Skip to content

Commit

Permalink
fix(test-users): request spark-test-account scopes when creating test…
Browse files Browse the repository at this point in the history
… users
  • Loading branch information
rstachof committed May 13, 2024
1 parent 3b0d670 commit 2eb70f1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
All contents are licensed under the Cisco EULA
(https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)
25 changes: 0 additions & 25 deletions LICENSE.md

This file was deleted.

3 changes: 2 additions & 1 deletion packages/@webex/test-users/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ function getClientCredentials({clientId, clientSecret, idbrokerUrl}) {
json: true,
form: {
grant_type: 'client_credentials',
scope: 'Identity:SCIM webexsquare:get_conversation',
scope:
'Identity:SCIM webexsquare:get_conversation spark-test-account:write spark-test:account:read',
client_id: clientId,
client_secret: clientSecret,
},
Expand Down
33 changes: 33 additions & 0 deletions packages/@webex/test-users/test/integration/spec/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,39 @@ assert.isTestUser = (user) => {
};

nodeOnly(describe)('test-users', () => {
describe('getClientCredentials', function () {
let requestStub;

beforeEach(function () {
requestStub = sinon.stub(request, 'post').resolves({
body: {token_type: 'Bearer', access_token: 'some-token'},
});
});

it('should call request with the correct scopes', function (done) {
const expectedScopes =
'Identity:SCIM webexsquare:get_conversation spark-test-account:write spark-test:account:read';

getClientCredentials({
clientId: '123',
clientSecret: 'abc',
idbrokerUrl: process.env.IDBROKER_BASE_URL || 'https://idbroker.webex.com',
})
.then(() => {
expect(requestStub.calledOnce).to.be.true;

const requestOptions = requestStub.firstCall.args[0];
expect(requestOptions.form.scope).to.equal(expectedScopes);
done();
})
.catch(done);
});

afterEach(function () {
sinon.restore();
});
});

const emailAddress = `test-${uuid.v4()}@wx2.example.com`;
const password = `${uuid.v4()}1@A`;
const displayName = uuid.v4();
Expand Down

0 comments on commit 2eb70f1

Please sign in to comment.