summaryrefslogtreecommitdiffstats
path: root/security/manager/ssl/tests/unit/test_client_auth_remember_service_read.js
blob: 6238b1dfda9b9f17aa3faa33d249a7c7b3fb57da (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
54
55
56
57
58
59
60
61
62
63
64
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

// This tests that the nsIClientAuthRememberService correctly reads its backing
// state file.

function run_test() {
  let profile = do_get_profile();
  let clientAuthRememberFile = do_get_file(
    `test_client_auth_remember_service/${CLIENT_AUTH_FILE_NAME}`
  );
  clientAuthRememberFile.copyTo(profile, CLIENT_AUTH_FILE_NAME);

  let clientAuthRememberService = Cc[
    "@mozilla.org/security/clientAuthRememberService;1"
  ].getService(Ci.nsIClientAuthRememberService);

  let dbKey = {};
  ok(
    clientAuthRememberService.hasRememberedDecisionScriptable(
      "example.com",
      {},
      dbKey
    )
  );
  equal(dbKey.value, "AAAA");

  dbKey = {};
  ok(
    clientAuthRememberService.hasRememberedDecisionScriptable(
      "example.com",
      { partitionKey: "(https,example.com)" },
      dbKey
    )
  );
  equal(dbKey.value, "BBBB");

  ok(
    !clientAuthRememberService.hasRememberedDecisionScriptable(
      "example.org",
      {},
      {}
    )
  );
  ok(
    !clientAuthRememberService.hasRememberedDecisionScriptable(
      "example.com",
      { partitionKey: "(https,example.org)" },
      {}
    )
  );

  dbKey = {};
  ok(
    clientAuthRememberService.hasRememberedDecisionScriptable(
      "example.test",
      {},
      dbKey
    )
  );
  equal(dbKey.value, "CCCC");
}