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

Commit

Permalink
fix(test): Test login data is sent with email_verified messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Tomlinson committed Jun 14, 2017
1 parent a8142d4 commit e00f8da
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/scripts/models/auth_brokers/fx-sync-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ define(function (require, exports, module) {
* CAN_LINK_ACCOUNT: <specify in subclass>,
* CHANGE_PASSWORD: <specify in subclass>,
* DELETE_ACCOUNT: <specify in subclass>,
* EMAIL_VERIFIED: <specify in subclass>,
* LOADED: <specify in subclass>,
* LOGIN: <specify in subclass>
* }
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/models/auth_brokers/mob-android-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ define(function (require, exports, module) {
module.exports = FxSyncWebChannelAuthenticationBroker.extend({
defaultCapabilities: _.extend({}, proto.defaultCapabilities, {
chooseWhatToSyncCheckbox: false,
chooseWhatToSyncWebV1: false, // TODO - check this
// No CWTS - see https://github.com/mozilla/fxa-content-server/issues/5029#issuecomment-306928551
chooseWhatToSyncWebV1: false,
openWebmailButtonVisible: false,
sendAfterSignInConfirmationPollNotice: true,
sendAfterSignUpConfirmationPollNotice: true,
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/models/auth_brokers/mob-ios-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ define(function (require, exports, module) {
module.exports = FxSyncWebChannelAuthenticationBroker.extend({
defaultCapabilities: _.extend({}, proto.defaultCapabilities, {
chooseWhatToSyncCheckbox: false,
chooseWhatToSyncWebV1: false, // TODO - check this
// No CWTS - see https://github.com/mozilla/fxa-content-server/issues/5029#issuecomment-306928551
chooseWhatToSyncWebV1: false,
openWebmailButtonVisible: false,
sendAfterSignInConfirmationPollNotice: true,
sendAfterSignUpConfirmationPollNotice: true,
Expand Down
42 changes: 39 additions & 3 deletions app/tests/spec/models/auth_brokers/fx-sync-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,29 @@ define(function (require, exports, module) {
describe('browser supports `sendAfterSignInConfirmationPollNotice`', () => {
it('notifies the channel of login, does not halt the flow by default', () => {
broker.setCapability('sendAfterSignInConfirmationPollNotice', true);

account.set({
keyFetchToken: 'key_fetch_token',
sessionToken: 'session_token',
sessionTokenContext: 'sync',
uid: 'uid',
unwrapBKey: 'unwrap_b_key',
verified: true
});

return broker.afterSignInConfirmationPoll(account)
.then((result) => {
assert.ok(result);

assert.isTrue(channelMock.send.calledOnce);
assert.isTrue(channelMock.send.calledWith('email_verified'));
assert.ok(result);

const loginData = channelMock.send.args[0][1];
assert.equal(loginData.email, 'testuser@testuser.com');
assert.equal(loginData.sessionToken, 'session_token');
assert.equal(loginData.uid, 'uid');
assert.equal(loginData.unwrapBKey, 'unwrap_b_key');
assert.equal(loginData.verified, true);
});
});
});
Expand All @@ -294,20 +312,38 @@ define(function (require, exports, module) {
broker.setCapability('sendAfterSignUpConfirmationPollNotice', false);
return broker.afterSignUpConfirmationPoll(account)
.then((result) => {
assert.isFalse(channelMock.send.called);
assert.ok(result);
assert.isFalse(channelMock.send.called);
});
});
});

describe('browser supports `sendAfterSignUpConfirmationPollNotice`', () => {
it('notifies the channel of login, does not halt the flow by default', () => {
broker.setCapability('sendAfterSignUpConfirmationPollNotice', true);

account.set({
keyFetchToken: 'key_fetch_token',
sessionToken: 'session_token',
sessionTokenContext: 'sync',
uid: 'uid',
unwrapBKey: 'unwrap_b_key',
verified: true
});

return broker.afterSignUpConfirmationPoll(account)
.then((result) => {
assert.ok(result);

assert.isTrue(channelMock.send.calledOnce);
assert.isTrue(channelMock.send.calledWith('email_verified'));
assert.ok(result);

const loginData = channelMock.send.args[0][1];
assert.equal(loginData.email, 'testuser@testuser.com');
assert.equal(loginData.sessionToken, 'session_token');
assert.equal(loginData.uid, 'uid');
assert.equal(loginData.unwrapBKey, 'unwrap_b_key');
assert.equal(loginData.verified, true);
});
});
});
Expand Down

0 comments on commit e00f8da

Please sign in to comment.