From 6e1e7468fbbfea8352de05ad0147131483208c6c Mon Sep 17 00:00:00 2001 From: cailbourdin Date: Tue, 10 Sep 2024 10:24:34 +0200 Subject: [PATCH] =?UTF-8?q?test:=20ajout=20scn=C3=A9ario=20puppeteer=20pro?= =?UTF-8?q?tocole=20SAML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- puppeteer/scenarios/saml_protocol.js | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 puppeteer/scenarios/saml_protocol.js diff --git a/puppeteer/scenarios/saml_protocol.js b/puppeteer/scenarios/saml_protocol.js new file mode 100644 index 0000000..30b31ae --- /dev/null +++ b/puppeteer/scenarios/saml_protocol.js @@ -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(); + } +})();