Merge pull request #1548 from mozilla/unknown-unblock
fix(unblock): rethrow customs server error when account is unknown
This commit is contained in:
Коммит
47c08753ad
|
@ -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) => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче