-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathhappy-login.js
More file actions
53 lines (46 loc) · 1.67 KB
/
happy-login.js
File metadata and controls
53 lines (46 loc) · 1.67 KB
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
51
52
53
const { By, Key, until, Builder } = require('selenium-webdriver')
require('chromedriver')
const assert = require('assert')
const { buildDriver, captureScreensFor, teardown } = require('../../utils')
const OverviewPage = require('../../pageobjects/OverviewPage')
const FakePortalPage = require('../../pageobjects/FakePortalPage')
describe('A user with a JWT token', function () {
let driver
let overview
let captureScreen
let fakePortal
let username
let password
before(async function () {
username = process.env.MGT_CLIENT_ID_FOR_IDP_INITIATED || 'rabbit_idp_user'
password = process.env.MGT_CLIENT_SECRET_FOR_IDP_INITIATED || 'rabbit_idp_user'
driver = buildDriver()
overview = new OverviewPage(driver)
captureScreen = captureScreensFor(driver, __filename)
fakePortal = new FakePortalPage(driver)
})
it('can log in presenting the token to the /login URL via fakeportal', async function () {
await fakePortal.goToHome(username, password)
if (!await fakePortal.isLoaded()) {
throw new Error('Failed to load fakePortal')
}
await fakePortal.login()
await overview.isLoaded()
assert.equal(await overview.getUser(), 'User ' + username)
})
it ('can reload page without being logged out', async function() {
await fakePortal.goToHome(username, password)
if (!await fakePortal.isLoaded()) {
throw new Error('Failed to load fakePortal')
}
await fakePortal.login()
await overview.isLoaded()
await overview.refresh()
if (!await overview.isLoaded()) {
throw new Error('Failed to keep session opened')
}
})
after(async function () {
await teardown(driver, this, captureScreen)
})
})