From 7f6b9f76a68905ff24fb00ed1b445e6bc36a1186 Mon Sep 17 00:00:00 2001 From: Kevin Leyow Date: Fri, 4 Jun 2021 09:18:29 -0500 Subject: [PATCH] chore: update validateConsentRequest and validateAuthToken --- src/simulator/api.yaml | 20 +++++++++----------- src/simulator/handlers.js | 10 +++++----- src/test/simulator.js | 10 +++++----- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/simulator/api.yaml b/src/simulator/api.yaml index 86b7e853..ef7fc7cf 100644 --- a/src/simulator/api.yaml +++ b/src/simulator/api.yaml @@ -587,12 +587,12 @@ paths: application/json: schema: $ref: '#/components/schemas/errorResponse' - /validateOTP: + /validateAuthToken: post: - operationId: PostValidateOTP - summary: PostValidateOTP + operationId: PostValidateAuthToken + summary: PostValidateAuthToken description: | - The HTTP request `POST /validateOTP` is used to validate an auth token from a PISP for authentication. + The HTTP request `POST /validateAuthToken` is used to validate an auth token from a PISP for authentication. tags: - validateOTP requestBody: @@ -2035,13 +2035,11 @@ components: type: object description: The object sent in a `POST /consentRequests` request. properties: - id: + consentRequestId: $ref: '#/components/schemas/CorrelationId' - initiatorId: + userId: type: string - description: >- - The id of the PISP who will initiate transactions on a user's - behalf. + description: ID used to associate request with GET /accounts request. scopes: type: array items: @@ -2056,8 +2054,8 @@ components: The callback uri that the user will be redirected to after completing the WEB auth channel. required: - - id - - initiatorId + - consentRequestId + - userId - scopes - authChannels - callbackUri diff --git a/src/simulator/handlers.js b/src/simulator/handlers.js index 191f19b4..a7cad1d6 100644 --- a/src/simulator/handlers.js +++ b/src/simulator/handlers.js @@ -254,9 +254,9 @@ const getScopesById = async (ctx) => { ctx.response.status = 200; }; -const postValidateOTP = async (ctx) => { +const postValidateAuthToken = async (ctx) => { // fake validation for testing purposes - // even auth tokens validate true + // even auth tokens validate true as default mock response, if rules not configured const res = { isValid: ctx.request.body.authToken % 2 === 0, }; @@ -268,7 +268,7 @@ const postValidateOTP = async (ctx) => { const validateConsentRequests = async (ctx) => { const request = ctx.request.body; ctx.state.logger.log(`validateConsentRequests request body: ${util.inspect(request)}`); - // default mock reponse, if rules not configured + // default mock response, if rules not configured const res = { isValid: true, data: { @@ -370,8 +370,8 @@ const map = { '/scopes/{ID}': { get: getScopesById, }, - '/validateOTP': { - post: postValidateOTP, + '/validateAuthToken': { + post: postValidateAuthToken, }, '/validateConsentRequests': { post: validateConsentRequests, diff --git a/src/test/simulator.js b/src/test/simulator.js index 860ff887..95d9d01a 100644 --- a/src/test/simulator.js +++ b/src/test/simulator.js @@ -76,7 +76,7 @@ test('get scopes by Id', async (t) => { test('post validateConsentRequests', async (t) => { // eslint-disable-next-line no-param-reassign t.context.request = { - body: { id: '123456' }, + body: { consentRequestId: '123456' }, }; await map['/validateConsentRequests'].post(t.context); t.truthy(t.context.response.body); @@ -116,7 +116,7 @@ test('get consentRequest', async (t) => { t.is(t.context.response.status, 200); }); -test('post validate otp valid', async (t) => { +test('post validate authToken valid', async (t) => { // eslint-disable-next-line no-param-reassign t.context.request = { body: { @@ -124,14 +124,14 @@ test('post validate otp valid', async (t) => { consentRequestId: idValue, }, }; - await map['/validateOTP'].post(t.context); + await map['/validateAuthToken'].post(t.context); t.truthy(t.context.response.body); t.is(t.context.response.body.isValid, true); t.is(t.context.response.status, 200); }); -test('post validate otp invalid', async (t) => { +test('post validate authToken invalid', async (t) => { // eslint-disable-next-line no-param-reassign t.context.request = { body: { @@ -139,7 +139,7 @@ test('post validate otp invalid', async (t) => { consentRequestId: idValue, }, }; - await map['/validateOTP'].post(t.context); + await map['/validateAuthToken'].post(t.context); t.truthy(t.context.response.body); t.is(t.context.response.body.isValid, false); t.is(t.context.response.status, 200);