Merge pull request #2879 from mozilla/pb/2850

https://github.com/mozilla/fxa-auth-server/pull/2879
r=shane-tomlinson
This commit is contained in:
Phil Booth 2019-01-24 10:48:50 +00:00 коммит произвёл GitHub
Родитель c51f0605e3 39c6d31c89
Коммит acd40c3916
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 17 добавлений и 5 удалений

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

@ -53,9 +53,13 @@ const IGNORE_ROUTE_FLOW_EVENTS_FOR_PATHS = new Set([
'/account/devices',
'/account/profile',
'/account/sessions',
'/certificate/sign'
'/certificate/sign',
'/password/forgot/status',
'/recovery_email/status'
])
const IGNORE_ROUTE_FLOW_EVENTS_REGEX = /^\/recoveryKey\/[0-9A-Fa-f]+$/
const PATH_PREFIX = /^\/v1/
module.exports = (log, config) => {
@ -130,7 +134,7 @@ module.exports = (log, config) => {
const path = request.path.replace(PATH_PREFIX, '')
let status = response.statusCode || response.output.statusCode
if (status === 404 || IGNORE_ROUTE_FLOW_EVENTS_FOR_PATHS.has(path)) {
if (status === 404 || IGNORE_ROUTE_FLOW_EVENTS_FOR_PATHS.has(path) || IGNORE_ROUTE_FLOW_EVENTS_REGEX.test(path)) {
return P.resolve()
}

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

@ -952,11 +952,19 @@ describe('metrics/events', () => {
})
})
it('.emitRouteFlowEvent with non-matching route', () => {
;[
'/account/devices',
'/account/profile',
'/account/sessions',
'/certificate/sign',
'/password/forgot/status',
'/recovery_email/status',
'/recoveryKey/0123456789abcdef0123456789ABCDEF'
].forEach(route => it(`.emitRouteFlowEvent with ${route}`, () => {
const metricsContext = mocks.mockMetricsContext()
const request = mocks.mockRequest({
metricsContext,
path: '/v1/account/devices',
path: `/v1${route}`,
payload: {
metricsContext: {
flowId: 'bar',
@ -972,7 +980,7 @@ describe('metrics/events', () => {
assert.equal(metricsContext.clear.callCount, 0, 'metricsContext.clear was not called')
assert.equal(log.error.callCount, 0, 'log.error was not called')
})
})
}))
it('.emitRouteFlowEvent with matching route and invalid metrics context', () => {
const metricsContext = mocks.mockMetricsContext({ validate: sinon.spy(() => false) })