From c86b8a3c7bac79b372fcbf466d138f617d1b9777 Mon Sep 17 00:00:00 2001 From: Jonas Gloning <34194370+jonasgloning@users.noreply.github.com> Date: Sat, 27 Apr 2024 17:57:03 +0200 Subject: [PATCH] test(e2e): Bypass Cloudflare's WAF via API key ref PJS-2059 --- .github/workflows/browserstack.yml | 2 ++ e2e/datachannel/serialization.js | 6 +++++- e2e/datachannel/serialization.page.ts | 7 +++++-- e2e/mediachannel/close.js | 4 +++- e2e/mediachannel/close.page.ts | 7 +++++-- e2e/peer/disconnected.html | 4 +++- e2e/peer/id-taken.html | 6 ++++-- e2e/peer/peer.page.ts | 5 ++++- 8 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/browserstack.yml b/.github/workflows/browserstack.yml index 0ed24b2db..ed7c6681f 100644 --- a/.github/workflows/browserstack.yml +++ b/.github/workflows/browserstack.yml @@ -34,6 +34,8 @@ jobs: - name: "Running test on BrowserStack" # Invokes the actual test script that would run on BrowserStack browsers run: npm run e2e:bstack # See sample test script above + env: + BYPASS_WAF: ${{ secrets.BYPASS_WAF }} - name: "BrowserStackLocal Stop" # Terminating the BrowserStackLocal tunnel connection uses: browserstack/github-actions/setup-local@master diff --git a/e2e/datachannel/serialization.js b/e2e/datachannel/serialization.js index 3231d6a1d..2d5c56e64 100644 --- a/e2e/datachannel/serialization.js +++ b/e2e/datachannel/serialization.js @@ -32,7 +32,11 @@ const serialization = params.get("serialization"); const result = document.getElementById("result"); const errorMessage = document.getElementById("error-message"); - const peer = new Peer({ debug: 3, serializers }); + const peer = new Peer({ + debug: 3, + serializers, + key: params.get("key"), + }); const received = []; /** * @type {import("../../lib/exports.js").DataConnection} diff --git a/e2e/datachannel/serialization.page.ts b/e2e/datachannel/serialization.page.ts index 1f253b932..2411b705f 100644 --- a/e2e/datachannel/serialization.page.ts +++ b/e2e/datachannel/serialization.page.ts @@ -1,4 +1,7 @@ import { browser, $ } from "@wdio/globals"; + +const { BYPASS_WAF } = process.env; + class SerializationPage { get sendBtn() { return $("button[id='send-btn']"); @@ -40,13 +43,13 @@ class SerializationPage { async open(testFile: string, serialization: string) { await browser.switchWindow("Alice"); await browser.url( - `/e2e/datachannel/serialization.html?testfile=${testFile}&serialization=${serialization}#Alice`, + `/e2e/datachannel/serialization.html?testfile=${testFile}&serialization=${serialization}&key=${BYPASS_WAF}#Alice`, ); await this.connectBtn.waitForEnabled(); await browser.switchWindow("Bob"); await browser.url( - `/e2e/datachannel/serialization.html?testfile=${testFile}#Bob`, + `/e2e/datachannel/serialization.html?testfile=${testFile}&key=${BYPASS_WAF}#Bob`, ); await this.connectBtn.waitForEnabled(); } diff --git a/e2e/mediachannel/close.js b/e2e/mediachannel/close.js index 8568028ac..7492fb707 100644 --- a/e2e/mediachannel/close.js +++ b/e2e/mediachannel/close.js @@ -3,6 +3,8 @@ */ const Peer = window.peerjs.Peer; +const params = new URLSearchParams(document.location.search); + document.getElementsByTagName("title")[0].innerText = window.location.hash.substring(1); @@ -14,7 +16,7 @@ const messages = document.getElementById("messages"); const errorMessage = document.getElementById("error-message"); const stream = window["sender-stream"].captureStream(30); -const peer = new Peer({ debug: 3 }); +const peer = new Peer({ debug: 3, key: params.get("key") }); /** * @type {import("peerjs").MediaConnection} */ diff --git a/e2e/mediachannel/close.page.ts b/e2e/mediachannel/close.page.ts index 30412ae15..1ade1672c 100644 --- a/e2e/mediachannel/close.page.ts +++ b/e2e/mediachannel/close.page.ts @@ -1,4 +1,7 @@ import { browser, $ } from "@wdio/globals"; + +const { BYPASS_WAF } = process.env; + class SerializationPage { get receiverId() { return $("input[id='receiver-id']"); @@ -35,11 +38,11 @@ class SerializationPage { async open() { await browser.switchWindow("Alice"); - await browser.url(`/e2e/mediachannel/close.html#Alice`); + await browser.url(`/e2e/mediachannel/close.html?key=${BYPASS_WAF}#Alice`); await this.callBtn.waitForEnabled(); await browser.switchWindow("Bob"); - await browser.url(`/e2e/mediachannel/close.html#Bob`); + await browser.url(`/e2e/mediachannel/close.html?key=${BYPASS_WAF}#Bob`); await this.callBtn.waitForEnabled(); } async init() { diff --git a/e2e/peer/disconnected.html b/e2e/peer/disconnected.html index 14b9c36ae..574d8d21c 100644 --- a/e2e/peer/disconnected.html +++ b/e2e/peer/disconnected.html @@ -17,9 +17,11 @@