Skip to content

Commit

Permalink
chore: topics/k1ch/admin-get-personas-permissions/minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
k1ch committed Dec 28, 2023
1 parent eb1f814 commit 22cdcbb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion database/test/db-admin-persona.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Admin persona view', () => {
const personaPermissions = await adminPersonas.getPersonaPermissions(personakey)
assert.equal(!!personaPermissions.length, true)
})
it('Should return an empty array', async function () {
it('Should return an empty array', async () => {
const personaPermissions = await adminPersonas.getPersonaPermissions(invalidPersonaKey)
assert.equal(personaPermissions.length, 0)
})
Expand Down
18 changes: 15 additions & 3 deletions server/test/endpoint_admin_personas_permissions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { describe, it, before } = require('mocha')
const fetch = require('node-fetch')
const assert = require('assert')

const { getAdmin1IdPToken } = require('./lib/tokens')
const { getAdmin1IdPToken, getTestUser1IdPToken } = require('./lib/tokens')
const { getServerUrl } = require('./lib/urls')
const { usherDb } = require('../../database/layer/knex')

Expand All @@ -12,10 +12,10 @@ describe('Admin Personas Permissions', () => {
const url = `${getServerUrl()}`

before(async () => {
const userAccessToken = await getAdmin1IdPToken()
const adminAccessToken = await getAdmin1IdPToken()
requestHeaders = {
'Content-Type': 'application/json',
Authorization: `Bearer ${userAccessToken}`,
Authorization: `Bearer ${adminAccessToken}`,
}
})

Expand Down Expand Up @@ -54,5 +54,17 @@ describe('Admin Personas Permissions', () => {
})
assert.equal(response.status, 404)
})

it('should return 401 due to lack of proper token', async () => {
const userAccessToken = await getTestUser1IdPToken()
const response = await fetch(`${url}/personas/${validPersonaWithNoPermissions}/permissions`, {
method: 'GET',
headers: {
...requestHeaders,
Authorization: `Bearer ${userAccessToken}`
},
})
assert.equal(response.status, 401)
})
})
})
6 changes: 4 additions & 2 deletions server/the-usher-openapi-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,15 @@ paths:
get:
'x-swagger-router-controller': 'personas/permissions'
operationId: getPersonaPermissions
parameters:
- $ref: '#/components/parameters/personaKeyPathParam'
tags:
- Admin APIs
security:
- bearerAdminAuth: []
responses:
200:
description: Returns the list of permission for the subject persona
description: Returns a list of permissions for the subject persona
content:
application/json:
schema:
Expand Down Expand Up @@ -767,7 +769,7 @@ components:
$ref: '#/components/schemas/EntityDescriptionDef'
required:
- permission
#---------------------

PermissionObject:
type: object
properties:
Expand Down

0 comments on commit 22cdcbb

Please sign in to comment.