2010-08-25 15:49:45 -07:00
|
|
|
Cu.import("resource://services-sync/main.js");
|
2010-06-16 20:12:38 -07:00
|
|
|
Cu.import("resource://services-sync/constants.js");
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
try {
|
2010-11-29 16:41:17 -08:00
|
|
|
// Ensure we have a blank slate to start.
|
|
|
|
Weave.Svc.Login.removeAllLogins();
|
|
|
|
|
2010-06-16 20:12:38 -07:00
|
|
|
Weave.Service.username = "johndoe";
|
|
|
|
Weave.Service.password = "ilovejane";
|
2010-11-29 16:41:17 -08:00
|
|
|
Weave.Service.passphrase = "abbbbbcccccdddddeeeeefffff";
|
2010-06-16 20:12:38 -07:00
|
|
|
|
|
|
|
_("Confirm initial environment is empty.");
|
|
|
|
let logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null,
|
|
|
|
PWDMGR_PASSWORD_REALM);
|
|
|
|
do_check_eq(logins.length, 0);
|
|
|
|
logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null,
|
|
|
|
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.");
|
|
|
|
logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null,
|
|
|
|
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.");
|
|
|
|
logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null,
|
|
|
|
PWDMGR_PASSPHRASE_REALM);
|
|
|
|
do_check_eq(logins.length, 1);
|
|
|
|
do_check_eq(logins[0].username, "johndoe");
|
2010-11-29 16:41:17 -08:00
|
|
|
do_check_eq(logins[0].password, "abbbbbcccccdddddeeeeefffff");
|
2010-06-16 20:12:38 -07:00
|
|
|
|
|
|
|
} finally {
|
|
|
|
Weave.Svc.Prefs.resetBranch("");
|
|
|
|
Weave.Svc.Login.removeAllLogins();
|
|
|
|
}
|
|
|
|
}
|