summaryrefslogtreecommitdiff
path: root/services/sync/modules-testing/utils.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-19 02:25:38 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-19 02:25:38 +0200
commit51722cd4fecb5c8c79a302f2771cad71535df5ea (patch)
tree4771e6d114249bf48d1e843167bcf393de2b98a2 /services/sync/modules-testing/utils.js
parent3eb4310cd889e6c8d22c27f0326273acf0a3e8bf (diff)
parentde75f133a7ec654d2a7c5bf628b3aee9fc109730 (diff)
downloaduxp-51722cd4fecb5c8c79a302f2771cad71535df5ea.tar.gz
Merge branch 'Sync-weave'
Diffstat (limited to 'services/sync/modules-testing/utils.js')
-rw-r--r--services/sync/modules-testing/utils.js85
1 files changed, 3 insertions, 82 deletions
diff --git a/services/sync/modules-testing/utils.js b/services/sync/modules-testing/utils.js
index fc14f2fbd8..64c9b163d6 100644
--- a/services/sync/modules-testing/utils.js
+++ b/services/sync/modules-testing/utils.js
@@ -28,8 +28,6 @@ Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-sync/browserid_identity.js");
Cu.import("resource://testing-common/services/common/logging.js");
Cu.import("resource://testing-common/services/sync/fakeservices.js");
-Cu.import("resource://gre/modules/FxAccounts.jsm");
-Cu.import("resource://gre/modules/FxAccountsCommon.js");
Cu.import("resource://gre/modules/Promise.jsm");
/**
@@ -77,27 +75,8 @@ this.setBasicCredentials =
this.makeIdentityConfig = function(overrides) {
// first setup the defaults.
let result = {
- // Username used in both fxaccount and sync identity configs.
+ // Username used in sync identity config.
username: "foo",
- // fxaccount specific credentials.
- fxaccount: {
- user: {
- assertion: 'assertion',
- email: 'email',
- kA: 'kA',
- kB: 'kB',
- sessionToken: 'sessionToken',
- uid: 'user_uid',
- verified: true,
- },
- token: {
- endpoint: Svc.Prefs.get("tokenServerURI"),
- duration: 300,
- id: "id",
- key: "key",
- // uid will be set to the username.
- }
- },
sync: {
// username will come from the top-level username
password: "whatever",
@@ -114,64 +93,15 @@ this.makeIdentityConfig = function(overrides) {
// TODO: allow just some attributes to be specified
result.sync = overrides.sync;
}
- if (overrides.fxaccount) {
- // TODO: allow just some attributes to be specified
- result.fxaccount = overrides.fxaccount;
- }
}
return result;
}
-// Configure an instance of an FxAccount identity provider with the specified
-// config (or the default config if not specified).
-this.configureFxAccountIdentity = function(authService,
- config = makeIdentityConfig()) {
- let MockInternal = {};
- let fxa = new FxAccounts(MockInternal);
-
- // until we get better test infrastructure for bid_identity, we set the
- // signedin user's "email" to the username, simply as many tests rely on this.
- config.fxaccount.user.email = config.username;
- fxa.internal.currentAccountState.signedInUser = {
- version: DATA_FORMAT_VERSION,
- accountData: config.fxaccount.user
- };
- fxa.internal.currentAccountState.getCertificate = function(data, keyPair, mustBeValidUntil) {
- this.cert = {
- validUntil: fxa.internal.now() + CERT_LIFETIME,
- cert: "certificate",
- };
- return Promise.resolve(this.cert.cert);
- };
-
- let mockTSC = { // TokenServerClient
- getTokenFromBrowserIDAssertion: function(uri, assertion, cb) {
- config.fxaccount.token.uid = config.username;
- cb(null, config.fxaccount.token);
- },
- };
- authService._fxaService = fxa;
- authService._tokenServerClient = mockTSC;
- // Set the "account" of the browserId manager to be the "email" of the
- // logged in user of the mockFXA service.
- authService._signedInUser = fxa.internal.currentAccountState.signedInUser.accountData;
- authService._account = config.fxaccount.user.email;
-}
-
this.configureIdentity = function(identityOverrides) {
let config = makeIdentityConfig(identityOverrides);
let ns = {};
Cu.import("resource://services-sync/service.js", ns);
- if (ns.Service.identity instanceof BrowserIDManager) {
- // do the FxAccounts thang...
- configureFxAccountIdentity(ns.Service.identity, config);
- return ns.Service.identity.initializeWithCurrentIdentity().then(() => {
- // need to wait until this identity manager is readyToAuthenticate.
- return ns.Service.identity.whenReadyToAuthenticate.promise;
- });
- }
- // old style identity provider.
setBasicCredentials(config.username, config.sync.password, config.sync.syncKey);
let deferred = Promise.defer();
deferred.resolve();
@@ -184,7 +114,6 @@ this.SyncTestingInfrastructure = function (server, username, password, syncKey)
ensureLegacyIdentityManager();
let config = makeIdentityConfig();
- // XXX - hacks for the sync identity provider.
if (username)
config.username = username;
if (password)
@@ -223,10 +152,10 @@ this.encryptPayload = function encryptPayload(cleartext) {
};
}
-// This helper can be used instead of 'add_test' or 'add_task' to run the
+// This helper was used instead of 'add_test' or 'add_task' to run the
// specified test function twice - once with the old-style sync identity
// manager and once with the new-style BrowserID identity manager, to ensure
-// it works in both cases.
+// it worked in both cases. Currently it's equal to just one. XXX: cleanup?
//
// * The test itself should be passed as 'test' - ie, test code will generally
// pass |this|.
@@ -248,12 +177,4 @@ this.add_identity_test = function(test, testFunction) {
yield testFunction();
Status.__authManager = ns.Service.identity = oldIdentity;
});
- // another task for the FxAccounts identity manager.
- test.add_task(function() {
- note("FxAccounts");
- let oldIdentity = Status._authManager;
- Status.__authManager = ns.Service.identity = new BrowserIDManager();
- yield testFunction();
- Status.__authManager = ns.Service.identity = oldIdentity;
- });
}