-
Notifications
You must be signed in to change notification settings - Fork 141
/
userinfo.test.js
50 lines (45 loc) · 1.19 KB
/
userinfo.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const { assert } = require('chai');
const puppeteer = require('puppeteer');
const provider = require('./fixture/oidc-provider');
const {
baseUrl,
start,
runExample,
stubEnv,
goto,
login,
} = require('./fixture/helpers');
describe('fetch userinfo', async () => {
let authServer;
let appServer;
beforeEach(async () => {
stubEnv();
authServer = await start(provider, 3001);
appServer = await runExample('userinfo');
});
afterEach(async () => {
authServer.close();
appServer.close();
});
it('should login with hybrid flow and fetch userinfo', async () => {
const browser = await puppeteer.launch({
args: puppeteer
.defaultArgs()
.concat(['--no-sandbox', '--disable-setuid-sandbox']),
});
const page = await browser.newPage();
await goto(baseUrl, page);
assert.match(
page.url(),
/http:\/\/localhost:3001\/interaction/,
'User should have been redirected to the auth server to login'
);
await login('username', 'password', page);
assert.equal(
page.url(),
`${baseUrl}/`,
'User is returned to the original page'
);
assert.include(await page.content(), 'hello username');
});
});