Skip to content

Commit

Permalink
test response for protocol that is not base64url encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Sep 19, 2024
1 parent c9b92e8 commit 72d5c5d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/http-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,13 @@ describe('http api', function () {
const protocolQueryResponse = await fetch(protocolUrl);
expect(protocolQueryResponse.status).to.equal(404);
});

it('returns a 400 if protocol is not base64url encoded', async function () {
const protocolUrl = `http://localhost:3000/${alice.did}/read/protocols/invalid-protocol`;
const protocolQueryResponse = await fetch(protocolUrl);
expect(protocolQueryResponse.status).to.equal(400);
expect(await protocolQueryResponse.text()).to.equal('Bad Request');
});
});

describe('/:did/query/protocols', function () {
Expand Down Expand Up @@ -860,6 +867,13 @@ describe('http api', function () {
expect(recordReadResponse.status).to.equal(400);
expect(await recordReadResponse.text()).to.equal('protocol path is required');
});

it('returns a 400 error if protocol cannot be base64url encoded', async function () {
const protocolUrl = `http://localhost:3000/${alice.did}/read/protocols/invalid-protocol/foo`;
const recordReadResponse = await fetch(protocolUrl);
expect(recordReadResponse.status).to.equal(400);
expect(await recordReadResponse.text()).to.equal('Bad Request');
})
});

describe('/:did/query', function () {
Expand Down

0 comments on commit 72d5c5d

Please sign in to comment.