Skip to content

Commit

Permalink
fix testing/lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Oct 22, 2024
1 parent 755dc4f commit 9750713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function callService (endpoint, body) {
return data
}

function isNotValidVC(unSignedVC) {
function isNotValidVC (unSignedVC) {
return !unSignedVC || !Object.keys(unSignedVC).length || !unSignedVC.credentialSubject
}

Expand Down Expand Up @@ -92,7 +92,6 @@ export async function build (opts = {}) {
const authHeader = req.headers.authorization
const body = req.body
const unSignedVC = body.credential ? body.credential : body
422
await verifyAuthHeader(authHeader, tenantName)
// NOTE: we throw the error here which will then be caught by middleware errorhandler
if (isNotValidVC(unSignedVC)) throw new IssuingException(422, 'A verifiable credential must be provided in the body')
Expand Down
8 changes: 4 additions & 4 deletions src/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ describe('api', () => {
})

describe('POST /instance/:instanceId/credentials/issue', () => {
it('returns 400 if no body', done => {
it('returns 422 if no body', done => {
request(app)
.post('/instance/protected_test/credentials/issue')
.set('Authorization', `Bearer ${testTenantToken}`)
.expect('Content-Type', /json/)
.expect(400, done)
.expect(422, done)
})

it('returns 401 if tenant token is missing from auth header', done => {
Expand All @@ -88,7 +88,7 @@ describe('api', () => {
.send(getUnsignedVC())

expect(response.header['content-type']).to.have.string('json')
expect(response.status).to.equal(200)
expect(response.status).to.equal(201)
expect(response.body)
})

Expand Down Expand Up @@ -137,7 +137,7 @@ describe('api', () => {
.send(sentCred)

expect(response.header['content-type']).to.have.string('json')
expect(response.status).to.equal(200)
expect(response.status).to.equal(201)

const returnedCred = JSON.parse(JSON.stringify(response.body))
// this proof value comes from the nock:
Expand Down

0 comments on commit 9750713

Please sign in to comment.