|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 Cu.import("resource://services-sync/constants.js"); |
|
5 Cu.import("resource://services-sync/status.js"); |
|
6 Cu.import("resource://services-sync/util.js"); |
|
7 Cu.import("resource://testing-common/services/sync/utils.js"); |
|
8 |
|
9 function run_test() { |
|
10 initTestLogging("Trace"); |
|
11 ensureLegacyIdentityManager(); |
|
12 |
|
13 try { |
|
14 _("Ensure fresh config."); |
|
15 Status._authManager.deleteSyncCredentials(); |
|
16 |
|
17 _("Fresh setup, we're not configured."); |
|
18 do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED); |
|
19 do_check_eq(Status.login, LOGIN_FAILED_NO_USERNAME); |
|
20 Status.resetSync(); |
|
21 |
|
22 _("Let's provide a username."); |
|
23 Status._authManager.username = "johndoe"; |
|
24 do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED); |
|
25 do_check_eq(Status.login, LOGIN_FAILED_NO_PASSWORD); |
|
26 Status.resetSync(); |
|
27 |
|
28 do_check_neq(Status._authManager.username, null); |
|
29 |
|
30 _("Let's provide a password."); |
|
31 Status._authManager.basicPassword = "carotsalad"; |
|
32 do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED); |
|
33 do_check_eq(Status.login, LOGIN_FAILED_NO_PASSPHRASE); |
|
34 Status.resetSync(); |
|
35 |
|
36 _("Let's provide a passphrase"); |
|
37 Status._authManager.syncKey = "a-bcdef-abcde-acbde-acbde-acbde"; |
|
38 _("checkSetup()"); |
|
39 do_check_eq(Status.checkSetup(), STATUS_OK); |
|
40 Status.resetSync(); |
|
41 |
|
42 } finally { |
|
43 Svc.Prefs.resetBranch(""); |
|
44 } |
|
45 } |