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
|
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="helper.js" type="module"></script>
<script type="module">
import { configureServer, expireCookie, documentHasCookie, waitForCookie, addCookieAndSessionCleanup, setupShardedServerState, postJson } from "./helper.js";
promise_test(async t => {
await setupShardedServerState();
const expectedCookieAndValue = "auth_cookie=abcdef0123";
const expectedCookieAndAttributes = `${expectedCookieAndValue};Domain=${location.hostname};Path=/device-bound-session-credentials`;
addCookieAndSessionCleanup(t);
// Configure server to:
// 1. Check that registration has the query param specified below.
// 2. Set a refresh endpoint query param in the session instructions and
// verify that refresh has that query param.
await configureServer({ hasCustomQueryParam: true });
// Prompt starting a session, and wait until registration completes. Pass
// through the query param to registration.
const registrationUrl = `start_session.py?registrationQueryParam=123`;
const loginResponse = await postJson('login.py', { registrationUrl });
assert_equals(loginResponse.status, 200);
await waitForCookie(expectedCookieAndValue, /*expectCookie=*/true);
// Confirm that a request has the cookie set.
const authResponse = await fetch('verify_authenticated.py');
assert_equals(authResponse.status, 200);
// Trigger refresh by expiring the cookie.
expireCookie(expectedCookieAndAttributes);
assert_false(documentHasCookie(expectedCookieAndValue));
// The server refresh will fail if the refresh endpoint query param is not
// present during refresh.
const authResponseAfterExpiry = await fetch('verify_authenticated.py');
assert_equals(authResponseAfterExpiry.status, 200);
assert_true(documentHasCookie(expectedCookieAndValue));
}, "Registration and refresh endpoints can contain query params");
</script>
|