summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/test_hpkp-invalid-headers.sjs
blob: cd0e18523b37f622135743832c49df1afa40b782 (plain)
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
44
45
46
47
48
49
50
51
52
53
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

function handleRequest(request, response)
{
  response.setHeader("Content-Type", "text/plain; charset=utf-8", false);

  let issue;
  switch (request.queryString) {
    case "badSyntax":
      response.setHeader("Public-Key-Pins", "\"");
      issue = "is not syntactically correct.";
      break;
    case "noMaxAge":
      response.setHeader("Public-Key-Pins", "max-age444");
      issue = "does not include a max-age directive.";
      break;
    case "invalidIncludeSubDomains":
      response.setHeader("Public-Key-Pins", "includeSubDomains=abc");
      issue = "includes an invalid includeSubDomains directive.";
      break;
    case "invalidMaxAge":
      response.setHeader("Public-Key-Pins", "max-age=abc");
      issue = "includes an invalid max-age directive.";
      break;
    case "multipleIncludeSubDomains":
      response.setHeader("Public-Key-Pins",
                         "includeSubDomains; includeSubDomains");
      issue = "includes multiple includeSubDomains directives.";
      break;
    case "multipleMaxAge":
      response.setHeader("Public-Key-Pins",
                         "max-age=444; max-age=999");
      issue = "includes multiple max-age directives.";
      break;
    case "multipleReportURIs":
      response.setHeader("Public-Key-Pins",
                         'report-uri="http://example.com"; ' +
                         'report-uri="http://example.com"');
      issue = "includes multiple report-uri directives.";
      break;
    case "pinsetDoesNotMatch":
      response.setHeader(
        "Public-Key-Pins",
        'max-age=999; ' +
        'pin-sha256="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; ' +
        'pin-sha256="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB="');
      issue = "does not include a matching pin.";
      break;
  }

  response.write("This page is served with a PKP header that " + issue);
}