mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 966434 - Update TPS to use FxA. r=jgriffin
This commit is contained in:
parent
2c0f2038b4
commit
a91de5dd52
@ -775,20 +775,20 @@ Sync11Service.prototype = {
|
||||
|
||||
info = info.obj;
|
||||
if (!(CRYPTO_COLLECTION in info)) {
|
||||
this._log.error("Consistency failure: info/collections excludes " +
|
||||
this._log.error("Consistency failure: info/collections excludes " +
|
||||
"crypto after successful upload.");
|
||||
throw new Error("Symmetric key upload failed.");
|
||||
}
|
||||
|
||||
// Can't check against local modified: clock drift.
|
||||
if (info[CRYPTO_COLLECTION] < serverModified) {
|
||||
this._log.error("Consistency failure: info/collections crypto entry " +
|
||||
this._log.error("Consistency failure: info/collections crypto entry " +
|
||||
"is stale after successful upload.");
|
||||
throw new Error("Symmetric key upload failed.");
|
||||
}
|
||||
|
||||
|
||||
// Doesn't matter if the timestamp is ahead.
|
||||
|
||||
|
||||
// Download and install them.
|
||||
let cryptoKeys = new CryptoWrapper(CRYPTO_COLLECTION, KEYS_WBO);
|
||||
let cryptoResp = cryptoKeys.fetch(this.resource(this.cryptoKeysURL)).response;
|
||||
|
57
services/sync/tps/extensions/tps/modules/fxaccounts.jsm
Normal file
57
services/sync/tps/extensions/tps/modules/fxaccounts.jsm
Normal file
@ -0,0 +1,57 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
"FxAccountsHelper",
|
||||
];
|
||||
|
||||
const { utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/FxAccountsClient.jsm");
|
||||
Cu.import("resource://services-common/async.js");
|
||||
Cu.import("resource://services-sync/main.js");
|
||||
Cu.import("resource://tps/logger.jsm");
|
||||
|
||||
|
||||
/**
|
||||
* Helper object for Firefox Accounts authentication
|
||||
*/
|
||||
var FxAccountsHelper = {
|
||||
|
||||
/**
|
||||
* Wrapper to synchronize the login of a user
|
||||
*
|
||||
* @param email
|
||||
* The email address for the account (utf8)
|
||||
* @param password
|
||||
* The user's password
|
||||
*/
|
||||
signIn: function signIn(email, password) {
|
||||
let cb = Async.makeSpinningCallback();
|
||||
|
||||
var client = new FxAccountsClient();
|
||||
client.signIn(email, password).then(credentials => {
|
||||
// Add keys because without those setSignedInUser() will fail
|
||||
credentials.kA = 'foo';
|
||||
credentials.kB = 'bar';
|
||||
|
||||
Weave.Service.identity._fxaService.setSignedInUser(credentials).then(() => {
|
||||
cb(null);
|
||||
}, err => {
|
||||
cb(err);
|
||||
});
|
||||
}, (err) => {
|
||||
cb(err);
|
||||
});
|
||||
|
||||
try {
|
||||
cb.wait();
|
||||
} catch (err) {
|
||||
Logger.logError("signIn() failed with: " + JSON.stringify(err));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
@ -69,6 +69,7 @@ var TPS = {
|
||||
}
|
||||
}
|
||||
catch(e) {}
|
||||
|
||||
Weave.Service.identity.account = prefs.getCharPref('tps.account.username');
|
||||
Weave.Service.Identity.basicPassword = prefs.getCharPref('tps.account.password');
|
||||
Weave.Service.identity.syncKey = prefs.getCharPref('tps.account.passphrase');
|
||||
|
@ -23,6 +23,7 @@ CU.import("resource://tps/logger.jsm");
|
||||
CU.import("resource://tps/passwords.jsm");
|
||||
CU.import("resource://tps/history.jsm");
|
||||
CU.import("resource://tps/forms.jsm");
|
||||
CU.import("resource://tps/fxaccounts.jsm");
|
||||
CU.import("resource://tps/prefs.jsm");
|
||||
CU.import("resource://tps/tabs.jsm");
|
||||
CU.import("resource://tps/windows.jsm");
|
||||
@ -57,8 +58,11 @@ const SYNC_WIPE_SERVER = "wipe-server";
|
||||
const SYNC_RESET_CLIENT = "reset-client";
|
||||
const SYNC_START_OVER = "start-over";
|
||||
|
||||
const OBSERVER_TOPICS = ["weave:engine:start-tracking",
|
||||
const OBSERVER_TOPICS = ["fxaccounts:onlogin",
|
||||
"fxaccounts:onlogout",
|
||||
"weave:engine:start-tracking",
|
||||
"weave:engine:stop-tracking",
|
||||
"weave:service:setup-complete",
|
||||
"weave:service:sync:finish",
|
||||
"weave:service:sync:error",
|
||||
"sessionstore-windows-restored",
|
||||
@ -71,6 +75,7 @@ let TPS = {
|
||||
_currentAction: -1,
|
||||
_currentPhase: -1,
|
||||
_errors: 0,
|
||||
_setupComplete: false,
|
||||
_syncErrors: 0,
|
||||
_usSinceEpoch: 0,
|
||||
_tabsAdded: 0,
|
||||
@ -96,6 +101,15 @@ let TPS = {
|
||||
case "private-browsing":
|
||||
Logger.logInfo("private browsing " + data);
|
||||
break;
|
||||
|
||||
case "fxaccounts:onlogin":
|
||||
this._loggedIn = true;
|
||||
break;
|
||||
|
||||
case "fxaccounts:onlogout":
|
||||
this._loggedIn = false;
|
||||
break;
|
||||
|
||||
case "weave:service:sync:error":
|
||||
if (this._waitingForSync && this._syncErrors == 0) {
|
||||
// if this is the first sync error, retry...
|
||||
@ -111,6 +125,10 @@ let TPS = {
|
||||
}
|
||||
break;
|
||||
|
||||
case "weave:service:setup-complete":
|
||||
this._setupComplete = true;
|
||||
break;
|
||||
|
||||
case "weave:service:sync:finish":
|
||||
if (this._waitingForSync) {
|
||||
this._syncErrors = 0;
|
||||
@ -611,13 +629,13 @@ let TPS = {
|
||||
|
||||
// Store account details as prefs so they're accessible to the mozmill
|
||||
// framework.
|
||||
prefs.setCharPref('tps.account.username', this.config.account.username);
|
||||
prefs.setCharPref('tps.account.password', this.config.account.password);
|
||||
prefs.setCharPref('tps.account.passphrase', this.config.account.passphrase);
|
||||
if (this.config.account['serverURL']) {
|
||||
prefs.setCharPref('tps.account.serverURL', this.config.account.serverURL);
|
||||
prefs.setCharPref('tps.account.username', this.config.fx_account.username);
|
||||
prefs.setCharPref('tps.account.password', this.config.fx_account.password);
|
||||
// old sync
|
||||
// prefs.setCharPref('tps.account.passphrase', this.config.fx_account.passphrase);
|
||||
if (this.config["serverURL"]) {
|
||||
prefs.setCharPref('tps.account.serverURL', this.config.serverURL);
|
||||
}
|
||||
|
||||
// start processing the test actions
|
||||
this._currentAction = 0;
|
||||
}
|
||||
@ -704,6 +722,33 @@ let TPS = {
|
||||
cb.wait();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Waits for Sync to logged in before returning
|
||||
*/
|
||||
waitForLoggedIn: function waitForLoggedIn() {
|
||||
if (!this._loggedIn) {
|
||||
this.waitForEvent("fxaccount:onlogin");
|
||||
}
|
||||
|
||||
let cb = Async.makeSyncCallback();
|
||||
Utils.nextTick(cb);
|
||||
Async.waitForSyncCallback(cb);
|
||||
},
|
||||
|
||||
/**
|
||||
* Waits for Sync to logged in before returning
|
||||
*/
|
||||
waitForSetupComplete: function waitForSetup() {
|
||||
if (!this._setupComplete) {
|
||||
this.waitForEvent("weave:service:setup-complete");
|
||||
}
|
||||
|
||||
let cb = Async.makeSyncCallback();
|
||||
Utils.nextTick(cb);
|
||||
Async.waitForSyncCallback(cb);
|
||||
},
|
||||
|
||||
/**
|
||||
* Waits for Sync to start tracking before returning.
|
||||
*/
|
||||
@ -746,44 +791,37 @@ let TPS = {
|
||||
return;
|
||||
}
|
||||
|
||||
let account = this.config.account;
|
||||
// old sync: have to add handling for this.config.sync_account
|
||||
let account = this.config.fx_account;
|
||||
|
||||
if (!account) {
|
||||
this.DumperError("No account information found! Did you use a valid " +
|
||||
"config file?");
|
||||
return;
|
||||
}
|
||||
|
||||
if (account["serverURL"]) {
|
||||
Weave.Service.serverURL = account["serverURL"];
|
||||
if (this.config["serverURL"]) {
|
||||
Weave.Service.serverURL = this.config.serverURL;
|
||||
}
|
||||
|
||||
Logger.logInfo("Setting client credentials.");
|
||||
if (account["admin-secret"]) {
|
||||
// if admin-secret is specified, we'll dynamically create
|
||||
// a new sync account
|
||||
Weave.Svc.Prefs.set("admin-secret", account["admin-secret"]);
|
||||
let suffix = account["account-suffix"];
|
||||
Weave.Service.identity.account = "tps" + suffix + "@mozilla.com";
|
||||
Weave.Service.identity.basicPassword = "tps" + suffix + "tps" + suffix;
|
||||
Weave.Service.identity.syncKey = Weave.Utils.generatePassphrase();
|
||||
Weave.Service.createAccount(Weave.Service.identity.account,
|
||||
Weave.Service.identity.basicPassword,
|
||||
"dummy1", "dummy2");
|
||||
} else if (account["username"] && account["password"] &&
|
||||
account["passphrase"]) {
|
||||
Weave.Service.identity.account = account["username"];
|
||||
Weave.Service.identity.basicPassword = account["password"];
|
||||
Weave.Service.identity.syncKey = account["passphrase"];
|
||||
if (account["username"] && account["password"]) { // && account["passphrase"]) {
|
||||
FxAccountsHelper.signIn(account["username"], account["password"]);
|
||||
this.waitForSetupComplete();
|
||||
|
||||
// Old sync code - has to be reactivated later for fallback
|
||||
//Weave.Service.identity.account = account["username"];
|
||||
//Weave.Service.identity.basicPassword = account["password"];
|
||||
//Weave.Service.identity.syncKey = account["passphrase"];
|
||||
} else {
|
||||
this.DumpError("Must specify admin-secret, or " +
|
||||
"username/password/passphrase in the config file");
|
||||
this.DumpError("Must specify username/password in the config file");
|
||||
return;
|
||||
}
|
||||
|
||||
Weave.Service.login();
|
||||
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status not OK");
|
||||
Weave.Svc.Obs.notify("weave:service:setup-complete");
|
||||
this._loggedIn = true;
|
||||
//Weave.Service.login();
|
||||
//this._loggedIn = true;
|
||||
//Weave.Svc.Obs.notify("weave:service:setup-complete");
|
||||
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK");
|
||||
|
||||
this.waitForTracking();
|
||||
},
|
||||
|
@ -1,25 +1,23 @@
|
||||
{
|
||||
"account": {
|
||||
"serverURL": "",
|
||||
"admin-secret": "",
|
||||
"username": "crossweaveservices@mozilla.com",
|
||||
"password": "crossweaveservicescrossweaveservices",
|
||||
"passphrase": "r-jwcbc-zgf42-fjn72-p5vpp-iypmi"
|
||||
},
|
||||
"resultstore": {
|
||||
"host": "brasstacks.mozilla.com",
|
||||
"path": "/resultserv/post/"
|
||||
},
|
||||
"email": {
|
||||
"username": "crossweave@mozilla.com",
|
||||
"password": "",
|
||||
"passednotificationlist": ["crossweave@mozilla.com"],
|
||||
"notificationlist": ["crossweave@mozilla.com"]
|
||||
},
|
||||
"platform": "win32",
|
||||
"os": "win7",
|
||||
"es": "localhost:9200",
|
||||
"testdir": "__TESTDIR__",
|
||||
"extensiondir": "__EXTENSIONDIR__"
|
||||
}
|
||||
|
||||
{
|
||||
"sync_account": {
|
||||
"username": "crossweaveservices@mozilla.com",
|
||||
"password": "crossweaveservicescrossweaveservices",
|
||||
"passphrase": "r-jwcbc-zgf42-fjn72-p5vpp-iypmi"
|
||||
},
|
||||
"fx_account": {
|
||||
"username": "crossweaveservices@restmail.net",
|
||||
"password": "crossweaveservicescrossweaveservices"
|
||||
},
|
||||
"email": {
|
||||
"username": "crossweave@mozilla.com",
|
||||
"password": "",
|
||||
"passednotificationlist": ["crossweave@mozilla.com"],
|
||||
"notificationlist": ["crossweave@mozilla.com"]
|
||||
},
|
||||
"platform": "win32",
|
||||
"os": "win7",
|
||||
"es": "localhost:9200",
|
||||
"serverURL": null,
|
||||
"testdir": "__TESTDIR__",
|
||||
"extensiondir": "__EXTENSIONDIR__"
|
||||
}
|
||||
|
@ -171,9 +171,9 @@ class TPSTestRunner(object):
|
||||
|
||||
# Create a random account suffix that is used when creating test
|
||||
# accounts on a staging server.
|
||||
account_suffix = {"account-suffix": ''.join([str(random.randint(0,9))
|
||||
for i in range(1,6)])}
|
||||
self.config['account'].update(account_suffix)
|
||||
#account_suffix = {"account-suffix": ''.join([str(random.randint(0,9))
|
||||
# for i in range(1,6)])}
|
||||
#self.config['sync_account'].update(account_suffix)
|
||||
|
||||
# Read and parse the test file, merge it with the contents of the config
|
||||
# file, and write the combined output to a temporary file.
|
||||
|
Loading…
Reference in New Issue
Block a user