Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ const Services = WebexPlugin.extend({
this.initServiceCatalogs().catch((error) => {
this.initFailed = true;
this.logger.error(
`services: failed to init initial services when credentials available, ${error?.message}`
`services: failed to init services when credentials available, ${error?.message}`
);
});
} else {
Expand Down Expand Up @@ -1506,7 +1506,7 @@ const Services = WebexPlugin.extend({
.catch((error) => {
this.initFailed = true;
this.logger.error(
`services: failed to init initial services when credentials available, ${error?.message}`
`services: failed to init services when credentials available, ${error?.message}`
);
})
.finally(() => this._finalizeReady());
Expand Down
4 changes: 2 additions & 2 deletions packages/@webex/webex-core/src/lib/services/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ const Services = WebexPlugin.extend({
this.initServiceCatalogs().catch((error) => {
this.initFailed = true;
this.logger.error(
`services: failed to init initial services when credentials available, ${error?.message}`
`services: failed to init services when credentials available, ${error?.message}`
);
});
} else {
Expand Down Expand Up @@ -1548,7 +1548,7 @@ const Services = WebexPlugin.extend({
.catch((error) => {
this.initFailed = true;
this.logger.error(
`services: failed to init initial services when credentials available, ${error?.message}`
`services: failed to init services when credentials available, ${error?.message}`
);
})
.finally(() => this._finalizeReady());
Expand Down
149 changes: 89 additions & 60 deletions packages/@webex/webex-core/test/unit/spec/services-v2/services-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('webex-core', () => {
assert.isTrue(services.initFailed);
sinon.assert.calledWith(
services.logger.error,
`services: failed to init initial services when no credentials available, ${expectedMessage}`
`services: failed to init services when no credentials available, ${expectedMessage}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the v2 no-credentials expectation

When this no-credentials rejection path runs, ServicesV2._initializeCatalogsUngated() still logs services: failed to init initial services when no credentials available, ... in packages/@webex/webex-core/src/lib/services-v2/services-v2.ts:1457. This updated assertion drops initial, so both parameterized collectPreauthCatalog failure cases fail even though the implementation under test has not changed on that branch.

Useful? React with 👍 / 👎.

);
}
);
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('webex-core', () => {
assert.isTrue(services.initFailed);
sinon.assert.calledWith(
services.logger.error,
`services: failed to init initial services when credentials available, ${expectedMessage}`
`services: failed to init services when credentials available, ${expectedMessage}`
);
}
);
Expand All @@ -138,7 +138,10 @@ describe('webex-core', () => {
// ungated mode, flips services.ready to true.
services.listenToOnce.getCall(0).args[2]();

assert.isTrue(services.ready, 'services.ready should be true so it does not block webex.ready');
assert.isTrue(
services.ready,
'services.ready should be true so it does not block webex.ready'
);
});

it('listens on the "ready" event when waitForCatalogInit is disabled (default)', () => {
Expand Down Expand Up @@ -573,7 +576,7 @@ describe('webex-core', () => {

services.initServiceCatalogs = sinon.stub().returns(Promise.resolve());
services.webex.credentials = {
getOrgId: sinon.stub().returns('')
getOrgId: sinon.stub().returns(''),
};
catalog.status = {};
});
Expand Down Expand Up @@ -614,7 +617,7 @@ describe('webex-core', () => {
const serviceGroup = 'postauth';
const hostmap = {services: [{hostmap: 'hostmap'}]};

services._formatReceivedHostmap = sinon.stub().returns({services : [{some: 'hostmap'}]});
services._formatReceivedHostmap = sinon.stub().returns({services: [{some: 'hostmap'}]});

catalog.updateServiceGroups = sinon.stub().returns(Promise.resolve([{some: 'value'}]));

Expand All @@ -630,7 +633,7 @@ describe('webex-core', () => {
const serviceGroup = 'postauth';
const hostmap = {};

services._formatReceivedHostmap = sinon.stub().returns({services : undefined});
services._formatReceivedHostmap = sinon.stub().returns({services: undefined});

catalog.updateServiceGroups = sinon.stub().returns(Promise.resolve([{some: 'value'}]));

Expand Down Expand Up @@ -869,21 +872,25 @@ describe('webex-core', () => {
});

describe('#invalidateCache', () => {
beforeEach( () => {
beforeEach(() => {
services.initServiceCatalogs = sinon.stub().returns(Promise.resolve());
services.webex.credentials = {
getOrgId: sinon.stub().returns('')
getOrgId: sinon.stub().returns(''),
};
catalog.status = {};
})
});
it('should log the timestamp parameter', async () => {
const timestamp = '1234567890';
services.logger.info = sinon.stub();
services._getCatalog = sinon.stub().returns({timestamp: '1234567880'});

await services.invalidateCache(timestamp);

assert.calledWith(services.logger.info, 'services: invalidate cache, timestamp:', timestamp);
assert.calledWith(
services.logger.info,
'services: invalidate cache, timestamp:',
timestamp
);
});

it('should call initServiceCatalogs when invalidate timestamp is newer than catalog timestamp', async () => {
Expand Down Expand Up @@ -1010,30 +1017,30 @@ describe('webex-core', () => {
// Arrange: seed internal _services with mobius (including duplicate baseUrl)
services._services = [
{
"id": "urn:TEAM:us-east-2_a:mobius",
"serviceName": 'mobius',
"serviceUrls": [
{"baseUrl": 'https://mobius-us-east-2.prod.infra.webex.com/api/v1', "priority": 5},
{"baseUrl": 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1', "priority": 10},
{"baseUrl": 'https://mobius-ap-southeast-2.prod.infra.webex.com/api/v1', "priority": 15}, // duplicate
id: 'urn:TEAM:us-east-2_a:mobius',
serviceName: 'mobius',
serviceUrls: [
{baseUrl: 'https://mobius-us-east-2.prod.infra.webex.com/api/v1', priority: 5},
{baseUrl: 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1', priority: 10},
{baseUrl: 'https://mobius-ap-southeast-2.prod.infra.webex.com/api/v1', priority: 15}, // duplicate
],
},
{
"id": "urn:TEAM:ap-southeast-2_m:mobius",
"serviceName": "mobius",
"serviceUrls": [
{
"baseUrl": "https://mobius-me-central-1.prod.infra.webex.com/api/v1",
"priority": 5
},
{
"baseUrl": "https://mobius-eu-central-1.prod.infra.webex.com/api/v1",
"priority": 10
},
{
"baseUrl": "https://mobius-ap-southeast-2.prod.infra.webex.com/api/v1",
"priority": 15
},
id: 'urn:TEAM:ap-southeast-2_m:mobius',
serviceName: 'mobius',
serviceUrls: [
{
baseUrl: 'https://mobius-me-central-1.prod.infra.webex.com/api/v1',
priority: 5,
},
{
baseUrl: 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1',
priority: 10,
},
{
baseUrl: 'https://mobius-ap-southeast-2.prod.infra.webex.com/api/v1',
priority: 15,
},
],
},
// Non-mobius service should be ignored by getMobiusClusters
Expand All @@ -1051,42 +1058,64 @@ describe('webex-core', () => {
assert.deepEqual(
clusters.map(({host, id, ttl, priority}) => ({host, id, ttl, priority})),
[
{host: 'mobius-us-east-2.prod.infra.webex.com', id: 'urn:TEAM:us-east-2_a:mobius', ttl: 0, priority: 5},
{host: 'mobius-eu-central-1.prod.infra.webex.com', id: 'urn:TEAM:us-east-2_a:mobius', ttl: 0, priority: 10},
{host: 'mobius-ap-southeast-2.prod.infra.webex.com', id: 'urn:TEAM:us-east-2_a:mobius', ttl: 0, priority: 15},
{host: 'mobius-me-central-1.prod.infra.webex.com', id: 'urn:TEAM:ap-southeast-2_m:mobius', ttl: 0, priority: 5},
{
host: 'mobius-us-east-2.prod.infra.webex.com',
id: 'urn:TEAM:us-east-2_a:mobius',
ttl: 0,
priority: 5,
},
{
host: 'mobius-eu-central-1.prod.infra.webex.com',
id: 'urn:TEAM:us-east-2_a:mobius',
ttl: 0,
priority: 10,
},
{
host: 'mobius-ap-southeast-2.prod.infra.webex.com',
id: 'urn:TEAM:us-east-2_a:mobius',
ttl: 0,
priority: 15,
},
{
host: 'mobius-me-central-1.prod.infra.webex.com',
id: 'urn:TEAM:ap-southeast-2_m:mobius',
ttl: 0,
priority: 5,
},
]
);
});
});

describe('#isValidHost', () => {
beforeEach(() => {
// Setting up a mock services list
services._services = [{
"id": "urn:IDENTITY:PC75:adminAudit",
"serviceName": "adminAudit",
"serviceUrls": [
{
"baseUrl": "https://audit-ci-r.wbx2.com/audit-ci/api/v2",
"priority": 5
},
{
"baseUrl": "https://audit-ci-t.wbx2.com/audit-ci/api/v2",
"priority": 10
}
]
},
{
"id": "urn:IDENTITY:PC75:cdf",
"serviceName": "cdf",
"serviceUrls": [
{
"baseUrl": "https://wapdavis.webex.com/davis/api/v1",
"priority": 5
}
]
}];
services._services = [
{
id: 'urn:IDENTITY:PC75:adminAudit',
serviceName: 'adminAudit',
serviceUrls: [
{
baseUrl: 'https://audit-ci-r.wbx2.com/audit-ci/api/v2',
priority: 5,
},
{
baseUrl: 'https://audit-ci-t.wbx2.com/audit-ci/api/v2',
priority: 10,
},
],
},
{
id: 'urn:IDENTITY:PC75:cdf',
serviceName: 'cdf',
serviceUrls: [
{
baseUrl: 'https://wapdavis.webex.com/davis/api/v1',
priority: 5,
},
],
},
];
});
afterAll(() => {
// Clean up the mock services list
Expand Down
Loading
Loading