From bd01b2008fddbbcac6c7d3a84304e12deb17eda7 Mon Sep 17 00:00:00 2001 From: Golda Velez Date: Mon, 23 Oct 2023 17:28:11 -0700 Subject: [PATCH 1/2] add logging of model cid string and tests to cover --- .../anchor-request-params-parser.test.ts | 21 +++++++++++++++++++ src/services/request-service.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ancillary/__tests__/anchor-request-params-parser.test.ts b/src/ancillary/__tests__/anchor-request-params-parser.test.ts index 4ff452999..e96714780 100644 --- a/src/ancillary/__tests__/anchor-request-params-parser.test.ts +++ b/src/ancillary/__tests__/anchor-request-params-parser.test.ts @@ -29,6 +29,8 @@ const TIMESTAMP_ISO = '2023-01-25T17:32:42.971Z' const FAKE_CACAO='test' // the p.domain of the cacao in our test blob +const FAKE_MODEL='kjzl6hvfrbw6c5ws6n17gx7zgb6veprsbb0b2m1x7x026rorhhu0mtuqz4d5zjn' + const LEGACY_REQUEST_EXAMPLE = mockRequest({ headers: { 'Content-Type': 'application/json', @@ -66,6 +68,15 @@ const CAR_FILE_REQUEST_EXAMPLE_SIGNED_GENESIS_WITH_CACAO = mockRequest({ ), }) +const CAR_FILE_REQUEST_EXAMPLE_WITH_MODEL = mockRequest({ + headers: { + 'Content-Type': 'application/vnd.ipld.car', + }, + body: bases['base64url'].decode( + 'uOqJlcm9vdHOB2CpYJQABcRIgQtL_mq5jv6WdKws8V3DwrUhSUnms7JUdb0aT_3sFXDFndmVyc2lvbgGqAQFxEiBC0v-armO_pZ0rCzxXcPCtSFJSeazslR1vRpP_ewVcMaNjdGlw2CpYJgABhQESIFXEyGyqkZ6hvYy558-KIMaMkhW5OEvuCqxXzx3z5_a-aHN0cmVhbUlkWCjOAQMBhQESIFXEyGyqkZ6hvYy558-KIMaMkhW5OEvuCqxXzx3z5_a-aXRpbWVzdGFtcHgYMjAyMy0xMC0yM1QxNjo0MzowOS43MTlaugIBhQESIFXEyGyqkZ6hvYy558-KIMaMkhW5OEvuCqxXzx3z5_a-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wbHh3dm5ydmVyaWZpY2F0aW9uTWV0aG9keGlkaWQ6a2V5Ono2TWtnaHZHSExvYkxFZGoxYmdSTGhTNExQR0pBdmJNQTF0bjJ6Y1J5cW1ZVTVMQyN6Nk1rZ2h2R0hMb2JMRWRqMWJnUkxoUzRMUEdKQXZiTUExdG4yemNSeXFtWVU1TENmaGVhZGVypGNzZXBlbW9kZWxlbW9kZWxYKM4BAgGFARIgI_-XRam_FzV3nlPWMV3YjqwzrNP3leux4_Fjpjd_sDNmdW5pcXVlTCkRWqdoKgigCq5F02tjb250cm9sbGVyc4F4OGRpZDprZXk6ejZNa3N3bXg2QjhCa3FhMUJ6a3NvdmNjWUhOZGtxc3U5R0hHUmJjMW1ucWg5UlJ4' + ), +}) + const CAR_FILE_INVALID = mockRequest({ headers: { @@ -125,6 +136,16 @@ describe('AnchoRequestParamsParser', () => { const params: RequestAnchorParams = (validation as Right).right expect(params.cacaoDomain).toEqual(FAKE_CACAO) + expect((params as RequestAnchorParamsV2).genesisFields.model?.toString() ?? '').toEqual('') + }) + + + test('parses CAR file with model properly', () => { + const validation = parser.parse(CAR_FILE_REQUEST_EXAMPLE_WITH_MODEL as ExpReq) + expect(isRight(validation)).toEqual(true) + + const params: RequestAnchorParams = (validation as Right).right + expect((params as RequestAnchorParamsV2).genesisFields.model.toString()).toEqual(FAKE_MODEL) }) test('isleft indicates invalid car file', () => { diff --git a/src/services/request-service.ts b/src/services/request-service.ts index 0a830537a..7b8913aeb 100644 --- a/src/services/request-service.ts +++ b/src/services/request-service.ts @@ -109,7 +109,7 @@ export class RequestService { did, schema: genesisFields?.schema, family: genesisFields?.family, - model: genesisFields?.model, + model: genesisFields?.model?.toString() ?? '', stream: request.streamId, origin: request.origin, cacao: 'cacaoDomain' in params ? params.cacaoDomain : '', From 35a3b906c7aad53c1a39f8937cd72972fe062d72 Mon Sep 17 00:00:00 2001 From: Golda Velez Date: Tue, 24 Oct 2023 15:48:08 -0700 Subject: [PATCH 2/2] Update src/ancillary/__tests__/anchor-request-params-parser.test.ts Co-authored-by: Spencer T Brody --- src/ancillary/__tests__/anchor-request-params-parser.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ancillary/__tests__/anchor-request-params-parser.test.ts b/src/ancillary/__tests__/anchor-request-params-parser.test.ts index e96714780..f5d599e5d 100644 --- a/src/ancillary/__tests__/anchor-request-params-parser.test.ts +++ b/src/ancillary/__tests__/anchor-request-params-parser.test.ts @@ -136,7 +136,7 @@ describe('AnchoRequestParamsParser', () => { const params: RequestAnchorParams = (validation as Right).right expect(params.cacaoDomain).toEqual(FAKE_CACAO) - expect((params as RequestAnchorParamsV2).genesisFields.model?.toString() ?? '').toEqual('') + expect((params as RequestAnchorParamsV2).genesisFields.model).toBeUndefined() })