Merge pull request #1548 from mozilla/unknown-unblock

fix(unblock): rethrow customs server error when account is unknown
This commit is contained in:
Sean McArthur 2016-11-15 19:43:37 -08:00 коммит произвёл GitHub
Родитель a69dfe6734 b5bda6b6fc
Коммит 47c08753ad
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -512,6 +512,9 @@ module.exports = function (
email: email,
errno: err.errno
})
if (customsErr) {
throw customsErr
}
}
throw err
}

Просмотреть файл

@ -1476,6 +1476,11 @@ describe('/account/login', function () {
mockCustoms.check = () => P.reject(error.requestBlocked(true))
})
beforeEach(() => {
mockLog.activityEvent.reset()
mockLog.flowEvent.reset()
})
after(() => {
mockCustoms.check = oldCheck
})
@ -1516,6 +1521,15 @@ describe('/account/login', function () {
describe('with unblock code', () => {
mockLog.flowEvent.reset()
let previousEmailRecord
before(() => {
previousEmailRecord = mockDB.emailRecord
})
afterEach(() => {
mockDB.emailRecord = previousEmailRecord
})
it('invalid code', () => {
mockDB.consumeUnblockCode = () => P.reject(error.invalidUnblockCode())
return runTest(route, mockRequestWithUnblockCode).then(() => assert.ok(false), err => {
@ -1542,6 +1556,14 @@ describe('/account/login', function () {
})
})
it('unknown account', () => {
mockDB.emailRecord = () => P.reject(new error.unknownAccount())
return runTest(route, mockRequestWithUnblockCode).then(() => assert(false), err => {
assert.equal(err.errno, error.ERRNO.REQUEST_BLOCKED)
assert.equal(err.output.statusCode, 400)
})
})
it('valid code', () => {
mockDB.consumeUnblockCode = () => P.resolve({ createdAt: Date.now() })
return runTest(route, mockRequestWithUnblockCode, (res) => {