@webex/plugin-authorization-browser 3.0.0-beta.13 → 3.0.0-beta.15
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.
- package/dist/authorization.js +1 -1
- package/dist/authorization.js.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/authorization.js +28 -24
- package/src/config.js +2 -2
- package/src/index.js +2 -5
- package/test/automation/fixtures/app.js +25 -24
- package/test/automation/fixtures/index.html +21 -16
- package/test/automation/spec/authorization-code-grant.js +74 -66
- package/test/automation/spec/implicit-grant.js +48 -41
- package/test/integration/spec/authorization.js +30 -31
- package/test/unit/spec/authorization.js +169 -132
|
@@ -17,67 +17,74 @@ describe('plugin-authorization-browser', function () {
|
|
|
17
17
|
describe.skip('Implicit Grant', () => {
|
|
18
18
|
let browser, user;
|
|
19
19
|
|
|
20
|
-
before(() =>
|
|
21
|
-
.then((users) => {
|
|
20
|
+
before(() =>
|
|
21
|
+
testUsers.create({count: 1}).then((users) => {
|
|
22
22
|
user = users[0];
|
|
23
|
-
})
|
|
23
|
+
})
|
|
24
|
+
);
|
|
24
25
|
|
|
25
|
-
before(() =>
|
|
26
|
-
.then((b) => {
|
|
26
|
+
before(() =>
|
|
27
|
+
createBrowser(pkg).then((b) => {
|
|
27
28
|
browser = b;
|
|
28
|
-
})
|
|
29
|
+
})
|
|
30
|
+
);
|
|
29
31
|
|
|
30
32
|
after(() => browser && browser.printLogs());
|
|
31
33
|
|
|
32
|
-
after(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
after(
|
|
35
|
+
() =>
|
|
36
|
+
browser &&
|
|
37
|
+
browser.quit().catch((reason) => {
|
|
38
|
+
console.warn(reason);
|
|
39
|
+
})
|
|
40
|
+
);
|
|
36
41
|
|
|
37
|
-
it('authorizes a user', () =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
it('authorizes a user', () =>
|
|
43
|
+
browser
|
|
44
|
+
.get(`${redirectUri}/${pkg.name}`)
|
|
45
|
+
.waitForElementByClassName('ready')
|
|
46
|
+
.title()
|
|
41
47
|
.should.eventually.become('Authorization Automation Test')
|
|
42
|
-
|
|
48
|
+
.waitForElementByCssSelector('[title="Login with Implicit Grant"]')
|
|
43
49
|
.click()
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
.login(user)
|
|
51
|
+
.waitForElementByClassName('authorization-automation-test')
|
|
52
|
+
.waitForElementByCssSelector('#ping-complete:not(:empty)')
|
|
47
53
|
.text()
|
|
48
|
-
|
|
54
|
+
.should.eventually.become('success'));
|
|
49
55
|
|
|
50
|
-
it('is still logged in after reloading the page', () =>
|
|
51
|
-
|
|
56
|
+
it('is still logged in after reloading the page', () =>
|
|
57
|
+
browser
|
|
58
|
+
.waitForElementById('access-token')
|
|
52
59
|
.text()
|
|
53
|
-
|
|
54
|
-
.url()
|
|
60
|
+
.should.eventually.not.be.empty.url()
|
|
55
61
|
.then((url) => browser.get(url))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.text()
|
|
59
|
-
.should.eventually.not.be.empty);
|
|
62
|
+
.sleep(500)
|
|
63
|
+
.waitForElementById('access-token')
|
|
64
|
+
.text().should.eventually.not.be.empty);
|
|
60
65
|
|
|
61
|
-
it('logs out a user', () =>
|
|
62
|
-
|
|
66
|
+
it('logs out a user', () =>
|
|
67
|
+
browser
|
|
68
|
+
.title()
|
|
63
69
|
.should.eventually.become('Authorization Automation Test')
|
|
64
|
-
|
|
70
|
+
.waitForElementByCssSelector('[title="Logout"]')
|
|
65
71
|
.click()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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()
|
|
71
77
|
.should.eventually.become('Redirect Dispatcher')
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
.get(`${redirectUri}/${pkg.name}`)
|
|
79
|
+
.title()
|
|
74
80
|
.should.eventually.become('Authorization Automation Test')
|
|
75
|
-
|
|
81
|
+
.waitForElementById('access-token')
|
|
76
82
|
.text()
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
.should.eventually.be.empty.waitForElementByCssSelector(
|
|
84
|
+
'[title="Login with Implicit Grant"]'
|
|
85
|
+
)
|
|
79
86
|
.click()
|
|
80
|
-
|
|
87
|
+
.waitForElementById('IDToken1'));
|
|
81
88
|
});
|
|
82
89
|
});
|
|
83
90
|
});
|
|
@@ -17,13 +17,13 @@ browserOnly(describe)('plugin-authorization-browser', () => {
|
|
|
17
17
|
const userId = uuid.v4();
|
|
18
18
|
const displayName = `test-${userId}`;
|
|
19
19
|
|
|
20
|
-
return createUser({displayName, userId})
|
|
21
|
-
|
|
22
|
-
const webex = new WebexCore();
|
|
20
|
+
return createUser({displayName, userId}).then(({jwt}) => {
|
|
21
|
+
const webex = new WebexCore();
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
return webex.authorization
|
|
24
|
+
.requestAccessTokenFromJwt({jwt})
|
|
25
|
+
.then(() => assert.isTrue(webex.canAuthorize));
|
|
26
|
+
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it('should call services#initServiceCatalogs()', () => {
|
|
@@ -39,37 +39,36 @@ browserOnly(describe)('plugin-authorization-browser', () => {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
describe.skip('
|
|
42
|
+
describe.skip("'#refresh", () => {
|
|
43
43
|
describe('when used with an appid access token', () => {
|
|
44
44
|
it('refreshes the access token', () => {
|
|
45
45
|
const userId = uuid.v4();
|
|
46
46
|
const displayName = `test-${userId}`;
|
|
47
47
|
|
|
48
|
-
return createUser({displayName, userId})
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
let token;
|
|
61
|
-
|
|
62
|
-
return webex.authorization.requestAccessTokenFromJwt({jwt})
|
|
63
|
-
.then(() => {
|
|
64
|
-
token = webex.credentials.supertoken.access_token;
|
|
65
|
-
assert.isTrue(webex.canAuthorize);
|
|
66
|
-
})
|
|
67
|
-
.then(() => webex.refresh())
|
|
68
|
-
.then(() => {
|
|
69
|
-
assert.isTrue(webex.canAuthorize);
|
|
70
|
-
assert.notEqual(webex.credentials.supertoken.access_token, token);
|
|
71
|
-
});
|
|
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
|
+
},
|
|
72
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
|
+
});
|
|
73
72
|
});
|
|
74
73
|
});
|
|
75
74
|
});
|