summaryrefslogtreecommitdiffstats
path: root/services/sync/modules-testing/utils.js
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2019-04-18 15:49:19 +0000
committerMoonchild <moonchild@palemoon.org>2019-04-18 15:49:19 +0000
commitcdc962dca59f2d68b82bec99beb5d67ae163f24a (patch)
tree4ebeba312f6c5c09e27da7e7e2408c985065dcd5 /services/sync/modules-testing/utils.js
parent8a68832519ec37cc14f14367b83bfee34c88cde2 (diff)
downloadUXP-cdc962dca59f2d68b82bec99beb5d67ae163f24a.tar
UXP-cdc962dca59f2d68b82bec99beb5d67ae163f24a.tar.gz
UXP-cdc962dca59f2d68b82bec99beb5d67ae163f24a.tar.lz
UXP-cdc962dca59f2d68b82bec99beb5d67ae163f24a.tar.xz
UXP-cdc962dca59f2d68b82bec99beb5d67ae163f24a.zip
Remove various FxA tests
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 fc14f2fbd..64c9b163d 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;
- });
}