-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: ajout scnéario puppeteer protocole SAML
- Loading branch information
1 parent
e4e9b51
commit 6e1e746
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const cas = require("../cas.js"); | ||
const puppeteer = require('puppeteer'); | ||
const assert = require("assert"); | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch(cas.browserOptions()); | ||
|
||
try { | ||
const page = await browser.newPage(); | ||
const client = await page.createCDPSession(); | ||
|
||
// Login to cas | ||
await page.goto("http://localhost:8011/?sso"); | ||
await cas.typeCredentialsAndEnter(page, "test1", "test"); | ||
await page.waitForNavigation(); | ||
|
||
// Assert that TGC exists | ||
await cas.verifyTGC(client) | ||
|
||
// waitForNetworkIdle is necessary in that case to obtain pageContent, or we get an error "Execution context was destroyed" | ||
await page.waitForNetworkIdle(); | ||
const pageContent = await page.content(); | ||
|
||
// Assert that user is logged in | ||
assert(pageContent.includes("authenticationDate")) | ||
assert(pageContent.includes("Logout")) | ||
|
||
process.exit(0) | ||
|
||
} catch (e) { | ||
cas.loge(e); | ||
process.exit(1) | ||
} finally { | ||
await browser.close(); | ||
} | ||
})(); |