Socket
Socket
Sign inDemoInstall

@webex/webex-core

Package Overview
Dependencies
Maintainers
21
Versions
1205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webex/webex-core - npm Package Compare versions

Comparing version 1.80.10 to 1.80.11

10

dist/interceptors/redirect.js

@@ -73,10 +73,8 @@ 'use strict';

value: function onRequest(options) {
if (options.uri && options.uri.includes('https://idbroker')) {
return options;
if (options && options.uri && typeof options.uri === 'string') {
if (options.uri.includes('https://idbroker') || options.uri.includes(this.webex.config.credentials.samlUrl) || options.uri.includes(this.webex.config.credentials.tokenUrl) || options.uri.includes(this.webex.config.credentials.authorizeUrl)) {
return options;
}
}
if (options.uri.includes(this.webex.config.credentials.samlUrl) || options.uri.includes(this.webex.config.credentials.tokenUrl) || options.uri.includes(this.webex.config.credentials.authorizeUrl)) {
return options;
}
// If cisco-no-http-redirect is already set, don't overwrite it

@@ -83,0 +81,0 @@ if (requestHeaderName in options.headers) {

2

dist/lib/batcher.js

@@ -354,3 +354,3 @@ 'use strict';

},
version: '1.80.9'
version: '1.80.10'
}); /*!

@@ -357,0 +357,0 @@ * Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.

@@ -581,3 +581,3 @@ 'use strict';

},
version: '1.80.9'
version: '1.80.10'
}, (_applyDecoratedDescriptor(_obj, 'getUserToken', [_dec, _dec2], (0, _getOwnPropertyDescriptor2.default)(_obj, 'getUserToken'), _obj), _applyDecoratedDescriptor(_obj, 'initialize', [_dec3], (0, _getOwnPropertyDescriptor2.default)(_obj, 'initialize'), _obj), _applyDecoratedDescriptor(_obj, 'invalidate', [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor2.default)(_obj, 'invalidate'), _obj), _applyDecoratedDescriptor(_obj, 'refresh', [_common.oneFlight, _dec5, _dec6], (0, _getOwnPropertyDescriptor2.default)(_obj, 'refresh'), _obj)), _obj)));

@@ -584,0 +584,0 @@

@@ -626,3 +626,3 @@ 'use strict';

},
version: '1.80.9'
version: '1.80.10'
}, (_applyDecoratedDescriptor(_obj, 'downscope', [_dec], (0, _getOwnPropertyDescriptor2.default)(_obj, 'downscope'), _obj), _applyDecoratedDescriptor(_obj, 'refresh', [_common.oneFlight], (0, _getOwnPropertyDescriptor2.default)(_obj, 'refresh'), _obj), _applyDecoratedDescriptor(_obj, 'revoke', [_common.oneFlight], (0, _getOwnPropertyDescriptor2.default)(_obj, 'revoke'), _obj)), _obj)));

@@ -629,0 +629,0 @@

@@ -19,2 +19,6 @@ 'use strict';

var _getIterator2 = require('babel-runtime/core-js/get-iterator');
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');

@@ -24,2 +28,6 @@

var _url = require('url');
var _url2 = _interopRequireDefault(_url);
var _ampersandState = require('ampersand-state');

@@ -141,2 +149,166 @@

/**
* Search over all service groups to find a cluster id based
* on a given url.
* @param {string} url - Must be parsable by `Url`
* @returns {string} - ClusterId of a given url
*/
findClusterId: function findClusterId(url) {
var incomingUrlObj = _url2.default.parse(url);
var clusterId = void 0;
var serviceUrlObj = void 0;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = (0, _getIterator3.default)((0, _keys2.default)(this.serviceGroups)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = (0, _getIterator3.default)(this.serviceGroups[key]), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var service = _step2.value;
serviceUrlObj = _url2.default.parse(service.defaultUrl);
if (serviceUrlObj.host === incomingUrlObj.host && service.hosts.length > 0) {
clusterId = service.hosts[0].id;
break;
}
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = (0, _getIterator3.default)(service.hosts), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var host = _step3.value;
if (incomingUrlObj.host === host.host && host.id) {
clusterId = host.id;
break;
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
if (clusterId) {
break;
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return clusterId;
},
/**
* Search over all service groups and return a service value from a provided
* clusterId. Currently, this method will return either a service name, or a
* service url depending on the `value` parameter. If the `value` parameter
* is set to `name`, it will return a service name to be utilized within the
* Services plugin methods.
* @param {object} params
* @param {string} params.clusterId - clusterId of found service
* @param {boolean} [params.priorityHost] - returns priority host url if true
* @param {string} [params.serviceGroup] - specify service group
* @returns {object} service
* @returns {string} service.name
* @returns {string} service.url
*/
findServiceFromClusterId: function findServiceFromClusterId() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
clusterId = _ref.clusterId,
_ref$priorityHost = _ref.priorityHost,
priorityHost = _ref$priorityHost === undefined ? true : _ref$priorityHost,
serviceGroup = _ref.serviceGroup;
var serviceUrls = typeof serviceGroup === 'string' ? this.serviceGroups[serviceGroup] || [] : [].concat((0, _toConsumableArray3.default)(this.serviceGroups.discovery), (0, _toConsumableArray3.default)(this.serviceGroups.preauth), (0, _toConsumableArray3.default)(this.serviceGroups.signin), (0, _toConsumableArray3.default)(this.serviceGroups.postauth));
var identifiedServiceUrl = serviceUrls.find(function (serviceUrl) {
return serviceUrl.hosts.find(function (host) {
return host.id === clusterId;
});
});
if (identifiedServiceUrl) {
return {
name: identifiedServiceUrl.name,
url: identifiedServiceUrl.get(priorityHost)
};
}
return undefined;
},
/**
* Find a service based on the provided url.
* @param {string} url - Must be parsable by `Url`
* @returns {serviceUrl} - ServiceUrl assocated with provided url
*/
findServiceUrlFromUrl: function findServiceUrlFromUrl(url) {
var incomingUrlObj = _url2.default.parse(url);
var serviceUrls = [].concat((0, _toConsumableArray3.default)(this.serviceGroups.discovery), (0, _toConsumableArray3.default)(this.serviceGroups.preauth), (0, _toConsumableArray3.default)(this.serviceGroups.signin), (0, _toConsumableArray3.default)(this.serviceGroups.postauth));
return serviceUrls.find(function (serviceUrl) {
if (incomingUrlObj.host === _url2.default.parse(serviceUrl.defaultUrl).host) {
return true;
}
if (serviceUrl.hosts.find(function (host) {
return host.host === incomingUrlObj.host;
})) {
return true;
}
return false;
});
},
/**
* Get a service url from the current services list by name.

@@ -143,0 +315,0 @@ * @param {string} name

@@ -388,2 +388,45 @@ 'use strict';

/**
* Get the clusterId associated with a URL string.
* @param {string} url
* @returns {string} - Cluster ID of url provided
*/
getClusterId: function getClusterId(url) {
var catalog = this._getCatalog();
return catalog.findClusterId(url);
},
/**
* Get a service value from a provided clusterId. This method will
* return an object containing both the name and url of a found service.
* @param {object} params
* @param {string} params.clusterId - clusterId of found service
* @param {boolean} [params.priorityHost] - returns priority host url if true
* @param {string} [params.serviceGroup] - specify service group
* @returns {object} service
* @returns {string} service.name
* @returns {string} service.url
*/
getServiceFromClusterId: function getServiceFromClusterId(params) {
var catalog = this._getCatalog();
return catalog.findServiceFromClusterId(params);
},
/**
* Verify that a provided url exists in the service
* catalog.
* @param {string} url
* @returns {boolean} - true if exists, false otherwise
*/
isServiceUrl: function isServiceUrl(url) {
var catalog = this._getCatalog();
return !!catalog.findServiceUrlFromUrl(url);
},
/**
* @private

@@ -453,3 +496,3 @@ * Simplified method wrapper for sending a request to get

},
version: '1.80.9'
version: '1.80.10'
});

@@ -456,0 +499,0 @@ /* eslint-enable no-underscore-dangle */

@@ -63,3 +63,3 @@ 'use strict';

trace: wrapConsoleMethod('trace'),
version: '1.80.9'
version: '1.80.10'
});

