From 72d5c5d3faac43ace4e4685b8c44b59f8ad46d01 Mon Sep 17 00:00:00 2001 From: Liran Cohen Date: Thu, 19 Sep 2024 16:34:54 -0400 Subject: [PATCH] test response for protocol that is not base64url encoded --- tests/http-api.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/http-api.spec.ts b/tests/http-api.spec.ts index b958c58..6a6b6c0 100644 --- a/tests/http-api.spec.ts +++ b/tests/http-api.spec.ts @@ -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 () { @@ -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 () {