Skip to content

Commit

Permalink
add more status tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Sep 9, 2024
1 parent fb58bab commit 54b1997
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import vprTestNocks from './test-fixtures/nocks/vprTest.js'
import unknownStatusListNock from './test-fixtures/nocks/unknown_status_list_nock.js'
import statusListNock from './test-fixtures/nocks/status_list_nock.js'

import unprotectedStatusUpdateNock from './test-fixtures/nocks/unprotected_status_update.js'
import unknownStatusIdNock from './test-fixtures/nocks/unknown_status_id_nock.js'
import protectedStatusUpdateNock from './test-fixtures/nocks/protected_status_update.js'

import { getSignedDIDAuth } from './didAuth.js';

import { build } from './app.js';
Expand Down Expand Up @@ -397,8 +401,8 @@ describe('api', () => {
.expect('Content-Type', /json/)
.expect(403, done)
}) */
//still AVE TO TRY these:
/*


it('update unprotected status when token not set for tenant in config', done => {
unprotectedStatusUpdateNock()
request(app)
Expand All @@ -407,19 +411,19 @@ describe('api', () => {
.expect('Content-Type', /json/)
.expect(200, done)
})
it('returns 404 for unknown cred id', async () => {
unknownStatusIdNock()
const statusUpdateBodyWithUnknownId = JSON.parse(JSON.stringify(statusUpdateBody))
statusUpdateBodyWithUnknownId.credentialId = 'kj09ij'
const response = await request(app)
.post('/instance/protected_test/credentials/status')
.set('Authorization', `Bearer ${testTenantToken}`)
.post(`/instance/${protectedTenantName}/credentials/status`)
.set('Authorization', `Bearer ${protectedTenantToken}`)
.send(statusUpdateBodyWithUnknownId)

expect(response.header['content-type']).to.have.string('json')
expect(response.status).to.equal(404)
})*/
})
})

describe('GET /status/:statusCredentialId', () => {
Expand Down
27 changes: 27 additions & 0 deletions src/test-fixtures/nocks/protected_status_update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import nock from 'nock'

export default () => {
nock('http://localhost:4008', { encodedQueryParams: true })
.post('/credentials/status', {
credentialId: 'urn:uuid:951b475e-b795-43bc-ba8f-a2d01efd2eb1',
credentialStatus: [{ type: 'BitstringStatusListCredential', status: 'revoked' }]
})
.reply(200, { code: 200, message: 'Credential status successfully updated.' }, [
'X-Powered-By',
'Express',
'Access-Control-Allow-Origin',
'*',
'Content-Type',
'application/json; charset=utf-8',
'Content-Length',
'64',
'ETag',
'W/"40-QIRY/d4PUONYie1grSHLdg5/hcs"',
'Date',
'Wed, 23 Aug 2023 20:42:41 GMT',
'Connection',
'keep-alive',
'Keep-Alive',
'timeout=5'
])
}
27 changes: 27 additions & 0 deletions src/test-fixtures/nocks/unknown_status_id_nock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import nock from 'nock'

export default () => {
nock('http://localhost:4008', { encodedQueryParams: true })
.post('/credentials/status', {
credentialId: 'kj09ij',
credentialStatus: [{ type: 'BitstringStatusListCredential', status: 'revoked' }]
})
.reply(404, { code: 404, message: 'Credential ID not found.' }, [
'X-Powered-By',
'Express',
'Access-Control-Allow-Origin',
'*',
'Content-Type',
'application/json; charset=utf-8',
'Content-Length',
'49',
'ETag',
'W/"31-lbV74I+iXZStkOsz/GAY1mIZewQ"',
'Date',
'Wed, 23 Aug 2023 20:44:24 GMT',
'Connection',
'keep-alive',
'Keep-Alive',
'timeout=5'
])
}
27 changes: 27 additions & 0 deletions src/test-fixtures/nocks/unprotected_status_update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import nock from 'nock'

export default () => {
nock('http://localhost:4008', { encodedQueryParams: true })
.post('/credentials/status', {
credentialId: 'urn:uuid:951b475e-b795-43bc-ba8f-a2d01efd2eb1',
credentialStatus: [{ type: 'BitstringStatusListCredential', status: 'revoked' }]
})
.reply(200, 'Credential status successfully updated', [
'X-Powered-By',
'Express',
'Access-Control-Allow-Origin',
'*',
'Content-Type',
'text/html; charset=utf-8',
'Content-Length',
'38',
'ETag',
'W/"26-5PplkKqVB9H6fTLVTOo/weOUkgE"',
'Date',
'Wed, 23 Aug 2023 13:01:55 GMT',
'Connection',
'keep-alive',
'Keep-Alive',
'timeout=5'
])
}

0 comments on commit 54b1997

Please sign in to comment.