@@ -66,0 +66,0 @@

@@ -247,3 +247,3 @@ 'use strict';

var WebexCore = _ampersandState2.default.extend((_obj = {
version: '1.80.9',
version: '1.80.10',

@@ -888,3 +888,3 @@ children: {

WebexCore.version = '1.80.9';
WebexCore.version = '1.80.10';

@@ -891,0 +891,0 @@ (0, _webexInternalCorePluginMixin2.default)(_webexInternalCore2.default, _config2.default, interceptors);

{
"name": "@webex/webex-core",
"version": "1.80.10",
"version": "1.80.11",
"description": "Plugin handling for Cisco Webex",

@@ -30,13 +30,13 @@ "license": "MIT",

"lodash": "^4.17.15",
"@webex/common": "1.80.10",
"@webex/common-timers": "1.80.10",
"@webex/common": "1.80.11",
"@webex/common-timers": "1.80.11",
"ampersand-state": "^5.0.3",
"ampersand-events": "^2.0.2",
"@webex/http-core": "1.80.10",
"@webex/http-core": "1.80.11",
"ampersand-collection": "^2.0.2",
"uuid": "^3.3.2",
"core-decorators": "^0.20.0",
"@webex/webex-core": "1.80.10",
"@webex/webex-core": "1.80.11",
"envify": "^4.1.0"
}
}

@@ -29,10 +29,11 @@ /*!

onRequest(options) {
if (options.uri && options.uri.includes('https://idbroker')) {
return options;
if (options && options.uri && typeof options.uri === 'string') {
if (options.uri.includes('https://idbroker') ||
options.uri.includes(this.webex.config.credentials.samlUrl) ||
options.uri.includes(this.webex.config.credentials.tokenUrl) ||
options.uri.includes(this.webex.config.credentials.authorizeUrl)) {
return options;
}
}
if (options.uri.includes(this.webex.config.credentials.samlUrl) || options.uri.includes(this.webex.config.credentials.tokenUrl) || options.uri.includes(this.webex.config.credentials.authorizeUrl)) {
return options;
}
// If cisco-no-http-redirect is already set, don't overwrite it

@@ -39,0 +40,0 @@ if (requestHeaderName in options.headers) {

@@ -0,1 +1,3 @@

import Url from 'url';
import AmpState from 'ampersand-state';

@@ -110,2 +112,108 @@

/**
* Search over all service groups to find a cluster id based
* on a given url.
* @param {string} url - Must be parsable by `Url`
* @returns {string} - ClusterId of a given url
*/
findClusterId(url) {
const incomingUrlObj = Url.parse(url);
let clusterId;
let serviceUrlObj;
for (const key of Object.keys(this.serviceGroups)) {
for (const service of this.serviceGroups[key]) {
serviceUrlObj = Url.parse(service.defaultUrl);
if (serviceUrlObj.host === incomingUrlObj.host &&
service.hosts.length > 0) {
clusterId = service.hosts[0].id;
break;
}
for (const host of service.hosts) {
if (incomingUrlObj.host === host.host && host.id) {
clusterId = host.id;
break;
}
}
if (clusterId) {
break;
}
}
}
return clusterId;
},
/**
* Search over all service groups and return a service value from a provided
* clusterId. Currently, this method will return either a service name, or a
* service url depending on the `value` parameter. If the `value` parameter
* is set to `name`, it will return a service name to be utilized within the
* Services plugin methods.
* @param {object} params
* @param {string} params.clusterId - clusterId of found service
* @param {boolean} [params.priorityHost] - returns priority host url if true
* @param {string} [params.serviceGroup] - specify service group
* @returns {object} service
* @returns {string} service.name
* @returns {string} service.url
*/
findServiceFromClusterId({clusterId, priorityHost = true, serviceGroup} = {}) {
const serviceUrls = (typeof serviceGroup === 'string') ?
this.serviceGroups[serviceGroup] || [] :
[
...this.serviceGroups.discovery,
...this.serviceGroups.preauth,
...this.serviceGroups.signin,
...this.serviceGroups.postauth
];
const identifiedServiceUrl = serviceUrls.find(
(serviceUrl) => serviceUrl.hosts.find(
(host) => host.id === clusterId
)
);
if (identifiedServiceUrl) {
return {
name: identifiedServiceUrl.name,
url: identifiedServiceUrl.get(priorityHost)
};
}
return undefined;
},
/**
* Find a service based on the provided url.
* @param {string} url - Must be parsable by `Url`
* @returns {serviceUrl} - ServiceUrl assocated with provided url
*/
findServiceUrlFromUrl(url) {
const incomingUrlObj = Url.parse(url);
const serviceUrls = [
...this.serviceGroups.discovery,
...this.serviceGroups.preauth,
...this.serviceGroups.signin,
...this.serviceGroups.postauth
];
return serviceUrls.find(
(serviceUrl) => {
if (incomingUrlObj.host === Url.parse(serviceUrl.defaultUrl).host) {
return true;
}
if (serviceUrl.hosts.find((host) => host.host === incomingUrlObj.host)) {
return true;
}
return false;
}
);
},
/**
* Get a service url from the current services list by name.

@@ -112,0 +220,0 @@ * @param {string} name

@@ -318,2 +318,42 @@ import Url from 'url';

/**
* Get the clusterId associated with a URL string.
* @param {string} url
* @returns {string} - Cluster ID of url provided
*/
getClusterId(url) {
const catalog = this._getCatalog();
return catalog.findClusterId(url);
},
/**
* Get a service value from a provided clusterId. This method will
* return an object containing both the name and url of a found service.
* @param {object} params
* @param {string} params.clusterId - clusterId of found service
* @param {boolean} [params.priorityHost] - returns priority host url if true
* @param {string} [params.serviceGroup] - specify service group
* @returns {object} service
* @returns {string} service.name
* @returns {string} service.url
*/
getServiceFromClusterId(params) {
const catalog = this._getCatalog();
return catalog.findServiceFromClusterId(params);
},
/**
* Verify that a provided url exists in the service
* catalog.
* @param {string} url
* @returns {boolean} - true if exists, false otherwise
*/
isServiceUrl(url) {
const catalog = this._getCatalog();
return !!(catalog.findServiceUrlFromUrl(url));
},
/**
* @private

@@ -320,0 +360,0 @@ * Simplified method wrapper for sending a request to get

@@ -57,2 +57,6 @@ /*!

afterEach('unload test url', () => {
catalog._unloadServiceUrls('preauth', [testUrl]);
});
it('returns a ServiceUrl from a specific serviceGroup', () => {

@@ -83,2 +87,189 @@ const serviceUrl = catalog._getUrl(testUrlTemplate.name, 'preauth');

describe('#findClusterId()', () => {
let testUrlTemplate;
let testUrl;
beforeEach('load test url', () => {
testUrlTemplate = {
defaultUrl: 'https://www.example.com/api/v1',
hosts: [
{
host: 'www.example-p5.com',
ttl: -1,
priority: 5,
id: 'exampleClusterId'
},
{
host: 'www.example-p3.com',
ttl: -1,
priority: 3,
id: 'exampleClusterId'
}
],
name: 'exampleValid'
};
testUrl = new ServiceUrl({...testUrlTemplate});
catalog._loadServiceUrls('preauth', [testUrl]);
});
afterEach('unload test url', () => {
catalog._unloadServiceUrls('preauth', [testUrl]);
});
it('returns a clusterId when found with default url', () => {
assert.equal(catalog.findClusterId(testUrlTemplate.defaultUrl),
testUrlTemplate.hosts[0].id);
});
it('returns a clusterId when found with priority host url', () => {
assert.equal(catalog.findClusterId(testUrl.get(true)),
testUrlTemplate.hosts[0].id);
});
it('returns a clusterId when found with resource-appended url', () => {
assert.equal(catalog.findClusterId(`${testUrl.get()}example/resource/value`),
testUrlTemplate.hosts[0].id);
});
it('returns undefined when the url doesn\'t exist in catalog', () => {
assert.isUndefined(catalog.findClusterId('http://not-a-known-url.com/'));
});
it('returns undefined when the string isn\'t a url', () => {
assert.isUndefined(catalog.findClusterId('not a url'));
});
});
describe('#findServiceFromClusterId()', () => {
let testUrlTemplate;
let testUrl;
beforeEach('load test url', () => {
testUrlTemplate = {
defaultUrl: 'https://www.example.com/api/v1',
hosts: [
{
host: 'www.example-p5.com',
ttl: -1,
priority: 5,
id: 'exampleClusterId'
},
{
host: 'www.example-p3.com',
ttl: -1,
priority: 3,
id: 'exampleClusterId'
}
],
name: 'exampleValid'
};
testUrl = new ServiceUrl({...testUrlTemplate});
catalog._loadServiceUrls('preauth', [testUrl]);
});
afterEach('unload test url', () => {
catalog._unloadServiceUrls('preauth', [testUrl]);
});
it('finds a valid service url from only a clusterId', () => {
const serviceFound = catalog.findServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
priorityHost: false
});
assert.equal(serviceFound.name, testUrl.name);
assert.equal(serviceFound.url, testUrl.defaultUrl);
});
it('finds a valid priority service url', () => {
const serviceFound = catalog.findServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
priorityHost: true
});
assert.equal(serviceFound.name, testUrl.name);
assert.equal(serviceFound.url, catalog.get('exampleValid', true));
});
it('finds a valid service when a service group is defined', () => {
const serviceFound = catalog.findServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
priorityHost: false,
serviceGroup: 'preauth'
});
assert.equal(serviceFound.name, testUrl.name);
assert.equal(serviceFound.url, testUrl.defaultUrl);
});
it('fails to find a valid service when it\'s not in a group', () => {
assert.isUndefined(
catalog.findServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
serviceGroup: 'signin'
})
);
});
it('returns undefined when service doesn\'t exist', () => {
assert.isUndefined(
catalog.findServiceFromClusterId({clusterId: 'not a clusterId'})
);
});
});
describe('#findServiceUrlFromUrl()', () => {
let testUrlTemplate;
let testUrl;
beforeEach('load test url', () => {
testUrlTemplate = {
defaultUrl: 'https://www.example.com/api/v1',
hosts: [
{
host: 'www.example-p5.com',
ttl: -1,
priority: 5,
id: 'exampleClusterId'
},
{
host: 'www.example-p3.com',
ttl: -1,
priority: 3,
id: 'exampleClusterId'
}
],
name: 'exampleValid'
};
testUrl = new ServiceUrl({...testUrlTemplate});
catalog._loadServiceUrls('preauth', [testUrl]);
});
afterEach('unload test url', () => {
catalog._unloadServiceUrls('preauth', [testUrl]);
});
it('finds a service if it exists', () => {
assert.equal(
catalog.findServiceUrlFromUrl(testUrlTemplate.defaultUrl),
testUrl
);
});
it('finds a service if its a priority host url', () => {
assert.equal(
catalog.findServiceUrlFromUrl(testUrl.get(true)).name,
testUrl.name
);
});
it('returns undefined if the url doesn\'t exist', () => {
assert.isUndefined(catalog.findServiceUrlFromUrl('https://na.com/'));
});
it('returns undefined if the param is not a url', () => {
assert.isUndefined(catalog.findServiceUrlFromUrl('not a url'));
});
});
describe('#list()', () => {

@@ -147,2 +338,6 @@ it('retreives priority host urls base on priorityHost parameter', () => {

afterEach('unload test url', () => {
catalog._unloadServiceUrls('preauth', [testUrl]);
});
it('returns a valid string when name is specified', () => {

@@ -208,2 +403,6 @@ const url = catalog.get(testUrlTemplate.name);

afterEach('unload test url', () => {
catalog._unloadServiceUrls('preauth', [testUrl]);
});
it('marks a host as failed and removes from host list', () => {

@@ -210,0 +409,0 @@ const priorityUrl = catalog.get(testUrlTemplate.name, true);

@@ -110,3 +110,3 @@ /*!

describe('#markFailedUrl()', () => {
describe('#getClusterId()', () => {
let testUrlTemplate;

@@ -122,3 +122,4 @@ let testUrl;

ttl: -1,
priority: 5
priority: 5,
id: 'exampleClusterId'
},

@@ -128,3 +129,4 @@ {

ttl: -1,
priority: 3
priority: 3,
id: 'exampleClusterId'
}

@@ -138,2 +140,173 @@ ],

it('returns a clusterId when found with default url', () => {
assert.equal(services.getClusterId(testUrlTemplate.defaultUrl),
testUrlTemplate.hosts[0].id);
});
it('returns a clusterId when found with priority host url', () => {
assert.equal(services.getClusterId(testUrl.get(true)),
testUrlTemplate.hosts[0].id);
});
it('returns a clusterId when found with resource-appended url', () => {
assert.equal(
services.getClusterId(`${testUrl.get()}example/resource/value`),
testUrlTemplate.hosts[0].id
);
});
it('returns undefined when the url doesn\'t exist in catalog', () => {
assert.isUndefined(
services.getClusterId('http://not-a-known-url.com/')
);
});
it('returns undefined when the string isn\'t a url', () => {
assert.isUndefined(services.getClusterId('not a url'));
});
});
describe('#getServiceFromClusterId()', () => {
let testUrlTemplate;
let testUrl;
beforeEach('load test url', () => {
testUrlTemplate = {
defaultUrl: 'https://www.example.com/api/v1',
hosts: [
{
host: 'www.example-p5.com',
ttl: -1,
priority: 5,
id: 'exampleClusterId'
},
{
host: 'www.example-p3.com',
ttl: -1,
priority: 3,
id: 'exampleClusterId'
}
],
name: 'exampleValid'
};
testUrl = new ServiceUrl({...testUrlTemplate});
catalog._loadServiceUrls('preauth', [testUrl]);
});
it('finds a valid service url from only a clusterId', () => {
const serviceFound = services.getServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
priorityHost: false
});
assert.equal(serviceFound.name, testUrl.name);
assert.equal(serviceFound.url, testUrl.defaultUrl);
});
it('finds a valid priority service url', () => {
const serviceFound = services.getServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
priorityHost: true
});
assert.equal(serviceFound.name, testUrl.name);
assert.equal(serviceFound.url, catalog.get('exampleValid', true));
});
it('finds a valid service when a service group is defined', () => {
const serviceFound = catalog.findServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
priorityHost: false,
serviceGroup: 'preauth'
});
assert.equal(serviceFound.name, testUrl.name);
assert.equal(serviceFound.url, testUrl.defaultUrl);
});
it('fails to find a valid service when it\'s not in a group', () => {
assert.isUndefined(
services.getServiceFromClusterId({
clusterId: testUrlTemplate.hosts[0].id,
serviceGroup: 'signin'
})
);
});
it('returns undefined when service doesn\'t exist', () => {
assert.isUndefined(
services.getServiceFromClusterId({clusterId: 'not a clusterId'})
);
});
});
describe('#isServiceUrl()', () => {
let testUrlTemplate;
let testUrl;
beforeEach('load test url', () => {
testUrlTemplate = {
defaultUrl: 'https://www.example.com/api/v1',
hosts: [
{
host: 'www.example-p5.com',
ttl: -1,
priority: 5,
id: 'exampleClusterId'
},
{
host: 'www.example-p3.com',
ttl: -1,
priority: 3,
id: 'exampleClusterId'
}
],
name: 'exampleValid'
};
testUrl = new ServiceUrl({...testUrlTemplate});
catalog._loadServiceUrls('preauth', [testUrl]);
});
it('returns true if url is a service url', () => {
assert.isTrue(services.isServiceUrl(testUrlTemplate.defaultUrl));
});
it('returns true for priority host urls', () => {
assert.isTrue(services.isServiceUrl(testUrl.get(true)));
});
it('returns undefined if the url doesn\'t exist', () => {
assert.isFalse(services.isServiceUrl('https://na.com/'));
});
it('returns undefined if the param is not a url', () => {
assert.isFalse(services.isServiceUrl('not a url'));
});
});
describe('#markFailedUrl()', () => {
let testUrlTemplate;
let testUrl;
beforeEach('load test url', () => {
testUrlTemplate = {
defaultUrl: 'https://www.example-phr.com/api/v1',
hosts: [
{
host: 'www.example-phr-p5.com',
ttl: -1,
priority: 5
},
{
host: 'www.example-phr-p3.com',
ttl: -1,
priority: 3
}
],
name: 'exampleValid-phr'
};
testUrl = new ServiceUrl({...testUrlTemplate});
catalog._loadServiceUrls('preauth', [testUrl]);
});
it('marks a host as failed and removes from host list', () => {

@@ -140,0 +313,0 @@ const priorityUrl = services.get(testUrlTemplate.name, true);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc