2010-08-25 22:49:45 +00:00
|
|
|
Cu.import("resource://services-sync/main.js");
|
2011-05-20 01:08:07 +00:00
|
|
|
Cu.import("resource://services-sync/util.js");
|
2010-06-17 03:12:38 +00:00
|
|
|
Cu.import("resource://services-sync/constants.js");
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
try {
|
2010-11-30 00:41:17 +00:00
|
|
|
// Ensure we have a blank slate to start.
|
2011-05-20 01:08:07 +00:00
|
|
|
Services.logins.removeAllLogins();
|
2012-03-22 22:49:50 +00:00
|
|
|
|
|
|
|
setBasicCredentials("johndoe", "ilovejane", "abbbbbcccccdddddeeeeefffff");
|
2010-06-17 03:12:38 +00:00
|
|
|
|
|
|
|
_("Confirm initial environment is empty.");
|
2011-05-20 01:08:07 +00:00
|
|
|
let logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
|
2010-06-17 03:12:38 +00:00
|
|
|
PWDMGR_PASSWORD_REALM);
|
|
|
|
do_check_eq(logins.length, 0);
|
2011-05-20 01:08:07 +00:00
|
|
|
logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
|
2010-06-17 03:12:38 +00:00
|
|
|
PWDMGR_PASSPHRASE_REALM);
|
|
|
|
do_check_eq(logins.length, 0);
|
|
|
|
|
|
|
|
_("Persist logins to the login service");
|
|
|
|
Weave.Service.persistLogin();
|
|
|
|
|
|
|
|
_("The password has been persisted in the login service.");
|
2011-05-20 01:08:07 +00:00
|
|
|
logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
|
2010-06-17 03:12:38 +00:00
|
|
|
PWDMGR_PASSWORD_REALM);
|
|
|
|
do_check_eq(logins.length, 1);
|
|
|
|
do_check_eq(logins[0].username, "johndoe");
|
|
|
|
do_check_eq(logins[0].password, "ilovejane");
|
|
|
|
|
|
|
|
_("The passphrase has been persisted in the login service.");
|
2011-05-20 01:08:07 +00:00
|
|
|
logins = Services.logins.findLogins({}, PWDMGR_HOST, null,
|
2010-06-17 03:12:38 +00:00
|
|
|
PWDMGR_PASSPHRASE_REALM);
|
|
|
|
do_check_eq(logins.length, 1);
|
|
|
|
do_check_eq(logins[0].username, "johndoe");
|
2010-11-30 00:41:17 +00:00
|
|
|
do_check_eq(logins[0].password, "abbbbbcccccdddddeeeeefffff");
|
2010-06-17 03:12:38 +00:00
|
|
|
|
|
|
|
} finally {
|
|
|
|
Weave.Svc.Prefs.resetBranch("");
|
2011-05-20 01:08:07 +00:00
|
|
|
Services.logins.removeAllLogins();
|
2010-06-17 03:12:38 +00:00
|
|
|
}
|
|
|
|
}
|