mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
Remove various FxA tests
This commit is contained in:
parent
1b9b6e7e75
commit
ccf32a6b79
14 changed files with 7 additions and 1522 deletions
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue