Skip to content

Commit

Permalink
feat(webex-core): method for manually updating the host catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
Coread committed Dec 18, 2024
1 parent 42bd008 commit d36aea3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/@webex/webex-core/src/lib/services/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,20 @@ const Services = WebexPlugin.extend({
);
},

/**
* Updates a given service group i.e. preauth, signin, postauth with a new hostmap.
* @param {string} serviceGroup - preauth, signin, postauth
* @param {object} hostMap - The new hostmap to update the service group with.
* @returns {Promise<void>}
*/
updateCatalog(serviceGroup, hostMap) {
const catalog = this._getCatalog();

const serviceHostMap = this._formatReceivedHostmap(hostMap);

return catalog.updateServiceUrls(serviceGroup, serviceHostMap);
},

/**
* simplified method to update the preauth catalog via email
*
Expand Down
19 changes: 19 additions & 0 deletions packages/@webex/webex-core/test/unit/spec/services/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,25 @@ describe('webex-core', () => {
});
});

describe('#updateCatalog', () => {
it('updates the catalog', async () => {
const serviceGroup = 'postauth';
const hostmap = {hostmap: 'hostmap'};

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

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

const result = await services.updateCatalog(serviceGroup, hostmap);

assert.calledWith(services._formatReceivedHostmap, hostmap);

assert.calledWith(catalog.updateServiceUrls, serviceGroup, {some: 'hostmap'});

assert.deepEqual(result, {some: 'value'});
});
});

describe('#_fetchNewServiceHostmap()', () => {

beforeEach(() => {
Expand Down

0 comments on commit d36aea3

Please sign in to comment.