requests-have-query-params.https.html (2056B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="helper.js" type="module"></script> 6 7 <script type="module"> 8 import { configureServer, expireCookie, documentHasCookie, waitForCookie, addCookieAndSessionCleanup, setupShardedServerState, postJson } from "./helper.js"; 9 10 promise_test(async t => { 11 await setupShardedServerState(); 12 const expectedCookieAndValue = "auth_cookie=abcdef0123"; 13 const expectedCookieAndAttributes = `${expectedCookieAndValue};Domain=${location.hostname};Path=/device-bound-session-credentials`; 14 addCookieAndSessionCleanup(t); 15 16 // Configure server to: 17 // 1. Check that registration has the query param specified below. 18 // 2. Set a refresh endpoint query param in the session instructions and 19 // verify that refresh has that query param. 20 await configureServer({ hasCustomQueryParam: true }); 21 22 // Prompt starting a session, and wait until registration completes. Pass 23 // through the query param to registration. 24 const registrationUrl = `start_session.py?registrationQueryParam=123`; 25 const loginResponse = await postJson('login.py', { registrationUrl }); 26 assert_equals(loginResponse.status, 200); 27 await waitForCookie(expectedCookieAndValue, /*expectCookie=*/true); 28 29 // Confirm that a request has the cookie set. 30 const authResponse = await fetch('verify_authenticated.py'); 31 assert_equals(authResponse.status, 200); 32 33 // Trigger refresh by expiring the cookie. 34 expireCookie(expectedCookieAndAttributes); 35 assert_false(documentHasCookie(expectedCookieAndValue)); 36 // The server refresh will fail if the refresh endpoint query param is not 37 // present during refresh. 38 const authResponseAfterExpiry = await fetch('verify_authenticated.py'); 39 assert_equals(authResponseAfterExpiry.status, 200); 40 assert_true(documentHasCookie(expectedCookieAndValue)); 41 }, "Registration and refresh endpoints can contain query params"); 42 </script>