1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/services/sync/tests/unit/test_service_persistLogin.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +Cu.import("resource://services-sync/constants.js"); 1.8 +Cu.import("resource://services-sync/service.js"); 1.9 +Cu.import("resource://services-sync/util.js"); 1.10 +Cu.import("resource://testing-common/services/sync/utils.js"); 1.11 + 1.12 +function run_test() { 1.13 + try { 1.14 + // Ensure we have a blank slate to start. 1.15 + ensureLegacyIdentityManager(); 1.16 + Services.logins.removeAllLogins(); 1.17 + 1.18 + setBasicCredentials("johndoe", "ilovejane", "abbbbbcccccdddddeeeeefffff"); 1.19 + 1.20 + _("Confirm initial environment is empty."); 1.21 + let logins = Services.logins.findLogins({}, PWDMGR_HOST, null, 1.22 + PWDMGR_PASSWORD_REALM); 1.23 + do_check_eq(logins.length, 0); 1.24 + logins = Services.logins.findLogins({}, PWDMGR_HOST, null, 1.25 + PWDMGR_PASSPHRASE_REALM); 1.26 + do_check_eq(logins.length, 0); 1.27 + 1.28 + _("Persist logins to the login service"); 1.29 + Service.persistLogin(); 1.30 + 1.31 + _("The password has been persisted in the login service."); 1.32 + logins = Services.logins.findLogins({}, PWDMGR_HOST, null, 1.33 + PWDMGR_PASSWORD_REALM); 1.34 + do_check_eq(logins.length, 1); 1.35 + do_check_eq(logins[0].username, "johndoe"); 1.36 + do_check_eq(logins[0].password, "ilovejane"); 1.37 + 1.38 + _("The passphrase has been persisted in the login service."); 1.39 + logins = Services.logins.findLogins({}, PWDMGR_HOST, null, 1.40 + PWDMGR_PASSPHRASE_REALM); 1.41 + do_check_eq(logins.length, 1); 1.42 + do_check_eq(logins[0].username, "johndoe"); 1.43 + do_check_eq(logins[0].password, "abbbbbcccccdddddeeeeefffff"); 1.44 + 1.45 + } finally { 1.46 + Svc.Prefs.resetBranch(""); 1.47 + Services.logins.removeAllLogins(); 1.48 + } 1.49 +}