Methods
createNumRequestCounter(attrs) → {object}
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
attrs |
object | Refer to individual attrs Properties
|
- Source:
Returns:
{ inc() {} }
.
- Type
- object
fakeJwtToken() → {string}
Generate a fake JWT Token valid for 1 hour for use in testing.
- Source:
Returns:
Fake JWT Token valid for 1 hour.
- Type
- string
generateFakeConfig(serviceClass, fakeKey, fakeUser, fakeauthorizedOrigins) → {object}
Generates a configuration object with a fake key based on the provided class. For use in auth tests where a config with a test key is required.
Parameters:
Name | Type | Description |
---|---|---|
serviceClass |
BaseService | The class to generate configuration for. |
fakeKey |
string | The fake key to be used in the configuration. |
fakeUser |
string | Optional, The fake user to be used in the configuration. |
fakeauthorizedOrigins |
string | authorizedOrigins to add to config. |
- Source:
Throws:
-
- Throws an error if the input is not a class.
- Type
- TypeError
Returns:
- The configuration object.
- Type
- object
getBadgeExampleCall(serviceClass) → {object}
Retrieves an example set of parameters for invoking a service class using OpenAPI example of that class.
Parameters:
Name | Type | Description |
---|---|---|
serviceClass |
BaseService | The service class containing OpenAPI specifications. |
- Source:
Throws:
-
- Throws a TypeError if the input
serviceClass
is not an instance of BaseService, or if it lacks the expected structure.
- Throws a TypeError if the input
- Type
- TypeError
Returns:
An object with call params to use with a service invoke of the first OpenAPI example.
- Type
- object
Example
// Example usage:
const example = getBadgeExampleCall(StackExchangeReputation)
console.log(example)
// Output: { stackexchangesite: 'stackoverflow', query: '123' }
StackExchangeReputation.invoke(defaultContext, config, example)
getServiceClassAuthOrigin(serviceClass) → {string}
Returns the first auth origin found for a provided service class.
Parameters:
Name | Type | Description |
---|---|---|
serviceClass |
BaseService | The service class to find the authorized origins. |
- Source:
Throws:
-
- Throws a TypeError if the input
serviceClass
is not an instance of BaseService.
- Throws a TypeError if the input
- Type
- TypeError
Returns:
First auth origin found.
- Type
- string
Example
// Example usage:
getServiceClassAuthOrigin(Obs)
// outputs 'https://api.opensuse.org'
isMetricWithPattern(nestedRegexp) → {function}
Parameters:
Name | Type | Description |
---|---|---|
nestedRegexp |
RegExp | Pattern that must appear after the metric. |
- Source:
Returns:
A function that returns a RegExp that matches a metric followed by another pattern.
- Type
- function
module:services/dynamic/json-path(superclass) → {function}
Dynamic service class factory which wraps module:core/base-service/base~BaseService with support of JSONPath.
Parameters:
Name | Type | Description |
---|---|---|
superclass |
function | class to extend |
- Source:
Returns:
wrapped class
- Type
- function
(async) testAuth(serviceClass, authMethod, dummyResponse, options)
Test authentication of a badge for it's first OpenAPI example using a provided dummyResponse and authentication method.
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
serviceClass |
BaseService | The service class tested. |
|||||||||||||||||||||
authMethod |
'BasicAuth' | 'ApiKeyHeader' | 'BearerAuthHeader' | 'QueryStringAuth' | 'JwtAuth' | The auth method of the tested service class. |
|||||||||||||||||||||
dummyResponse |
object | An object containing the dummy response by the server. |
|||||||||||||||||||||
options |
object | Additional options for non default keys and content-type of the dummy response. Properties
|
- Source:
Throws:
-
- Throws a TypeError if the input
serviceClass
is not an instance of BaseService, or ifserviceClass
is missing authorizedOrigins.
- Throws a TypeError if the input
- Type
- TypeError
Example
// Example usage:
testAuth(StackExchangeReputation, QueryStringAuth, { items: [{ reputation: 8 }] })