зеркало из https://github.com/mozilla/gecko-dev.git
Bug 756366 - Preserve Sync credentials during client wipe; r=rnewman
This commit is contained in:
Родитель
d49d993f19
Коммит
2966d613ae
|
@ -333,8 +333,8 @@ IdentityManager.prototype = {
|
|||
* If the password store is locked (e.g. if the master password hasn't been
|
||||
* entered), this could throw an exception.
|
||||
*/
|
||||
persistCredentials: function persistCredentials() {
|
||||
if (this._basicPasswordUpdated) {
|
||||
persistCredentials: function persistCredentials(force) {
|
||||
if (this._basicPasswordUpdated || force) {
|
||||
if (this._basicPassword) {
|
||||
this._setLogin(PWDMGR_PASSWORD_REALM, this.username,
|
||||
this._basicPassword);
|
||||
|
@ -347,7 +347,7 @@ IdentityManager.prototype = {
|
|||
this._basicPasswordUpdated = false;
|
||||
}
|
||||
|
||||
if (this._syncKeyUpdated) {
|
||||
if (this._syncKeyUpdated || force) {
|
||||
if (this._syncKey) {
|
||||
this._setLogin(PWDMGR_PASSPHRASE_REALM, this.username, this._syncKey);
|
||||
} else {
|
||||
|
|
|
@ -862,7 +862,7 @@ WeaveSvc.prototype = {
|
|||
|
||||
persistLogin: function persistLogin() {
|
||||
try {
|
||||
this._identity.persistCredentials();
|
||||
this._identity.persistCredentials(true);
|
||||
} catch (ex) {
|
||||
this._log.info("Unable to persist credentials: " + ex);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Cu.import("resource://services-sync/identity.js");
|
||||
Cu.import("resource://services-sync/record.js");
|
||||
Cu.import("resource://services-sync/engines.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
|
@ -44,12 +48,12 @@ CannotDecryptEngine.prototype = {
|
|||
Engines.register(CannotDecryptEngine);
|
||||
|
||||
|
||||
function test_withEngineList() {
|
||||
add_test(function test_withEngineList() {
|
||||
try {
|
||||
_("Ensure initial scenario.");
|
||||
do_check_false(Engines.get("candecrypt").wasWiped);
|
||||
do_check_false(Engines.get("cannotdecrypt").wasWiped);
|
||||
|
||||
|
||||
_("Wipe local engine data.");
|
||||
Service.wipeClient(["candecrypt", "cannotdecrypt"]);
|
||||
|
||||
|
@ -61,16 +65,48 @@ function test_withEngineList() {
|
|||
Engines.get("cannotdecrypt").wasWiped = false;
|
||||
Service.startOver();
|
||||
}
|
||||
}
|
||||
|
||||
function test_startOver_clears_keys() {
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_startOver_clears_keys() {
|
||||
generateNewKeys();
|
||||
do_check_true(!!CollectionKeys.keyForCollection());
|
||||
Service.startOver();
|
||||
do_check_false(!!CollectionKeys.keyForCollection());
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_credentials_preserved() {
|
||||
_("Ensure that credentials are preserved if client is wiped.");
|
||||
|
||||
// Required for wipeClient().
|
||||
Service.clusterURL = TEST_CLUSTER_URL;
|
||||
|
||||
Identity.account = "testaccount";
|
||||
Identity.basicPassword = "testpassword";
|
||||
let key = Utils.generatePassphrase();
|
||||
Identity.syncKey = key;
|
||||
Identity.persistCredentials();
|
||||
|
||||
// Simulate passwords engine wipe without all the overhead. To do this
|
||||
// properly would require extra test infrastructure.
|
||||
Services.logins.removeAllLogins();
|
||||
Service.wipeClient();
|
||||
|
||||
let id = new IdentityManager();
|
||||
do_check_eq(id.account, "testaccount");
|
||||
do_check_eq(id.basicPassword, "testpassword");
|
||||
do_check_eq(id.syncKey, key);
|
||||
|
||||
Service.startOver();
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
test_withEngineList();
|
||||
test_startOver_clears_keys();
|
||||
initTestLogging();
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче