tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

registration-no-challenge.https.html (1481B)


      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 { expireCookie, waitForCookie, addCookieAndSessionCleanup, configureServer, setupShardedServerState, documentHasCookie } 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 never send back a challenge.
     17    await configureServer({
     18      allowsChallenges: false
     19    });
     20 
     21    // Prompt starting a session, and wait until registration completes.
     22    const loginResponse = await fetch('login.py');
     23    assert_equals(loginResponse.status, 200);
     24    await waitForCookie(expectedCookieAndValue, /*expectCookie=*/true);
     25 
     26    // Confirm that expiring the cookie does refresh because registration succeeded.
     27    expireCookie(expectedCookieAndAttributes);
     28    assert_false(documentHasCookie(expectedCookieAndValue));
     29    const authResponseAfterExpiry = await fetch('verify_authenticated.py');
     30    assert_equals(authResponseAfterExpiry.status, 200);
     31    assert_true(documentHasCookie(expectedCookieAndValue));
     32  }, "Registration header doesn't need a challenge");
     33 </script>