Skip to content

Commit

Permalink
test: ajout scnéario puppeteer protocole SAML
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancailbourdin committed Sep 10, 2024
1 parent e4e9b51 commit 6e1e746
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions puppeteer/scenarios/saml_protocol.js
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();
}
})();

0 comments on commit 6e1e746

Please sign in to comment.