@webex/plugin-authorization-browser 2.59.1 → 2.59.3-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,90 +1,90 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- /* eslint-disable indent */
6
-
7
- import {createBrowser} from '@webex/test-helper-automation';
8
- import testUsers from '@webex/test-helper-test-users';
9
-
10
- import pkg from '../../../package';
11
-
12
- const redirectUri = process.env.WEBEX_REDIRECT_URI || process.env.REDIRECT_URI;
13
-
14
- describe('plugin-authorization-browser', function () {
15
- this.timeout(120000);
16
- describe('Authorization', () => {
17
- describe.skip('Implicit Grant', () => {
18
- let browser, user;
19
-
20
- before(() =>
21
- testUsers.create({count: 1}).then((users) => {
22
- user = users[0];
23
- })
24
- );
25
-
26
- before(() =>
27
- createBrowser(pkg).then((b) => {
28
- browser = b;
29
- })
30
- );
31
-
32
- after(() => browser && browser.printLogs());
33
-
34
- after(
35
- () =>
36
- browser &&
37
- browser.quit().catch((reason) => {
38
- console.warn(reason);
39
- })
40
- );
41
-
42
- it('authorizes a user', () =>
43
- browser
44
- .get(`${redirectUri}/${pkg.name}`)
45
- .waitForElementByClassName('ready')
46
- .title()
47
- .should.eventually.become('Authorization Automation Test')
48
- .waitForElementByCssSelector('[title="Login with Implicit Grant"]')
49
- .click()
50
- .login(user)
51
- .waitForElementByClassName('authorization-automation-test')
52
- .waitForElementByCssSelector('#ping-complete:not(:empty)')
53
- .text()
54
- .should.eventually.become('success'));
55
-
56
- it('is still logged in after reloading the page', () =>
57
- browser
58
- .waitForElementById('access-token')
59
- .text()
60
- .should.eventually.not.be.empty.url()
61
- .then((url) => browser.get(url))
62
- .sleep(500)
63
- .waitForElementById('access-token')
64
- .text().should.eventually.not.be.empty);
65
-
66
- it('logs out a user', () =>
67
- browser
68
- .title()
69
- .should.eventually.become('Authorization Automation Test')
70
- .waitForElementByCssSelector('[title="Logout"]')
71
- .click()
72
- // We need to revoke three tokens before the window.location assignment.
73
- // So far, I haven't found any ques to wait for, so sleep seems to be
74
- // the only option.
75
- .sleep(3000)
76
- .title()
77
- .should.eventually.become('Redirect Dispatcher')
78
- .get(`${redirectUri}/${pkg.name}`)
79
- .title()
80
- .should.eventually.become('Authorization Automation Test')
81
- .waitForElementById('access-token')
82
- .text()
83
- .should.eventually.be.empty.waitForElementByCssSelector(
84
- '[title="Login with Implicit Grant"]'
85
- )
86
- .click()
87
- .waitForElementById('IDToken1'));
88
- });
89
- });
90
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ /* eslint-disable indent */
6
+
7
+ import {createBrowser} from '@webex/test-helper-automation';
8
+ import testUsers from '@webex/test-helper-test-users';
9
+
10
+ import pkg from '../../../package';
11
+
12
+ const redirectUri = process.env.WEBEX_REDIRECT_URI || process.env.REDIRECT_URI;
13
+
14
+ describe('plugin-authorization-browser', function () {
15
+ this.timeout(120000);
16
+ describe('Authorization', () => {
17
+ describe.skip('Implicit Grant', () => {
18
+ let browser, user;
19
+
20
+ before(() =>
21
+ testUsers.create({count: 1}).then((users) => {
22
+ user = users[0];
23
+ })
24
+ );
25
+
26
+ before(() =>
27
+ createBrowser(pkg).then((b) => {
28
+ browser = b;
29
+ })
30
+ );
31
+
32
+ after(() => browser && browser.printLogs());
33
+
34
+ after(
35
+ () =>
36
+ browser &&
37
+ browser.quit().catch((reason) => {
38
+ console.warn(reason);
39
+ })
40
+ );
41
+
42
+ it('authorizes a user', () =>
43
+ browser
44
+ .get(`${redirectUri}/${pkg.name}`)
45
+ .waitForElementByClassName('ready')
46
+ .title()
47
+ .should.eventually.become('Authorization Automation Test')
48
+ .waitForElementByCssSelector('[title="Login with Implicit Grant"]')
49
+ .click()
50
+ .login(user)
51
+ .waitForElementByClassName('authorization-automation-test')
52
+ .waitForElementByCssSelector('#ping-complete:not(:empty)')
53
+ .text()
54
+ .should.eventually.become('success'));
55
+
56
+ it('is still logged in after reloading the page', () =>
57
+ browser
58
+ .waitForElementById('access-token')
59
+ .text()
60
+ .should.eventually.not.be.empty.url()
61
+ .then((url) => browser.get(url))
62
+ .sleep(500)
63
+ .waitForElementById('access-token')
64
+ .text().should.eventually.not.be.empty);
65
+
66
+ it('logs out a user', () =>
67
+ browser
68
+ .title()
69
+ .should.eventually.become('Authorization Automation Test')
70
+ .waitForElementByCssSelector('[title="Logout"]')
71
+ .click()
72
+ // We need to revoke three tokens before the window.location assignment.
73
+ // So far, I haven't found any ques to wait for, so sleep seems to be
74
+ // the only option.
75
+ .sleep(3000)
76
+ .title()
77
+ .should.eventually.become('Redirect Dispatcher')
78
+ .get(`${redirectUri}/${pkg.name}`)
79
+ .title()
80
+ .should.eventually.become('Authorization Automation Test')
81
+ .waitForElementById('access-token')
82
+ .text()
83
+ .should.eventually.be.empty.waitForElementByCssSelector(
84
+ '[title="Login with Implicit Grant"]'
85
+ )
86
+ .click()
87
+ .waitForElementById('IDToken1'));
88
+ });
89
+ });
90
+ });
@@ -1,76 +1,76 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import '@webex/plugin-authorization-node';
6
- import {browserOnly} from '@webex/test-helper-mocha';
7
- import {assert} from '@webex/test-helper-chai';
8
- import {createUser} from '@webex/test-helper-appid';
9
- import WebexCore from '@webex/webex-core';
10
- import uuid from 'uuid';
11
- import sinon from 'sinon';
12
-
13
- browserOnly(describe)('plugin-authorization-browser', () => {
14
- describe('Authorization', () => {
15
- describe('#requestAccessTokenFromJwt', () => {
16
- it('exchanges a JWT for an appid access token', () => {
17
- const userId = uuid.v4();
18
- const displayName = `test-${userId}`;
19
-
20
- return createUser({displayName, userId}).then(({jwt}) => {
21
- const webex = new WebexCore();
22
-
23
- return webex.authorization
24
- .requestAccessTokenFromJwt({jwt})
25
- .then(() => assert.isTrue(webex.canAuthorize));
26
- });
27
- });
28
-
29
- it('should call services#initServiceCatalogs()', () => {
30
- const webex = new WebexCore();
31
- const userId = uuid.v4();
32
- const displayName = `test-${userId}`;
33
-
34
- webex.internal.services.initServiceCatalogs = sinon.spy();
35
-
36
- return createUser({displayName, userId})
37
- .then(({jwt}) => webex.authorization.requestAccessTokenFromJwt({jwt}))
38
- .then(() => assert.called(webex.internal.services.initServiceCatalogs));
39
- });
40
- });
41
-
42
- describe.skip("'#refresh", () => {
43
- describe('when used with an appid access token', () => {
44
- it('refreshes the access token', () => {
45
- const userId = uuid.v4();
46
- const displayName = `test-${userId}`;
47
-
48
- return createUser({displayName, userId}).then(({jwt}) => {
49
- const webex = new WebexCore({
50
- config: {
51
- credentials: {
52
- jwtRefreshCallback() {
53
- return createUser({displayName, userId}).then(({jwt}) => jwt);
54
- },
55
- },
56
- },
57
- });
58
- let token;
59
-
60
- return webex.authorization
61
- .requestAccessTokenFromJwt({jwt})
62
- .then(() => {
63
- token = webex.credentials.supertoken.access_token;
64
- assert.isTrue(webex.canAuthorize);
65
- })
66
- .then(() => webex.refresh())
67
- .then(() => {
68
- assert.isTrue(webex.canAuthorize);
69
- assert.notEqual(webex.credentials.supertoken.access_token, token);
70
- });
71
- });
72
- });
73
- });
74
- });
75
- });
76
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import '@webex/plugin-authorization-node';
6
+ import {browserOnly} from '@webex/test-helper-mocha';
7
+ import {assert} from '@webex/test-helper-chai';
8
+ import {createUser} from '@webex/test-helper-appid';
9
+ import WebexCore from '@webex/webex-core';
10
+ import uuid from 'uuid';
11
+ import sinon from 'sinon';
12
+
13
+ browserOnly(describe)('plugin-authorization-browser', () => {
14
+ describe('Authorization', () => {
15
+ describe('#requestAccessTokenFromJwt', () => {
16
+ it('exchanges a JWT for an appid access token', () => {
17
+ const userId = uuid.v4();
18
+ const displayName = `test-${userId}`;
19
+
20
+ return createUser({displayName, userId}).then(({jwt}) => {
21
+ const webex = new WebexCore();
22
+
23
+ return webex.authorization
24
+ .requestAccessTokenFromJwt({jwt})
25
+ .then(() => assert.isTrue(webex.canAuthorize));
26
+ });
27
+ });
28
+
29
+ it('should call services#initServiceCatalogs()', () => {
30
+ const webex = new WebexCore();
31
+ const userId = uuid.v4();
32
+ const displayName = `test-${userId}`;
33
+
34
+ webex.internal.services.initServiceCatalogs = sinon.spy();
35
+
36
+ return createUser({displayName, userId})
37
+ .then(({jwt}) => webex.authorization.requestAccessTokenFromJwt({jwt}))
38
+ .then(() => assert.called(webex.internal.services.initServiceCatalogs));
39
+ });
40
+ });
41
+
42
+ describe.skip("'#refresh", () => {
43
+ describe('when used with an appid access token', () => {
44
+ it('refreshes the access token', () => {
45
+ const userId = uuid.v4();
46
+ const displayName = `test-${userId}`;
47
+
48
+ return createUser({displayName, userId}).then(({jwt}) => {
49
+ const webex = new WebexCore({
50
+ config: {
51
+ credentials: {
52
+ jwtRefreshCallback() {
53
+ return createUser({displayName, userId}).then(({jwt}) => jwt);
54
+ },
55
+ },
56
+ },
57
+ });
58
+ let token;
59
+
60
+ return webex.authorization
61
+ .requestAccessTokenFromJwt({jwt})
62
+ .then(() => {
63
+ token = webex.credentials.supertoken.access_token;
64
+ assert.isTrue(webex.canAuthorize);
65
+ })
66
+ .then(() => webex.refresh())
67
+ .then(() => {
68
+ assert.isTrue(webex.canAuthorize);
69
+ assert.notEqual(webex.credentials.supertoken.access_token, token);
70
+ });
71
+ });
72
+ });
73
+ });
74
+ });
75
+ });
76
+ });