From 2eb70f15ba5454d6c62bb322241749732ea8182f Mon Sep 17 00:00:00 2001 From: rstachof Date: Fri, 10 May 2024 17:51:04 -0400 Subject: [PATCH] fix(test-users): request spark-test-account scopes when creating test users --- LICENSE | 2 ++ LICENSE.md | 25 -------------- packages/@webex/test-users/src/index.js | 3 +- .../test-users/test/integration/spec/index.js | 33 +++++++++++++++++++ 4 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 LICENSE delete mode 100644 LICENSE.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..c93cef35444 --- /dev/null +++ b/LICENSE @@ -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) \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index d0063c2c6f8..00000000000 --- a/LICENSE.md +++ /dev/null @@ -1,25 +0,0 @@ -Your use of the AI effects in this library (e.g., noise reduction, virtual background, etc.) are subject to the [Cisco General Terms](https://www.cisco.com/c/dam/en_us/about/doing_business/legal/Cisco_General_Terms.pdf). - -The contents of this repository are licensed pursuant to the terms of the MIT License below. - -### MIT License - -Copyright (c) 2024 Cisco Systems - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/@webex/test-users/src/index.js b/packages/@webex/test-users/src/index.js index de5f5408e15..a694f6110df 100644 --- a/packages/@webex/test-users/src/index.js +++ b/packages/@webex/test-users/src/index.js @@ -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, }, diff --git a/packages/@webex/test-users/test/integration/spec/index.js b/packages/@webex/test-users/test/integration/spec/index.js index 09fc9d55456..288fff9a60e 100644 --- a/packages/@webex/test-users/test/integration/spec/index.js +++ b/packages/@webex/test-users/test/integration/spec/index.js @@ -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();