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

Commit

Permalink
fix(tests): remove account devices, add unlock verify code
Browse files Browse the repository at this point in the history
Fixes #151
  • Loading branch information
vladikoff committed May 19, 2015
1 parent dff42d0 commit 13c1b83
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 89 deletions.
18 changes: 0 additions & 18 deletions client/FxAccountClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,24 +494,6 @@ define([
});
};

/**
* Gets the collection of devices currently authenticated and syncing for the user.
*
* @method accountDevices
* @param {String} sessionToken User session token
* @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request
*/
FxAccountClient.prototype.accountDevices = function(sessionToken) {
var self = this;

required(sessionToken, 'sessionToken');

return hawkCredentials(sessionToken, 'sessionToken', 2 * 32)
.then(function(creds) {
return self.request.send('/account/devices', 'GET', creds);
});
};

/**
* This deletes the account completely. All stored data is erased.
*
Expand Down
1 change: 0 additions & 1 deletion tests/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ define([
'tests/lib/credentials',
'tests/lib/hawkCredentials',
'tests/lib/passwordChange',
'tests/lib/devices',
'tests/lib/session',
'tests/lib/certificateSign',
'tests/lib/account',
Expand Down
60 changes: 40 additions & 20 deletions tests/lib/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,13 @@ define([
});

test('#accountLock', function () {
var account;

return accountHelper.newVerifiedAccount()
.then(
function (acc) {
account = acc;
.then(function (acc) {
account = acc;

return respond(client.accountLock(account.input.email, account.input.password), RequestMocks.accountLock);
return respond(client.accountLock(account.input.email, account.input.password), RequestMocks.accountLock);
})
.then(
function (result) {
Expand All @@ -354,23 +355,21 @@ define([
});

test('#accountUnlockResendCode', function () {
var account;
var opts = {
service: 'sync',
redirectTo: 'https://sync.firefox.com/after_account_unlocked',
resume: 'resumejwt'
};

return accountHelper.newVerifiedAccount()
.then(
function (acc) {
account = acc;
.then(function (acc) {
account = acc;

return respond(client.accountLock(account.input.email, account.input.password), RequestMocks.accountLock);
return respond(client.accountLock(account.input.email, account.input.password), RequestMocks.accountLock);
})
.then(
function (result) {

return respond(client.accountUnlockResendCode(account.input.email, opts), RequestMocks.accountUnlockResendCode)
.then(function () {
return respond(client.accountUnlockResendCode(account.input.email, opts), RequestMocks.accountUnlockResendCode)
})
.then(
function (result) {
Expand All @@ -390,14 +389,35 @@ define([


test('#accountUnlockVerifyCode', function () {
return respond(client.accountUnlockVerifyCode('uid', 'code'), RequestMocks.accountUnlockVerifyCode)
.then(function (result) {
// result is an empty object
assert.ok(result);
assert.equal(Object.keys(result).length, 0);
},
assert.notOk
);
var account;
var opts = {
service: 'sync',
redirectTo: 'https://sync.firefox.com/after_account_unlocked',
resume: 'resumejwt'
};

return accountHelper.newVerifiedAccount()
.then(function (acc) {
account = acc;

return respond(client.accountLock(account.input.email, account.input.password), RequestMocks.accountLock);
})
.then(function () {
return respond(client.accountUnlockResendCode(account.input.email, opts), RequestMocks.accountUnlockResendCode)
})
.then(function () {
return respond(mail.wait(account.input.user, 2), RequestMocks.resetMailUnlock);
})
.then(function (emails) {
var code = emails[1].html.match(/code=([A-Za-z0-9]+)/)[1];
return respond(client.accountUnlockVerifyCode(account.signUp.uid, code), RequestMocks.accountUnlockVerifyCode);
})
.then(
function (result) {
assert.ok(result);
},
assert.notOk
);
});

test('#accountUnlockVerifyCode with no uid', function () {
Expand Down
46 changes: 0 additions & 46 deletions tests/lib/devices.js

This file was deleted.

8 changes: 4 additions & 4 deletions tests/mocks/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ define(['client/lib/errors'], function (ERRORS) {
status: 200,
body: '[{"html":"Mocked code=9001"}, {"html":"Mocked code=9001"}]'
},
resetMailUnlock: {
status: 200,
body: '[{"html":"Mocked code=9001"}, {"html":"Mocked code=9001"}]'
},
resetMailWithServiceAndRedirect: {
status: 200,
body: '[{"html":"Mocked code=9001"}, {"html":"Mocked code=9001 service=sync redirectTo=https resume=resumejwt"}]'
Expand Down Expand Up @@ -121,10 +125,6 @@ define(['client/lib/errors'], function (ERRORS) {
status: 200,
body: '{ "bundle": "7f1a9633560774251a2d317b4539e04bcb14a767ec92e3b3f4d438fdad984831f6d1e1b0d93c23d312bf0859270dc8c0e6ebcae4c499f3a604881fc57683459b01cdfd04757835b0334a80728ce40cf50dce32bb365d8a0ac868bb747bf8aca4"}'
},
accountDevices: {
status: 200,
body: '{ "devices": [ { "id": "4c352927-cd4f-4a4a-a03d-7d1893d950b8", "type": "computer", "name": "Macbook" } ] }'
},
accountStatus: {
status: 200,
body: '{ "exists": true }'
Expand Down

0 comments on commit 13c1b83

Please sign in to comment.