tor-browser

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

query.window.js (1692B)


      1 // META: script=helper.js
      2 
      3 // The following tests validate the behavior of the `@query` derived component.
      4 // They'll all be rooted in the following response, generated using the steps at
      5 // https://wicg.github.io/signature-based-sri/#examples, relying on the test
      6 // key from https://www.rfc-editor.org/rfc/rfc9421.html#name-example-ed25519-test-key:
      7 //
      8 // ```
      9 // NOTE: '\' line wrapping per RFC 8792
     10 //
     11 // HTTP/1.1 200 OK
     12 // Date: Tue, 20 Apr 2021 02:07:56 GMT
     13 // Content-Type: application/json
     14 // Unencoded-Digest: sha-256=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:
     15 // Content-Length: 18
     16 // Signature-Input: signature=("unencoded-digest";sf "@query";req); \
     17 //                  keyid="JrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs=";       \
     18 //                  tag="sri"
     19 // Signature: signature=[SEE NOTE BELOW]
     20 //
     21 // {"hello": "world"}
     22 // ```
     23 //
     24 // Unlike other tests in this directory, we cannot pass the signature into the resource,
     25 // as it would then be reflected via the signature base's inclusion of the query string.
     26 // Instead, `query-response.py` contains a hard-coded set of signatures for the test
     27 // cases below.
     28 
     29 
     30 let test_cases = [
     31  "", "test", "test=a", "test=%2F",  "test=ΓΌ"
     32 ];
     33 
     34 for (let query of test_cases) {
     35  generate_query_test(query, {}, EXPECT_LOADED,
     36                      `Query = "${query}": no integrity check: loads.`);
     37  generate_query_test(query, {integrity:`ed25519-${kValidKeys['rfc']}`}, EXPECT_LOADED,
     38                      `Query = "${query}": matching integrity check: loads.`);
     39  generate_query_test(query, {integrity:`ed25519-${kInvalidKey}`}, EXPECT_BLOCKED,
     40                      `Query = "${query}": mismatched integrity check: blocked.`);
     41 }