services/sync/tests/unit/test_service_persistLogin.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:f71e428bcff3
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/service.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 try {
11 // Ensure we have a blank slate to start.
12 ensureLegacyIdentityManager();
13 Services.logins.removeAllLogins();
14
15 setBasicCredentials("johndoe", "ilovejane", "abbbbbcccccdddddeeeeefffff");
16
17 _("Confirm initial environment is empty.");
18 let logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
19 PWDMGR_PASSWORD_REALM);
20 do_check_eq(logins.length, 0);
21 logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
22 PWDMGR_PASSPHRASE_REALM);
23 do_check_eq(logins.length, 0);
24
25 _("Persist logins to the login service");
26 Service.persistLogin();
27
28 _("The password has been persisted in the login service.");
29 logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
30 PWDMGR_PASSWORD_REALM);
31 do_check_eq(logins.length, 1);
32 do_check_eq(logins[0].username, "johndoe");
33 do_check_eq(logins[0].password, "ilovejane");
34
35 _("The passphrase has been persisted in the login service.");
36 logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
37 PWDMGR_PASSPHRASE_REALM);
38 do_check_eq(logins.length, 1);
39 do_check_eq(logins[0].username, "johndoe");
40 do_check_eq(logins[0].password, "abbbbbcccccdddddeeeeefffff");
41
42 } finally {
43 Svc.Prefs.resetBranch("");
44 Services.logins.removeAllLogins();
45 }
46 }

mercurial