Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update validateConsentRequest and validateAuthToken #105

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/simulator/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/simulator/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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: {
Expand Down Expand Up @@ -370,8 +370,8 @@ const map = {
'/scopes/{ID}': {
get: getScopesById,
},
'/validateOTP': {
post: postValidateOTP,
'/validateAuthToken': {
post: postValidateAuthToken,
},
'/validateConsentRequests': {
post: validateConsentRequests,
Expand Down
10 changes: 5 additions & 5 deletions src/test/simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -116,30 +116,30 @@ 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: {
authToken: '123456',
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: {
authToken: '123457',
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);
Expand Down