PageRenderTime 25ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/services/sync/tests/unit/test_status_checkSetup.js

http://github.com/zpao/v8monkey
JavaScript | 45 lines | 37 code | 8 blank | 0 comment | 0 complexity | e9691afd1d2237d23edc6e6d9d7e7324 MD5 | raw file
 1Cu.import("resource://services-sync/constants.js");
 2Cu.import("resource://services-sync/identity.js");
 3Cu.import("resource://services-sync/status.js");
 4Cu.import("resource://services-sync/util.js");
 5
 6function run_test() {
 7  try {
 8    _("Verify initial setup.");
 9    do_check_eq(ID.get("WeaveID"), null);
10    do_check_eq(ID.get("WeaveCryptoID"), null);
11
12    _("Fresh setup, we're not configured.");
13    do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
14    do_check_eq(Status.login, LOGIN_FAILED_NO_USERNAME);
15    Status.resetSync();
16
17    _("Let's provide a username.");
18    Svc.Prefs.set("username", "johndoe");
19    do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
20    do_check_eq(Status.login, LOGIN_FAILED_NO_PASSWORD);
21    Status.resetSync();
22
23    _("checkSetup() created a WeaveID identity.");
24    let id = ID.get("WeaveID");
25    do_check_true(!!id);
26
27    _("Let's provide a password.");
28    id.password = "carotsalad";
29    do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
30    do_check_eq(Status.login, LOGIN_FAILED_NO_PASSPHRASE);
31    Status.resetSync();
32
33    _("checkSetup() created a WeaveCryptoID identity");
34    id = ID.get("WeaveCryptoID");
35    do_check_true(!!id);
36
37    _("Let's provide a passphrase");
38    id.keyStr = "a-bcdef-abcde-acbde-acbde-acbde";
39    do_check_eq(Status.checkSetup(), STATUS_OK);
40    Status.resetSync();
41
42  } finally {
43    Svc.Prefs.resetBranch("");
44  }
45}