From 63bd0ab3a14fb181e45e4ae31497ed861cdf2ee6 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 6 Mar 2024 12:48:59 -0800 Subject: [PATCH] validate.GET_re? --- routes/group.js | 1 - routes/permission.js | 8 ++++---- routes/session.js | 2 +- routes/user.js | 19 ++++++++++++++----- routes/user.test.js | 2 +- test.js | 2 +- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/routes/group.js b/routes/group.js index ad8a7aa..58f63f4 100644 --- a/routes/group.js +++ b/routes/group.js @@ -86,7 +86,6 @@ function GroupRoutes(server) { tags: ['api'], }, handler: async (request, h) => { - const groups = await Group.get({ id: parseInt(request.params.id, 10) }) /* c8 ignore next 10 */ if (groups.length !== 1) { diff --git a/routes/permission.js b/routes/permission.js index af5c24f..99fdbe9 100644 --- a/routes/permission.js +++ b/routes/permission.js @@ -10,10 +10,10 @@ function PermissionRoutes(server) { path: '/permission/{id}', options: { validate: { - query: validate.permission.v3, + query: validate.permission.GET_req, }, response: { - schema: validate.permission.GET, + schema: validate.permission.GET_res, }, tags: ['api'], }, @@ -44,7 +44,7 @@ function PermissionRoutes(server) { payload: validate.permission.POST, }, response: { - schema: validate.permission.GET, + schema: validate.permission.GET_res, }, tags: ['api'], }, @@ -72,7 +72,7 @@ function PermissionRoutes(server) { query: validate.permission.DELETE, }, response: { - schema: validate.permission.GET, + schema: validate.permission.GET_res, }, tags: ['api'], }, diff --git a/routes/session.js b/routes/session.js index 46a6a09..ee2cea4 100644 --- a/routes/session.js +++ b/routes/session.js @@ -12,7 +12,7 @@ function SessionRoutes(server) { path: '/session', options: { response: { - schema: validate.session.GET, + schema: validate.session.GET_res, }, tags: ['api'], }, diff --git a/routes/user.js b/routes/user.js index 8a3e093..06a1277 100644 --- a/routes/user.js +++ b/routes/user.js @@ -9,8 +9,11 @@ function UserRoutes(server) { method: 'GET', path: '/user', options: { + validate: { + query: validate.user.GET_req, + }, response: { - schema: validate.user.GET, + schema: validate.user.GET_res, }, // tags: ['api'], }, @@ -35,8 +38,11 @@ function UserRoutes(server) { method: 'GET', path: '/user/{id}', options: { + validate: { + query: validate.user.GET_req, + }, response: { - schema: validate.user.GET, + schema: validate.user.GET_res, }, tags: ['api'], }, @@ -76,10 +82,10 @@ function UserRoutes(server) { path: '/user', options: { validate: { - payload: validate.user.userPOST, + payload: validate.user.POST, }, response: { - schema: validate.user.GET, + schema: validate.user.GET_res, }, tags: ['api'], }, @@ -109,8 +115,11 @@ function UserRoutes(server) { method: 'DELETE', path: '/user/{id}', options: { + validate: { + query: validate.user.DELETE, + }, response: { - schema: validate.user.GET, + schema: validate.user.GET_res, }, tags: ['api'], }, diff --git a/routes/user.test.js b/routes/user.test.js index 32829a3..27f541e 100644 --- a/routes/user.test.js +++ b/routes/user.test.js @@ -122,7 +122,7 @@ describe('user routes', () => { it(`GET /user/${userId2}?deleted=1`, async () => { const res = await server.inject({ method: 'GET', - url: `/user/${userId2}?deleted=1`, + url: `/user/${userId2}?deleted=true`, headers: { Cookie: sessionCookie, }, diff --git a/test.js b/test.js index 177d6d6..cba2bd4 100644 --- a/test.js +++ b/test.js @@ -48,7 +48,7 @@ async function setup() { async function teardown() { await Nameserver.destroy({ id: nsCaseR.id }) - await Nameserver.destroy({ id: nsCaseR.id -1 }) + await Nameserver.destroy({ id: nsCaseR.id - 1 }) await Permission.destroy({ id: userCase.id }) await Permission.destroy({ id: userCase.id - 1 }) await Session.delete({ nt_user_id: userCase.id })