mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 982965 - ensure we fail if getKeys can't get kA or kB. r=ckarlof
This commit is contained in:
parent
015666895f
commit
daab8eed8b
@ -487,6 +487,12 @@ FxAccountsInternal.prototype = {
|
||||
if (!currentState.whenKeysReadyDeferred) {
|
||||
currentState.whenKeysReadyDeferred = Promise.defer();
|
||||
this.fetchAndUnwrapKeys(data.keyFetchToken).then(data => {
|
||||
if (!data.kA || !data.kB) {
|
||||
currentState.whenKeysReadyDeferred.reject(
|
||||
new Error("user data missing kA or kB")
|
||||
);
|
||||
return;
|
||||
}
|
||||
currentState.whenKeysReadyDeferred.resolve(data);
|
||||
});
|
||||
}
|
||||
|
@ -418,6 +418,52 @@ add_task(function test_getHAWKErrors() {
|
||||
Assert.equal(Status.login, LOGIN_FAILED_NETWORK_ERROR, "login state is LOGIN_FAILED_NETWORK_ERROR");
|
||||
});
|
||||
|
||||
add_task(function test_getKeysError() {
|
||||
_("BrowserIDManager correctly handles getKeys failures.");
|
||||
|
||||
let browseridManager = new BrowserIDManager();
|
||||
let identityConfig = makeIdentityConfig();
|
||||
// our mock identity config already has kA and kB - remove them or we never
|
||||
// try and fetch them.
|
||||
delete identityConfig.fxaccount.user.kA;
|
||||
delete identityConfig.fxaccount.user.kB;
|
||||
|
||||
configureFxAccountIdentity(browseridManager, identityConfig);
|
||||
|
||||
// Mock a fxAccounts object that returns no keys
|
||||
let fxa = new FxAccounts({
|
||||
fetchAndUnwrapKeys: function () {
|
||||
return Promise.resolve({});
|
||||
},
|
||||
fxAccountsClient: new MockFxAccountsClient()
|
||||
});
|
||||
|
||||
// Add a mock to the currentAccountState object.
|
||||
fxa.internal.currentAccountState.getCertificate = function(data, keyPair, mustBeValidUntil) {
|
||||
this.cert = {
|
||||
validUntil: fxa.internal.now() + CERT_LIFETIME,
|
||||
cert: "certificate",
|
||||
};
|
||||
return Promise.resolve(this.cert.cert);
|
||||
};
|
||||
|
||||
// Ensure the new FxAccounts mock has a signed-in user.
|
||||
fxa.internal.currentAccountState.signedInUser = browseridManager._fxaService.internal.currentAccountState.signedInUser;
|
||||
|
||||
browseridManager._fxaService = fxa;
|
||||
|
||||
yield browseridManager.initializeWithCurrentIdentity();
|
||||
|
||||
let ex;
|
||||
try {
|
||||
yield browseridManager.whenReadyToAuthenticate.promise;
|
||||
} catch (e) {
|
||||
ex = e;
|
||||
}
|
||||
|
||||
Assert.ok(ex.message.indexOf("missing kA or kB") >= 0);
|
||||
});
|
||||
|
||||
// End of tests
|
||||
// Utility functions follow
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user