Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(totp): call proto afterCompleteSignInWithCode after entering va…
Browse files Browse the repository at this point in the history
…lid totp code
  • Loading branch information
vbudhram committed Oct 15, 2018
1 parent cb7be4f commit f8c5a32
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
10 changes: 9 additions & 1 deletion app/scripts/models/auth_brokers/fx-ios-v1.js
Expand Up @@ -83,8 +83,16 @@ define(function (require, exports, module) {
return proto._notifyRelierOfLogin.call(this, account);
},

/**
* Notify the relier that a sign-in with a code was performed.
*
* @param {Object} account
* @returns {Promise}
* @private
*/
afterCompleteSignInWithCode (account) {
return this._notifyRelierOfLogin(account);
return this._notifyRelierOfLogin(account)
.then(() => proto.afterCompleteSignInWithCode.call(this, account));
},
});

Expand Down
33 changes: 29 additions & 4 deletions app/tests/spec/models/auth_brokers/fx-ios-v1.js
Expand Up @@ -8,6 +8,7 @@ define(function (require, exports, module) {
const Account = require('models/account');
const { assert } = require('chai');
const FxiOSAuthenticationBroker = require('models/auth_brokers/fx-ios-v1');
const FxDesktopV1AuthenticationBroker = require('models/auth_brokers/fx-desktop-v1');
const NullChannel = require('lib/channels/null');
const Relier = require('models/reliers/relier');
const sinon = require('sinon');
Expand All @@ -22,6 +23,7 @@ define(function (require, exports, module) {
const loginMessageDelayMS = 250;
let relier;
let windowMock;
let sandbox;

function initializeBroker(userAgent) {
windowMock.navigator.userAgent = userAgent;
Expand All @@ -31,16 +33,21 @@ define(function (require, exports, module) {
relier: relier,
window: windowMock
});
sinon.stub(broker, '_hasRequiredLoginFields').callsFake(() => true);
sandbox.stub(broker, '_hasRequiredLoginFields').callsFake(() => true);
}

beforeEach(() => {
channel = new NullChannel();
relier = new Relier();
windowMock = new WindowMock();
sandbox = sinon.sandbox.create();
initializeBroker(IMMEDIATE_UNVERIFIED_LOGIN_UA_STRING);
});

afterEach(() => {
sandbox.restore();
});

describe('capabilities', () => {
describe('supports chooseWhatToSyncWebV1', () => {
it('has the expected capabilities and behaviors', () => {
Expand Down Expand Up @@ -76,9 +83,9 @@ define(function (require, exports, module) {
let account;

beforeEach(() => {
sinon.stub(broker, 'send').callsFake(() => Promise.resolve());
sinon.spy(windowMock, 'setTimeout');
sinon.spy(windowMock, 'clearTimeout');
sandbox.stub(broker, 'send').callsFake(() => Promise.resolve());
sandbox.spy(windowMock, 'setTimeout');
sandbox.spy(windowMock, 'clearTimeout');
account = new Account({
uid: 'uid'
});
Expand Down Expand Up @@ -118,6 +125,24 @@ define(function (require, exports, module) {
});
});

describe('afterCompleteSignInWithCode', () => {
let account;

beforeEach(() => {
sandbox.spy(broker, 'afterCompleteSignInWithCode');
sandbox.spy(broker, '_notifyRelierOfLogin');
sandbox.spy(FxDesktopV1AuthenticationBroker.prototype, 'afterCompleteSignInWithCode');
account = new Account({
uid: 'uid'
});
return broker.afterCompleteSignInWithCode(account);
});

it('broker calls correct methods', () => {
assert.isTrue(FxDesktopV1AuthenticationBroker.prototype.afterCompleteSignInWithCode.called);
assert.isTrue(broker._notifyRelierOfLogin.called);
});
});
});
});
});

0 comments on commit f8c5a32

Please sign in to comment.