Skip to content

Commit

Permalink
fix: validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinkrustev committed May 15, 2024
1 parent ef14532 commit 13aa5c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/api/transfers/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = [{
accept: Joi.string().optional().regex(regexAccept),
'content-type': Joi.string().required().regex(regexContentType),
'content-length': Joi.number().max(5242880),
date: Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(),
date: Joi.date().format('ddd, DD MMM YYYY HH:mm:ss [GMT]').required(),
'x-forwarded-for': Joi.string().optional(),
'fspiop-source': Joi.string().required(),
'fspiop-destination': Joi.string().optional(),
Expand Down Expand Up @@ -108,7 +108,7 @@ module.exports = [{
validate: {
headers: Joi.object({
'content-type': Joi.string().required().regex(regexContentType),
date: Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(),
date: Joi.date().format('ddd, DD MMM YYYY HH:mm:ss [GMT]').required(),
'x-forwarded-for': Joi.string().optional(),
'fspiop-source': Joi.string().required(),
'fspiop-destination': Joi.string().optional(),
Expand Down Expand Up @@ -150,7 +150,7 @@ module.exports = [{
validate: {
headers: Joi.object({
'content-type': Joi.string().required().regex(regexContentType),
date: Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(),
date: Joi.date().format('ddd, DD MMM YYYY HH:mm:ss [GMT]').required(),
'x-forwarded-for': Joi.string().optional(),
'fspiop-source': Joi.string().required(),
'fspiop-destination': Joi.string().optional(),
Expand Down Expand Up @@ -195,7 +195,7 @@ module.exports = [{
headers: Joi.object({
accept: Joi.string().optional().regex(regexAccept),
'content-type': Joi.string().required().regex(regexContentType),
date: Joi.date().format('ddd, D MMM YYYY H:mm:ss [GMT]').required(),
date: Joi.date().format('ddd, DD MMM YYYY HH:mm:ss [GMT]').required(),
'x-forwarded-for': Joi.string().optional(),
'fspiop-source': Joi.string().required(),
'fspiop-destination': Joi.string().optional(),
Expand Down
16 changes: 8 additions & 8 deletions test/unit/api/transfers/routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Test('return error if Date Header is not according to format in RFC7231 as per M
})
const server = await Base.setup()
const res = await server.inject(req)
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, D MMM YYYY H:mm:ss [GMT]]]')
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, DD MMM YYYY HH:mm:ss [GMT]]]')
await server.stop()
assert.end()
})
Expand Down Expand Up @@ -247,7 +247,7 @@ Test('return error if Date Header is not according to format in RFC7231 as per M
})
const server = await Base.setup()
const res = await server.inject(req)
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, D MMM YYYY H:mm:ss [GMT]]]')
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, DD MMM YYYY HH:mm:ss [GMT]]]')
await server.stop()
assert.end()
})
Expand All @@ -271,7 +271,7 @@ Test('return error if Date Header is not according to format in RFC7231 as per M
})
const server = await Base.setup()
const res = await server.inject(req)
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, D MMM YYYY H:mm:ss [GMT]]]')
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, DD MMM YYYY HH:mm:ss [GMT]]]')
await server.stop()
assert.end()
})
Expand All @@ -282,7 +282,7 @@ Test('return error if transfer is not provided', async function (assert) {
method: 'GET',
payload: {},
headers: {
date: 'Mon, 10 Sep 2018 20:22:01 GMT',
date: 'Mon, 01 Sep 2018 09:22:01 GMT',
'fspiop-source': 'value',
'content-type': 'application/vnd.interoperability.transfers+json;version=1.1'
}
Expand Down Expand Up @@ -313,7 +313,7 @@ Test('return error if FSPIOP-Source is not provided to PUT /transfers/{id}/error
})
const server = await Base.setup()
const res = await server.inject(req)
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, D MMM YYYY H:mm:ss [GMT]]]')
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, DD MMM YYYY HH:mm:ss [GMT]]]')
await server.stop()
assert.end()
})
Expand All @@ -337,7 +337,7 @@ Test('return error if invalid errorCode is provided to PUT /transfers/{id}/error
})
const server = await Base.setup()
const res = await server.inject(req)
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, D MMM YYYY H:mm:ss [GMT]]]')
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, DD MMM YYYY HH:mm:ss [GMT]]]')
await server.stop()
assert.end()
})
Expand All @@ -360,7 +360,7 @@ Test('return error if errorCode is not provided to PUT /transfers/{id}/error', a
})
const server = await Base.setup()
const res = await server.inject(req)
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, D MMM YYYY H:mm:ss [GMT]]]')
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, DD MMM YYYY HH:mm:ss [GMT]]]')
await server.stop()
assert.end()
})
Expand All @@ -383,7 +383,7 @@ Test('return error if errorDescription is not provided to PUT /transfers/{id}/er
})
const server = await Base.setup()
const res = await server.inject(req)
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, D MMM YYYY H:mm:ss [GMT]]]')
Base.assertBadRequestError(assert, res, 'child "date" fails because [date must be a string with one of the following formats [ddd, DD MMM YYYY HH:mm:ss [GMT]]]')
await server.stop()
assert.end()
})

0 comments on commit 13aa5c2

Please sign in to comment.