This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
Test refactor #506
Merged
Merged
Test refactor #506
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8f3509f
restructure tests
dannycoates e6508cd
remove unreachable code
dannycoates 1013c15
increased test coverage
dannycoates 1a525bc
remote tests working against prod
dannycoates 61367a8
increased test coverage
dannycoates a658008
fixed lint errors before @pdehaan flips a table
dannycoates 4bc4b68
added grunt to npm test-all
dannycoates File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,9 +131,6 @@ module.exports = function ( | |
db.emailRecord(form.email) | ||
.then( | ||
function (emailRecord) { | ||
if (!emailRecord) { | ||
throw error.unknownAccount(form.email) | ||
} | ||
return password.stretch(authPW, emailRecord.authSalt) | ||
.then( | ||
function (stretched) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was unreachable |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,6 @@ module.exports = function (log, isA, error, db, redirectDomain, mailer) { | |
db.emailRecord(form.email) | ||
.then( | ||
function (emailRecord) { | ||
if (!emailRecord) { | ||
throw error.unknownAccount(form.email) | ||
} | ||
return password.stretch(oldAuthPW, emailRecord.authSalt) | ||
.then( | ||
function (oldStretched) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unreachable |
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
require('ass') | ||
var test = require('tap').test | ||
var butil = require('../../crypto/butil') | ||
|
||
test( | ||
'buffersAreEqual returns false if lengths are different', | ||
function (t) { | ||
t.equal(butil.buffersAreEqual(Buffer(2), Buffer(4)), false) | ||
t.end() | ||
} | ||
) | ||
|
||
test( | ||
'buffersAreEqual returns true if buffers have same bytes', | ||
function (t) { | ||
var b1 = Buffer('abcd', 'hex') | ||
var b2 = Buffer('abcd', 'hex') | ||
t.equal(butil.buffersAreEqual(b1, b2), true) | ||
t.end() | ||
} | ||
) | ||
|
||
test( | ||
'xorBuffers throws an Error if lengths are different', | ||
function (t) { | ||
try { | ||
butil.xorBuffers(Buffer(2), Buffer(4)) | ||
} | ||
catch (e) { | ||
return t.end() | ||
} | ||
t.fail('did not throw') | ||
} | ||
) | ||
|
||
test( | ||
'xorBuffers works', | ||
function (t) { | ||
var b1 = Buffer('e5', 'hex') | ||
var b2 = Buffer('5e', 'hex') | ||
t.deepEqual(butil.xorBuffers(b1, b2), Buffer('bb', 'hex')) | ||
t.end() | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
var test = require('../ptaptest') | ||
var TestServer = require('../test_server') | ||
var path = require('path') | ||
var Client = require('../../client') | ||
|
||
process.env.CONFIG_FILES = path.join(__dirname, '../config/api_error.json') | ||
var config = require('../../config').root() | ||
|
||
function fail() { throw new Error() } | ||
|
||
TestServer.start(config) | ||
.then(function main(server) { | ||
|
||
test( | ||
'token expiry', | ||
function (t) { | ||
// FYI config.tokenLifetimes.passwordChangeToken = -1 | ||
var email = Math.random() + "@example.com" | ||
var password = 'ok' | ||
return Client.create(config.publicUrl, email, password, { preVerified: true }) | ||
.then( | ||
function (c) { | ||
return c.changePassword('hello') | ||
} | ||
) | ||
.then( | ||
fail, | ||
function (err) { | ||
t.equal(err.errno, 110, 'invalid token') | ||
} | ||
) | ||
} | ||
) | ||
|
||
test( | ||
'teardown', | ||
function (t) { | ||
server.stop() | ||
t.end() | ||
} | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
var P = require('p-promise') | ||
var request = require('request') | ||
|
||
module.exports = function (host, port) { | ||
|
||
host = host || '127.0.0.1' | ||
port = port || 9001 | ||
|
||
function waitForCode(email) { | ||
return waitForEmail(email) | ||
.then( | ||
function (emailData) { | ||
return emailData.headers['x-verify-code'] || emailData.headers['x-recovery-code'] | ||
} | ||
) | ||
} | ||
|
||
function loop(name, tries, cb) { | ||
var url = 'http://' + host + ':' + port + '/mail/' + name | ||
console.log('checking mail', url) | ||
request({ url: url, method: 'GET' }, | ||
function (err, res, body) { | ||
console.log('mail status', res && res.statusCode, 'tries', tries) | ||
var json = null | ||
try { | ||
json = JSON.parse(body)[0] | ||
} | ||
catch (e) { | ||
return cb(e) | ||
} | ||
|
||
if(!json) { | ||
if (tries === 0) { | ||
return cb(new Error('could not get mail for ' + url)) | ||
} | ||
return setTimeout(loop.bind(null, name, --tries, cb), 1000) | ||
} | ||
console.log('deleting mail', url) | ||
request({ url: url, method: 'DELETE' }, | ||
function (err, res, body) { | ||
cb(err, json) | ||
} | ||
) | ||
} | ||
) | ||
} | ||
|
||
function waitForEmail(email) { | ||
var d = P.defer() | ||
loop(email.split('@')[0], 20, function (err, json) { | ||
return err ? d.reject(err) : d.resolve(json) | ||
}) | ||
return d.promise | ||
} | ||
|
||
return { | ||
waitForEmail: waitForEmail, | ||
waitForCode: waitForCode | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets give travis a break on this one