Skip to content

Commit

Permalink
Bug 1148205 - Replace misnamed formSubmitURL and hostname propert…
Browse files Browse the repository at this point in the history
…ies on nsILoginInfo in services/sync/ r=markh,tcsc

Differential Revision: https://phabricator.services.mozilla.com/D33347

--HG--
extra : moz-landing-system : lando
  • Loading branch information
mnoorenberghe committed Jun 5, 2019
1 parent a74f1ce commit e7afdd4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions services/sync/modules/engines/passwords.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ PasswordEngine.prototype = {
return null;
}

let logins = Services.logins.findLogins(login.hostname, login.formSubmitURL, login.httpRealm);
let logins = Services.logins.findLogins(login.origin, login.formActionOrigin, login.httpRealm);

await Async.promiseYield(); // Yield back to main thread after synchronous operation.

// Look for existing logins that match the hostname, but ignore the password.
// Look for existing logins that match the origin, but ignore the password.
for (let local of logins) {
if (login.matches(local, true) && local instanceof Ci.nsILoginMetaInfo) {
return local.guid;
Expand Down Expand Up @@ -218,7 +218,7 @@ PasswordStore.prototype = {
for (let i = 0; i < logins.length; i++) {
// Skip over Weave password/passphrase entries.
let metaInfo = logins[i].QueryInterface(Ci.nsILoginMetaInfo);
if (Utils.getSyncCredentialsHosts().has(metaInfo.hostname)) {
if (Utils.getSyncCredentialsHosts().has(metaInfo.origin)) {
continue;
}

Expand Down Expand Up @@ -260,8 +260,8 @@ PasswordStore.prototype = {
return record;
}

record.hostname = login.hostname;
record.formSubmitURL = login.formSubmitURL;
record.hostname = login.origin;
record.formSubmitURL = login.formActionOrigin;
record.httpRealm = login.httpRealm;
record.username = login.username;
record.password = login.password;
Expand All @@ -284,7 +284,7 @@ PasswordStore.prototype = {

this._log.trace("Adding login for " + record.hostname);
this._log.trace("httpRealm: " + JSON.stringify(login.httpRealm) + "; " +
"formSubmitURL: " + JSON.stringify(login.formSubmitURL));
"formSubmitURL: " + JSON.stringify(login.formActionOrigin));
Services.logins.addLogin(login);
},

Expand Down Expand Up @@ -375,7 +375,7 @@ PasswordTracker.prototype = {
},

async _trackLogin(login) {
if (Utils.getSyncCredentialsHosts().has(login.hostname)) {
if (Utils.getSyncCredentialsHosts().has(login.origin)) {
// Skip over Weave password/passphrase changes.
return false;
}
Expand Down Expand Up @@ -405,7 +405,7 @@ class PasswordValidator extends CollectionValidator {
let logins = Services.logins.getAllLogins();
let syncHosts = Utils.getSyncCredentialsHosts();
let result = logins.map(l => l.QueryInterface(Ci.nsILoginMetaInfo))
.filter(l => !syncHosts.has(l.hostname));
.filter(l => !syncHosts.has(l.origin));
return Promise.resolve(result);
}

Expand Down
8 changes: 4 additions & 4 deletions services/sync/tests/unit/test_password_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ add_task(async function test_password_engine() {

// Insert a server record that's older, so that we prefer the local one.
let rec = new LoginRec("passwords", newLogin.guid);
rec.formSubmitURL = newLogin.formSubmitURL;
rec.formSubmitURL = newLogin.formActionOrigin;
rec.httpRealm = newLogin.httpRealm;
rec.hostname = newLogin.hostname;
rec.hostname = newLogin.origin;
rec.username = newLogin.username;
rec.password = "sekrit";
let remotePasswordChangeTime = Date.now() - 1 * 60 * 60 * 24 * 1000;
Expand Down Expand Up @@ -147,8 +147,8 @@ add_task(async function test_password_engine() {
equal(oldLogin.timePasswordChanged, localPasswordChangeTime);

let rec = new LoginRec("passwords", oldLogin.guid);
rec.hostname = oldLogin.hostname;
rec.formSubmitURL = oldLogin.formSubmitURL;
rec.hostname = oldLogin.origin;
rec.formSubmitURL = oldLogin.formActionOrigin;
rec.httpRealm = oldLogin.httpRealm;
rec.username = oldLogin.username;
// Change the password and bump the password change time to ensure we prefer
Expand Down
4 changes: 2 additions & 2 deletions services/sync/tests/unit/test_password_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ add_task(async function run_test() {
const BOGUS_GUID_B = "yyyyyyyyyyyy";
let recordA = {id: BOGUS_GUID_A,
hostname: "http://foo.bar.com",
formSubmitURL: "http://foo.bar.com/baz",
formSubmitURL: "http://foo.bar.com",
httpRealm: "secure",
username: "john",
password: "smith",
usernameField: "username",
passwordField: "password"};
let recordB = {id: BOGUS_GUID_B,
hostname: "http://foo.baz.com",
formSubmitURL: "http://foo.baz.com/baz",
formSubmitURL: "http://foo.baz.com",
username: "john",
password: "smith",
usernameField: "username",
Expand Down
2 changes: 1 addition & 1 deletion services/sync/tests/unit/test_password_tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ add_task(async function test_tracking() {
_("RECORD NUM: " + recordNum);
let record = {id: "GUID" + recordNum,
hostname: "http://foo.bar.com",
formSubmitURL: "http://foo.bar.com/baz",
formSubmitURL: "http://foo.bar.com",
username: "john" + recordNum,
password: "smith",
usernameField: "username",
Expand Down
12 changes: 6 additions & 6 deletions services/sync/tests/unit/test_password_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getDummyServerAndClient() {
id: "11111",
guid: "11111",
hostname: "https://www.11111.com",
formSubmitURL: "https://www.11111.com/login",
formSubmitURL: "https://www.11111.com",
password: "qwerty123",
passwordField: "pass",
username: "foobar",
Expand All @@ -21,7 +21,7 @@ function getDummyServerAndClient() {
id: "22222",
guid: "22222",
hostname: "https://www.22222.org",
formSubmitURL: "https://www.22222.org/login",
formSubmitURL: "https://www.22222.org",
password: "hunter2",
passwordField: "passwd",
username: "baz12345",
Expand All @@ -32,7 +32,7 @@ function getDummyServerAndClient() {
id: "33333",
guid: "33333",
hostname: "https://www.33333.com",
formSubmitURL: "https://www.33333.com/login",
formSubmitURL: "https://www.33333.com",
password: "p4ssw0rd",
passwordField: "passwad",
username: "quux",
Expand All @@ -45,7 +45,7 @@ function getDummyServerAndClient() {
id: "11111",
guid: "11111",
hostname: "https://www.11111.com",
formSubmitURL: "https://www.11111.com/login",
formSubmitURL: "https://www.11111.com",
password: "qwerty123",
passwordField: "pass",
username: "foobar",
Expand All @@ -56,7 +56,7 @@ function getDummyServerAndClient() {
id: "22222",
guid: "22222",
hostname: "https://www.22222.org",
formSubmitURL: "https://www.22222.org/login",
formSubmitURL: "https://www.22222.org",
password: "hunter2",
passwordField: "passwd",
username: "baz12345",
Expand All @@ -68,7 +68,7 @@ function getDummyServerAndClient() {
id: "33333",
guid: "33333",
hostname: "https://www.33333.com",
formSubmitURL: "https://www.33333.com/login",
formSubmitURL: "https://www.33333.com",
password: "p4ssw0rd",
passwordField: "passwad",
username: "quux",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var DumpPasswords = function TPS__Passwords__DumpPasswords() {
let logins = Services.logins.getAllLogins();
Logger.logInfo("\ndumping password list\n", true);
for (var i = 0; i < logins.length; i++) {
Logger.logInfo("* host=" + logins[i].hostname + ", submitURL=" + logins[i].formSubmitURL +
Logger.logInfo("* origin=" + logins[i].origin + ", formActionOrigin=" + logins[i].formActionOrigin +
", realm=" + logins[i].httpRealm + ", password=" + logins[i].password +
", passwordField=" + logins[i].passwordField + ", username=" +
logins[i].username + ", usernameField=" + logins[i].usernameField, true);
Expand Down

0 comments on commit e7afdd4

Please sign in to comment.