From e8ad4b151df4cdb8d775bbea609c817a5b0bd35a Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 10:53:26 -0400 Subject: [PATCH 1/9] Sample --- src/handlers/records-write.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/records-write.ts b/src/handlers/records-write.ts index 5e8fb75f9..47e24cf97 100644 --- a/src/handlers/records-write.ts +++ b/src/handlers/records-write.ts @@ -163,7 +163,7 @@ export class RecordsWriteHandler implements MethodHandler { } const messageReply = { - status: { code: 202, detail: 'Accepted' } + status: { code: newMessageIsInitialWrite ? 204 : 202, detail: newMessageIsInitialWrite ? 'No Content' : 'Accepted' } }; // delete all existing messages of the same record that are not newest, except for the initial write From 486fc35b4a50f04ae7f7d86ae7660d5b3c40b8d2 Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 11:01:47 -0400 Subject: [PATCH 2/9] Fix --- src/handlers/records-write.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/handlers/records-write.ts b/src/handlers/records-write.ts index 47e24cf97..e32427416 100644 --- a/src/handlers/records-write.ts +++ b/src/handlers/records-write.ts @@ -162,8 +162,10 @@ export class RecordsWriteHandler implements MethodHandler { throw error; } - const messageReply = { - status: { code: newMessageIsInitialWrite ? 204 : 202, detail: newMessageIsInitialWrite ? 'No Content' : 'Accepted' } + const messageReply = { + status: (newMessageIsInitialWrite && dataStream !== undefined) ? + { code: 204, detail: 'No Content' } : + { code: 202, detail: 'Accepted' } }; // delete all existing messages of the same record that are not newest, except for the initial write From d38f87b29410abbed4cbc03fd409daa13d456247 Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 11:09:01 -0400 Subject: [PATCH 3/9] Fix the tests. --- package.json | 2 +- tests/dwn.spec.ts | 2 +- tests/features/author-delegated-grant.spec.ts | 42 ++-- tests/features/owner-delegated-grant.spec.ts | 6 +- tests/features/owner-signature.spec.ts | 6 +- tests/features/permissions.spec.ts | 44 ++-- tests/features/protocol-create-action.spec.ts | 10 +- tests/features/protocol-delete-action.spec.ts | 24 +- tests/features/protocol-update-action.spec.ts | 24 +- tests/features/records-prune.spec.ts | 32 +-- tests/features/records-tags.spec.ts | 94 ++++---- tests/features/resumable-tasks.spec.ts | 6 +- tests/handlers/messages-query.spec.ts | 18 +- tests/handlers/messages-read.spec.ts | 36 +-- tests/handlers/messages-subscribe.spec.ts | 20 +- tests/handlers/protocols-query.spec.ts | 12 +- tests/handlers/records-delete.spec.ts | 46 ++-- tests/handlers/records-query.spec.ts | 154 ++++++------- tests/handlers/records-read.spec.ts | 100 ++++----- tests/handlers/records-subscribe.spec.ts | 30 +-- tests/handlers/records-write.spec.ts | 208 +++++++++--------- tests/scenarios/end-to-end-tests.spec.ts | 6 +- tests/scenarios/messages-query.spec.ts | 26 +-- tests/scenarios/nested-roles.spec.ts | 22 +- tests/scenarios/subscriptions.spec.ts | 56 ++--- 25 files changed, 513 insertions(+), 513 deletions(-) diff --git a/package.json b/package.json index 392ef30ac..2cf90f4fb 100644 --- a/package.json +++ b/package.json @@ -158,7 +158,7 @@ "lint": "eslint . --max-warnings 0", "lint:fix": "eslint . --fix", "circular-dependency-check": "depcruise src", - "test:node": "npm run compile-validators && tsc && c8 mocha \"dist/esm/tests/**/*.spec.js\"", + "test:node": "npm run compile-validators && tsc && c8 node --enable-source-maps node_modules/.bin/mocha \"dist/esm/tests/**/*.spec.js\"", "test:browser": "npm run compile-validators && cross-env karma start karma.conf.cjs", "test:browser-debug": "npm run compile-validators && cross-env karma start karma.conf.debug.cjs", "license-check": "license-report --only=prod > license-report.json && node ./build/license-check.cjs", diff --git a/tests/dwn.spec.ts b/tests/dwn.spec.ts index d308c20ae..3a223515b 100644 --- a/tests/dwn.spec.ts +++ b/tests/dwn.spec.ts @@ -64,7 +64,7 @@ export function testDwnClass(): void { const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); }); it('should process RecordsQuery message', async () => { diff --git a/tests/features/author-delegated-grant.spec.ts b/tests/features/author-delegated-grant.spec.ts index 05d4d0ce9..12dabcc43 100644 --- a/tests/features/author-delegated-grant.spec.ts +++ b/tests/features/author-delegated-grant.spec.ts @@ -198,7 +198,7 @@ export function testAuthorDelegatedGrant(): void { }); const deviceXWriteReply = await dwn.processMessage(bob.did, messageByDeviceX.message, { dataStream: deviceXDataStream }); - expect(deviceXWriteReply.status.code).to.equal(202); + expect(deviceXWriteReply.status.code).to.equal(204); // verify the message by device X got written to Bob's DWN, AND Alice is the logical author const recordsQueryByBob = await TestDataGenerator.generateRecordsQuery({ @@ -285,7 +285,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Bob adds Alice as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -297,7 +297,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('Alice is my friend'), }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Bob writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -307,7 +307,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Alice creates a delegated query grant for device X to act as Alice. const queryGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -449,7 +449,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Bob adds Alice as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -461,7 +461,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('Alice is my friend'), }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Alice creates a delegated subscribe grant for device X to act as Alice. const subscribeGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -541,7 +541,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecord1Reply = await dwn.processMessage(bob.did, chatRecord1.message, { dataStream: chatRecord1.dataStream }); - expect(chatRecord1Reply.status.code).to.equal(202); + expect(chatRecord1Reply.status.code).to.equal(204); const chatRecord2 = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -550,7 +550,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecord2Reply = await dwn.processMessage(bob.did, chatRecord2.message, { dataStream: chatRecord2.dataStream }); - expect(chatRecord2Reply.status.code).to.equal(202); + expect(chatRecord2Reply.status.code).to.equal(204); await Poller.pollUntilSuccessOrTimeout(async () => { expect(subscriptionChatRecords.size).to.equal(2); @@ -591,7 +591,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('I trust Alice to manage my chat thread'), }); const globalAdminRecordReply = await dwn.processMessage(bob.did, globalAdminRecord.message, { dataStream: globalAdminRecord.dataStream }); - expect(globalAdminRecordReply.status.code).to.equal(202); + expect(globalAdminRecordReply.status.code).to.equal(204); // Bob starts a chat thread const threadRecord = await TestDataGenerator.generateRecordsWrite({ @@ -600,7 +600,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Bob adds Carol as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -611,7 +611,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Carol writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -623,7 +623,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('A rude message'), }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Alice creates a delegated delete grant for device X to act as Alice. const deleteGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -826,7 +826,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Bob adds Alice as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -838,7 +838,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('Alice is my friend'), }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Bob writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -848,7 +848,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // 2. Alice creates a delegated grant for device X to act as her for a protocol that is NOT chat protocol @@ -968,7 +968,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('I trust Alice to manage my chat thread'), }); const globalAdminRecordReply = await dwn.processMessage(bob.did, globalAdminRecord.message, { dataStream: globalAdminRecord.dataStream }); - expect(globalAdminRecordReply.status.code).to.equal(202); + expect(globalAdminRecordReply.status.code).to.equal(204); // Bob starts a chat thread const threadRecord = await TestDataGenerator.generateRecordsWrite({ @@ -977,7 +977,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Bob adds Carol as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -988,7 +988,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Carol writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1000,7 +1000,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('A rude message'), }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Alice creates a delegated delete grant for Device X to act as her for a protocol that is NOT chat protocol const delegatedGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -1216,7 +1216,7 @@ export function testAuthorDelegatedGrant(): void { deviceXGrant.recordsWrite.message, { dataStream: deviceXGrantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // 3. Alice revokes the grant const permissionRevoke = await PermissionsProtocol.createRevocation({ @@ -1225,7 +1225,7 @@ export function testAuthorDelegatedGrant(): void { }); const revocationDataStream = DataStream.fromBytes(permissionRevoke.permissionRevocationBytes); const permissionRevokeReply = await dwn.processMessage(alice.did, permissionRevoke.recordsWrite.message, { dataStream: revocationDataStream }); - expect(permissionRevokeReply.status.code).to.equal(202); + expect(permissionRevokeReply.status.code).to.equal(204); // 3. Verify that device X cannot write a `RecordsWrite` message to Bob's DWN as Alice using a mismatching delegated grant ID const deviceXData = new TextEncoder().encode('message from device X'); diff --git a/tests/features/owner-delegated-grant.spec.ts b/tests/features/owner-delegated-grant.spec.ts index cc04e2a38..517848d69 100644 --- a/tests/features/owner-delegated-grant.spec.ts +++ b/tests/features/owner-delegated-grant.spec.ts @@ -217,7 +217,7 @@ export function testOwnerDelegatedGrant(): void { appXAugmentedWrite.message, { dataStream: DataStream.fromBytes(bobRecordsWriteBytes) } ); - expect(appXWriteReply.status.code).to.equal(202); + expect(appXWriteReply.status.code).to.equal(204); // 7. Sanity verify the RecordsWrite written by App X const recordsQuery = await TestDataGenerator.generateRecordsQuery({ @@ -598,7 +598,7 @@ export function testOwnerDelegatedGrant(): void { }); const grantDataStream = DataStream.fromBytes(appXGrant.permissionGrantBytes); const permissionGrantWriteReply = await dwn.processMessage(alice.did, appXGrant.recordsWrite.message, { dataStream: grantDataStream }); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // 3. Alice revokes the grant const permissionRevoke = await PermissionsProtocol.createRevocation({ @@ -611,7 +611,7 @@ export function testOwnerDelegatedGrant(): void { permissionRevoke.recordsWrite.message, { dataStream: revocationDataStream } ); - expect(permissionRevokeReply.status.code).to.equal(202); + expect(permissionRevokeReply.status.code).to.equal(204); // 4. A third party (Bob) authors a RecordsWrite const bobRecordsWriteBytes = new TextEncoder().encode('message from Bob'); diff --git a/tests/features/owner-signature.spec.ts b/tests/features/owner-signature.spec.ts index eed9cad07..2aff5eab7 100644 --- a/tests/features/owner-signature.spec.ts +++ b/tests/features/owner-signature.spec.ts @@ -68,7 +68,7 @@ export function testOwnerSignature(): void { // Bob writes a message to his DWN const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: bob, published: true }); const writeReply = await dwn.processMessage(bob.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // Alice fetches the message from Bob's DWN const recordsRead = await RecordsRead.create({ @@ -89,7 +89,7 @@ export function testOwnerSignature(): void { // Test that Alice can successfully retain/write Bob's message to her DWN const aliceDataStream = readReply.record!.data; const aliceWriteReply = await dwn.processMessage(alice.did, ownerSignedMessage.message, { dataStream: aliceDataStream }); - expect(aliceWriteReply.status.code).to.equal(202); + expect(aliceWriteReply.status.code).to.equal(204); // Test that Bob's message can be read from Alice's DWN const readReply2 = await dwn.processMessage(alice.did, recordsRead.message); @@ -135,7 +135,7 @@ export function testOwnerSignature(): void { // Test that Alice can successfully retain/write Bob's message to her DWN const aliceDataStream = DataStream.fromBytes(bobRecordsWrite.dataBytes!); const aliceWriteReply = await dwn.processMessage(alice.did, ownerSignedMessage.message, { dataStream: aliceDataStream }); - expect(aliceWriteReply.status.code).to.equal(202); + expect(aliceWriteReply.status.code).to.equal(204); // Test that Bob's message can be read from Alice's DWN const recordsRead = await RecordsRead.create({ diff --git a/tests/features/permissions.spec.ts b/tests/features/permissions.spec.ts index e7a458099..1b25a8da2 100644 --- a/tests/features/permissions.spec.ts +++ b/tests/features/permissions.spec.ts @@ -183,7 +183,7 @@ export function testPermissions(): void { const grantWriteReply = await dwn.processMessage(alice.did, grantWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(grantWrite.permissionGrantBytes) }); - expect(grantWriteReply.status.code).to.equal(202); + expect(grantWriteReply.status.code).to.equal(204); // derive the grantId and protocol from the grant record const revokeWrite = await PermissionsProtocol.createRevocation({ @@ -233,7 +233,7 @@ export function testPermissions(): void { requestToAlice.recordsWrite.message, { dataStream: DataStream.fromBytes(requestToAlice.permissionRequestBytes) } ); - expect(requestWriteReply.status.code).to.equal(202); + expect(requestWriteReply.status.code).to.equal(204); // 2. Alice queries her DWN for new permission requests const requestQuery = await RecordsQuery.create({ @@ -283,7 +283,7 @@ export function testPermissions(): void { grantWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(grantWrite.permissionGrantBytes) } ); - expect(grantWriteReply.status.code).to.equal(202); + expect(grantWriteReply.status.code).to.equal(204); // 5. Verify that Bob can query the permission grant from Alice's DWN (even though Alice can also send it directly to Bob) const grantQuery = await RecordsQuery.create({ @@ -340,7 +340,7 @@ export function testPermissions(): void { revokeWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeWrite.permissionRevocationBytes) } ); - expect(revokeWriteReply.status.code).to.equal(202); + expect(revokeWriteReply.status.code).to.equal(204); // 9. Verify that any third-party can fetch the revocation status of the permission grant const revocationReadReply2 = await dwn.processMessage(alice.did, revocationRead.message); @@ -419,7 +419,7 @@ export function testPermissions(): void { const grantWriteReply = await dwn.processMessage(alice.did, grantWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(grantWrite.permissionGrantBytes) }); - expect(grantWriteReply.status.code).to.equal(202); + expect(grantWriteReply.status.code).to.equal(204); // attempt to revoke the grant without a protocol set const permissionRevocationBytes = Encoder.objectToBytes({ description: 'Revoking the grant' }); @@ -475,7 +475,7 @@ export function testPermissions(): void { const revokeWriteReply = await dwn.processMessage(alice.did, revokeWrite.message, { dataStream: DataStream.fromBytes(permissionRevocationBytes) }); - expect(revokeWriteReply.status.code).to.equal(202); + expect(revokeWriteReply.status.code).to.equal(204); }); // These set of tets are primarily to ensure SchemaValidation passes for the various permission request and grant messages and their scopes @@ -500,7 +500,7 @@ export function testPermissions(): void { const messagesQueryPermissionsReply = await dwn.processMessage(alice.did, messagesQueryPermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(messagesQueryPermissions.permissionGrantBytes) }); - expect(messagesQueryPermissionsReply.status.code).to.equal(202); + expect(messagesQueryPermissionsReply.status.code).to.equal(204); }); it('MessagesRead', async () => { @@ -523,7 +523,7 @@ export function testPermissions(): void { const messagesReadPermissionsReply = await dwn.processMessage(alice.did, messagesReadPermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(messagesReadPermissions.permissionGrantBytes) }); - expect(messagesReadPermissionsReply.status.code).to.equal(202); + expect(messagesReadPermissionsReply.status.code).to.equal(204); }); it('MessagesSubscribe', async () => { @@ -546,7 +546,7 @@ export function testPermissions(): void { const messagesSubscribePermissionsReply = await dwn.processMessage(alice.did, messagesSubscribePermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(messagesSubscribePermissions.permissionGrantBytes) }); - expect(messagesSubscribePermissionsReply.status.code).to.equal(202); + expect(messagesSubscribePermissionsReply.status.code).to.equal(204); }); it('RecordsDelete', async () => { @@ -570,7 +570,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(202); + expect(withContextIdReply.status.code).to.equal(204); // create a permission request with protocol and protocolPath const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -589,7 +589,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(202); + expect(withProtocolPathReply.status.code).to.equal(204); }); it('RecordsQuery', async () => { @@ -614,7 +614,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(202); + expect(withContextIdReply.status.code).to.equal(204); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createRequest({ @@ -632,7 +632,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(bob.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionRequestBytes) }); - expect(withProtocolPathReply.status.code).to.equal(202); + expect(withProtocolPathReply.status.code).to.equal(204); }); it('RecordsRead', async () => { @@ -657,7 +657,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(202); + expect(withContextIdReply.status.code).to.equal(204); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -677,7 +677,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(202); + expect(withProtocolPathReply.status.code).to.equal(204); }); it('RecordsSubscribe', async () => { @@ -702,7 +702,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(202); + expect(withContextIdReply.status.code).to.equal(204); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -722,7 +722,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(202); + expect(withProtocolPathReply.status.code).to.equal(204); }); it('RecordsWrite', async () => { @@ -747,7 +747,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(202); + expect(withContextIdReply.status.code).to.equal(204); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -767,7 +767,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(202); + expect(withProtocolPathReply.status.code).to.equal(204); }); it('ProtocolsQuery', async () => { @@ -789,7 +789,7 @@ export function testPermissions(): void { const protocolQueryPermissionsReply = await dwn.processMessage(alice.did, protocolQueryPermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(protocolQueryPermissions.permissionGrantBytes) }); - expect(protocolQueryPermissionsReply.status.code).to.equal(202); + expect(protocolQueryPermissionsReply.status.code).to.equal(204); }); }); @@ -819,7 +819,7 @@ export function testPermissions(): void { requestToAlice.recordsWrite.message, { dataStream: DataStream.fromBytes(requestToAlice.permissionRequestBytes) } ); - expect(requestToAliceReply.status.code).to.equal(202); + expect(requestToAliceReply.status.code).to.equal(204); expect(validateScopeSpy.calledOnce).to.be.true; // create a grant @@ -836,7 +836,7 @@ export function testPermissions(): void { grantedToBob.recordsWrite.message, { dataStream: DataStream.fromBytes(grantedToBob.permissionGrantBytes) } ); - expect(grantWriteReply.status.code).to.equal(202); + expect(grantWriteReply.status.code).to.equal(204); expect(validateScopeSpy.calledTwice).to.be.true; // called twice, once for the request and once for the grant }); diff --git a/tests/features/protocol-create-action.spec.ts b/tests/features/protocol-create-action.spec.ts index 73072ebab..8db9c3d8d 100644 --- a/tests/features/protocol-create-action.spec.ts +++ b/tests/features/protocol-create-action.spec.ts @@ -156,7 +156,7 @@ export function testProtocolCreateAction(): void { }); const adminBobRecordsWriteReply = await dwn.processMessage(alice.did, adminBobRecordsWrite.message, { dataStream: adminBobRecordsWrite.dataStream }); - expect(adminBobRecordsWriteReply.status.code).to.equal(202); + expect(adminBobRecordsWriteReply.status.code).to.equal(204); // Verify that Bob can create `foo` by invoking the admin role. const bobRoleAuthorizedFoo = await RecordsWrite.create( @@ -173,7 +173,7 @@ export function testProtocolCreateAction(): void { ); const bobRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, bobRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobRoleAuthorizedCreateReply.status.code).to.equal(202); + expect(bobRoleAuthorizedCreateReply.status.code).to.equal(204); // Verify that Bob cannot update `foo` const bobUnauthorizedFooUpdate = await RecordsWrite.createFrom( @@ -203,7 +203,7 @@ export function testProtocolCreateAction(): void { ); const bobBarCreateReply = await dwn.processMessage(alice.did, bobAuthorAuthorizedBar.message, { dataStream: DataStream.fromBytes(bobBarBytes) }); - expect(bobBarCreateReply.status.code).to.equal(202); + expect(bobBarCreateReply.status.code).to.equal(204); // Verify that Bob cannot update `bar` const bobUnauthorizedBarUpdate = await RecordsWrite.createFrom( @@ -233,7 +233,7 @@ export function testProtocolCreateAction(): void { ); const carolBarCreateReply = await dwn.processMessage(alice.did, carolRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(carolBarBytes) }); - expect(carolBarCreateReply.status.code).to.equal(202); + expect(carolBarCreateReply.status.code).to.equal(204); // Verify that Carol cannot update `bar` const carolUnauthorizedBarUpdate = await RecordsWrite.createFrom( @@ -281,7 +281,7 @@ export function testProtocolCreateAction(): void { ); const danielBazCreateReply = await dwn.processMessage(alice.did, danielAnyoneAuthorizedBar.message, { dataStream: DataStream.fromBytes(danielBazBytes) }); - expect(danielBazCreateReply.status.code).to.equal(202); + expect(danielBazCreateReply.status.code).to.equal(204); // Verify that Daniel cannot update `baz` const danielUnauthorizedBazUpdate = await RecordsWrite.createFrom( diff --git a/tests/features/protocol-delete-action.spec.ts b/tests/features/protocol-delete-action.spec.ts index 42eb7020f..7a969995d 100644 --- a/tests/features/protocol-delete-action.spec.ts +++ b/tests/features/protocol-delete-action.spec.ts @@ -114,7 +114,7 @@ export function testProtocolDeleteAction(): void { }); const userBobRecordsWriteReply = await dwn.processMessage(alice.did, userBobRecordsWrite.message, { dataStream: userBobRecordsWrite.dataStream }); - expect(userBobRecordsWriteReply.status.code).to.equal(202); + expect(userBobRecordsWriteReply.status.code).to.equal(204); const userCarolRecordsWrite = await TestDataGenerator.generateRecordsWrite({ author : alice, @@ -124,7 +124,7 @@ export function testProtocolDeleteAction(): void { }); const userCarolRecordsWriteReply = await dwn.processMessage(alice.did, userCarolRecordsWrite.message, { dataStream: userCarolRecordsWrite.dataStream }); - expect(userCarolRecordsWriteReply.status.code).to.equal(202); + expect(userCarolRecordsWriteReply.status.code).to.equal(204); // 3. Bob creates a `foo` by invoking the user role. const bobFooBytes = TestDataGenerator.randomBytes(100); @@ -141,7 +141,7 @@ export function testProtocolDeleteAction(): void { ); const bobRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, bobRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobRoleAuthorizedCreateReply.status.code).to.equal(202); + expect(bobRoleAuthorizedCreateReply.status.code).to.equal(204); // 4. Verify that Bob can delete his `foo` const bobAuthorizedFooDelete = await RecordsDelete.create( @@ -180,7 +180,7 @@ export function testProtocolDeleteAction(): void { ); const carolRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, carolRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolRoleAuthorizedCreateReply.status.code).to.equal(202); + expect(carolRoleAuthorizedCreateReply.status.code).to.equal(204); // 6. Verify that Bob cannot delete Carol's `foo` const bobUnauthorizedFooDelete = await RecordsDelete.create( @@ -263,7 +263,7 @@ export function testProtocolDeleteAction(): void { protocolPath : 'foo' }); const fooForBobReply = await dwn.processMessage(alice.did, fooForBob.message, { dataStream: fooForBob.dataStream }); - expect(fooForBobReply.status.code).to.equal(202); + expect(fooForBobReply.status.code).to.equal(204); // 3. Alice creates a `foo` with Carol being the recipient, so that Carol can create `bar`. const fooForCarol = await TestDataGenerator.generateRecordsWrite({ @@ -273,7 +273,7 @@ export function testProtocolDeleteAction(): void { protocolPath : 'foo' }); const fooForCarolReply = await dwn.processMessage(alice.did, fooForCarol.message, { dataStream: fooForCarol.dataStream }); - expect(fooForCarolReply.status.code).to.equal(202); + expect(fooForCarolReply.status.code).to.equal(204); // 4. Bob creates a recipient-authorized `bar`. const bobBarBytes = TestDataGenerator.randomBytes(100); @@ -290,7 +290,7 @@ export function testProtocolDeleteAction(): void { ); const bobRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, bobRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(bobBarBytes) }); - expect(bobRecipientAuthorizedBarReply.status.code).to.equal(202); + expect(bobRecipientAuthorizedBarReply.status.code).to.equal(204); // 5. Bob creates a author-authorized `baz` after his `bar`. const bobBazBytes = TestDataGenerator.randomBytes(100); @@ -307,7 +307,7 @@ export function testProtocolDeleteAction(): void { ); const bobAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, bobAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(bobBazBytes) }); - expect(bobAuthorAuthorizedBazReply.status.code).to.equal(202); + expect(bobAuthorAuthorizedBazReply.status.code).to.equal(204); // 6. Carol creates a recipient-authorized `bar`. const carolBarBytes = TestDataGenerator.randomBytes(100); @@ -324,7 +324,7 @@ export function testProtocolDeleteAction(): void { ); const carolRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, carolRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(carolBarBytes) }); - expect(carolRecipientAuthorizedBarReply.status.code).to.equal(202); + expect(carolRecipientAuthorizedBarReply.status.code).to.equal(204); // 7. Carol creates a author-authorized `baz` after her `bar`. const carolBazBytes = TestDataGenerator.randomBytes(100); @@ -341,7 +341,7 @@ export function testProtocolDeleteAction(): void { ); const carolAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, carolAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(carolBazBytes) }); - expect(carolAuthorAuthorizedBazReply.status.code).to.equal(202); + expect(carolAuthorAuthorizedBazReply.status.code).to.equal(204); // 8. Verify that Bob can delete his `baz` const bobAuthorizedBazDelete = await RecordsDelete.create( @@ -453,7 +453,7 @@ export function testProtocolDeleteAction(): void { ); const bobAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, bobAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(202); + expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(204); // 3. Carol creates a anyone-authorized `foo`. const carolFooBytes = TestDataGenerator.randomBytes(100); @@ -469,7 +469,7 @@ export function testProtocolDeleteAction(): void { ); const carolAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, carolAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(202); + expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(204); // 4. Verify that Bob can delete his `foo`. const bobAuthorizedFooDelete = await RecordsDelete.create( diff --git a/tests/features/protocol-update-action.spec.ts b/tests/features/protocol-update-action.spec.ts index 9ac08d935..bf399b76a 100644 --- a/tests/features/protocol-update-action.spec.ts +++ b/tests/features/protocol-update-action.spec.ts @@ -114,7 +114,7 @@ export function testProtocolUpdateAction(): void { }); const userBobRecordsWriteReply = await dwn.processMessage(alice.did, userBobRecordsWrite.message, { dataStream: userBobRecordsWrite.dataStream }); - expect(userBobRecordsWriteReply.status.code).to.equal(202); + expect(userBobRecordsWriteReply.status.code).to.equal(204); const userCarolRecordsWrite = await TestDataGenerator.generateRecordsWrite({ author : alice, @@ -124,7 +124,7 @@ export function testProtocolUpdateAction(): void { }); const userCarolRecordsWriteReply = await dwn.processMessage(alice.did, userCarolRecordsWrite.message, { dataStream: userCarolRecordsWrite.dataStream }); - expect(userCarolRecordsWriteReply.status.code).to.equal(202); + expect(userCarolRecordsWriteReply.status.code).to.equal(204); // 3. Bob creates a `foo` by invoking the user role. const bobFooBytes = TestDataGenerator.randomBytes(100); @@ -141,7 +141,7 @@ export function testProtocolUpdateAction(): void { ); const bobRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, bobRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobRoleAuthorizedCreateReply.status.code).to.equal(202); + expect(bobRoleAuthorizedCreateReply.status.code).to.equal(204); // 4. Verify that Bob can update his `foo` const bobFooNewBytes = TestDataGenerator.randomBytes(100); @@ -184,7 +184,7 @@ export function testProtocolUpdateAction(): void { ); const carolRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, carolRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolRoleAuthorizedCreateReply.status.code).to.equal(202); + expect(carolRoleAuthorizedCreateReply.status.code).to.equal(204); // 6. Verify that carol can update her `foo` const carolFooNewBytes = TestDataGenerator.randomBytes(100); @@ -282,7 +282,7 @@ export function testProtocolUpdateAction(): void { protocolPath : 'foo' }); const fooForBobReply = await dwn.processMessage(alice.did, fooForBob.message, { dataStream: fooForBob.dataStream }); - expect(fooForBobReply.status.code).to.equal(202); + expect(fooForBobReply.status.code).to.equal(204); // 3. Alice creates a `foo` with Carol being the recipient, so that Carol can create `bar`. const fooForCarol = await TestDataGenerator.generateRecordsWrite({ @@ -292,7 +292,7 @@ export function testProtocolUpdateAction(): void { protocolPath : 'foo' }); const fooForCarolReply = await dwn.processMessage(alice.did, fooForCarol.message, { dataStream: fooForCarol.dataStream }); - expect(fooForCarolReply.status.code).to.equal(202); + expect(fooForCarolReply.status.code).to.equal(204); // 4. Bob creates a recipient-authorized `bar`. const bobBarBytes = TestDataGenerator.randomBytes(100); @@ -309,7 +309,7 @@ export function testProtocolUpdateAction(): void { ); const bobRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, bobRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(bobBarBytes) }); - expect(bobRecipientAuthorizedBarReply.status.code).to.equal(202); + expect(bobRecipientAuthorizedBarReply.status.code).to.equal(204); // 5. Carol creates a recipient-authorized `bar`. const carolBarBytes = TestDataGenerator.randomBytes(100); @@ -326,7 +326,7 @@ export function testProtocolUpdateAction(): void { ); const carolRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, carolRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(carolBarBytes) }); - expect(carolRecipientAuthorizedBarReply.status.code).to.equal(202); + expect(carolRecipientAuthorizedBarReply.status.code).to.equal(204); // 6. Verify that Bob can update his `bar`. const bobBarNewBytes = TestDataGenerator.randomBytes(100); @@ -382,7 +382,7 @@ export function testProtocolUpdateAction(): void { ); const bobAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, bobAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(bobBazBytes) }); - expect(bobAuthorAuthorizedBazReply.status.code).to.equal(202); + expect(bobAuthorAuthorizedBazReply.status.code).to.equal(204); // 9. Carol creates a author-authorized `baz` after her `bar`. const carolBazBytes = TestDataGenerator.randomBytes(100); @@ -399,7 +399,7 @@ export function testProtocolUpdateAction(): void { ); const carolAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, carolAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(carolBazBytes) }); - expect(carolAuthorAuthorizedBazReply.status.code).to.equal(202); + expect(carolAuthorAuthorizedBazReply.status.code).to.equal(204); // 10. Verify that Bob can update his `baz` const bobBazNewBytes = TestDataGenerator.randomBytes(100); @@ -494,7 +494,7 @@ export function testProtocolUpdateAction(): void { ); const bobAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, bobAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(202); + expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(204); // 3. Carol creates a anyone-authorized `foo`. const carolFooBytes = TestDataGenerator.randomBytes(100); @@ -510,7 +510,7 @@ export function testProtocolUpdateAction(): void { ); const carolAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, carolAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(202); + expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(204); // 4. Verify that Bob can update his `foo`. const bobFooNewBytes = TestDataGenerator.randomBytes(100); diff --git a/tests/features/records-prune.spec.ts b/tests/features/records-prune.spec.ts index 47fec043b..d0f824b00 100644 --- a/tests/features/records-prune.spec.ts +++ b/tests/features/records-prune.spec.ts @@ -90,11 +90,11 @@ export function testRecordsPrune(): void { const foo1 = await RecordsWrite.create(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: DataStream.fromBytes(fooData) }); - expect(foo1WriteResponse.status.code).equals(202); + expect(foo1WriteResponse.status.code).equals(204); const foo2 = await RecordsWrite.create(fooOptions); const foo2WriteResponse = await dwn.processMessage(alice.did, foo2.message, { dataStream: DataStream.fromBytes(fooData) }); - expect(foo2WriteResponse.status.code).equals(202); + expect(foo2WriteResponse.status.code).equals(204); // write 2 bars under foo1 with data large enough to be required to be stored in the data store so we can test purge in data store const barData = TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded + 1); @@ -110,11 +110,11 @@ export function testRecordsPrune(): void { const bar1 = await RecordsWrite.create({ ...barOptions }); const bar1WriteResponse = await dwn.processMessage(alice.did, bar1.message, { dataStream: DataStream.fromBytes(barData) }); - expect(bar1WriteResponse.status.code).equals(202); + expect(bar1WriteResponse.status.code).equals(204); const bar2 = await RecordsWrite.create({ ...barOptions }); const bar2WriteResponse = await dwn.processMessage(alice.did, bar2.message, { dataStream: DataStream.fromBytes(barData) }); - expect(bar2WriteResponse.status.code).equals(202); + expect(bar2WriteResponse.status.code).equals(204); // write 2 bazes under bar1, each has more than 1 message associated with the record so we can test multi-message purge const bazData = TestDataGenerator.randomBytes(100); @@ -130,11 +130,11 @@ export function testRecordsPrune(): void { const baz1 = await RecordsWrite.create({ ...bazOptions }); const baz1WriteResponse = await dwn.processMessage(alice.did, baz1.message, { dataStream: DataStream.fromBytes(bazData) }); - expect(baz1WriteResponse.status.code).equals(202); + expect(baz1WriteResponse.status.code).equals(204); const baz2 = await RecordsWrite.create({ ...bazOptions }); const baz2WriteResponse = await dwn.processMessage(alice.did, baz2.message, { dataStream: DataStream.fromBytes(bazData) }); - expect(baz2WriteResponse.status.code).equals(202); + expect(baz2WriteResponse.status.code).equals(204); // make latest state of baz1 a `RecordsWrite` const newBaz1Data = TestDataGenerator.randomBytes(100); @@ -280,7 +280,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(202); + expect(postWriteResponse.status.code).equals(204); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -294,7 +294,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(202); + expect(attachmentWriteResponse.status.code).equals(204); // 3. Verify Bob cannot prune the records if `prune` is not set to `true` in RecordsDelete. const unauthorizedPostPrune = await RecordsDelete.create({ @@ -358,7 +358,7 @@ export function testRecordsPrune(): void { const message = await RecordsWrite.create(messageOptions); const messageWriteResponse = await dwn.processMessage(alice.did, message.message, { dataStream: DataStream.fromBytes(messageData) }); - expect(messageWriteResponse.status.code).equals(202); + expect(messageWriteResponse.status.code).equals(204); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -372,7 +372,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(202); + expect(attachmentWriteResponse.status.code).equals(204); // 3. Verify Bob cannot prune the records. const messagePrune = await RecordsDelete.create({ @@ -459,7 +459,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(202); + expect(postWriteResponse.status.code).equals(204); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -473,7 +473,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(202); + expect(attachmentWriteResponse.status.code).equals(204); // 3. Verify Carol cannot prune the records if `prune` is not set to `true` in RecordsDelete. const unauthorizedPostPrune = await RecordsDelete.create({ @@ -571,7 +571,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(202); + expect(postWriteResponse.status.code).equals(204); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -585,7 +585,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(202); + expect(attachmentWriteResponse.status.code).equals(204); // 3. Verify Carol cannot prune the records. const postPrune = await RecordsDelete.create({ @@ -670,7 +670,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(202); + expect(postWriteResponse.status.code).equals(204); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -684,7 +684,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(202); + expect(attachmentWriteResponse.status.code).equals(204); // 3. Verify Bob cannot prune the records. const unauthorizedPostPrune = await RecordsDelete.create({ diff --git a/tests/features/records-tags.spec.ts b/tests/features/records-tags.spec.ts index e6a8ea717..465c8d947 100644 --- a/tests/features/records-tags.spec.ts +++ b/tests/features/records-tags.spec.ts @@ -391,7 +391,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a tag value that does not match the boolean type', async () => { @@ -452,7 +452,7 @@ export function testRecordsTags(): void { }); const fooRecord2Reply = await dwn.processMessage(alice.did, fooRecord2.message, { dataStream: fooRecord2.dataStream }); - expect(fooRecord2Reply.status.code).to.equal(202); + expect(fooRecord2Reply.status.code).to.equal(204); }); it('should reject a tag value that does not match the number type', async () => { @@ -513,7 +513,7 @@ export function testRecordsTags(): void { }); const fooRecord2Reply = await dwn.processMessage(alice.did, fooRecord2.message, { dataStream: fooRecord2.dataStream }); - expect(fooRecord2Reply.status.code).to.equal(202); + expect(fooRecord2Reply.status.code).to.equal(204); // positive tests with a decimal number const fooRecord3 = await TestDataGenerator.generateRecordsWrite({ @@ -527,7 +527,7 @@ export function testRecordsTags(): void { }); const fooRecord3Reply = await dwn.processMessage(alice.did, fooRecord3.message, { dataStream: fooRecord3.dataStream }); - expect(fooRecord3Reply.status.code).to.equal(202); + expect(fooRecord3Reply.status.code).to.equal(204); }); it('should reject a tag value that does not match the integer type', async () => { @@ -587,7 +587,7 @@ export function testRecordsTags(): void { }); const fooRecord2Reply = await dwn.processMessage(alice.did, fooRecord2.message, { dataStream: fooRecord2.dataStream }); - expect(fooRecord2Reply.status.code).to.equal(202); + expect(fooRecord2Reply.status.code).to.equal(204); }); it('should reject a record with a tag value that does not match a given enum in the protocol definition', async () => { @@ -654,7 +654,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a record with a tag value that is not within the `minimum` and `maximum` range', async () => { @@ -736,7 +736,7 @@ export function testRecordsTags(): void { // should pass const validFooMaxRecordReply = await dwn.processMessage(alice.did, validFooMaxRecord.message, { dataStream: validFooMaxRecord.dataStream }); - expect(validFooMaxRecordReply.status.code).to.equal(202); + expect(validFooMaxRecordReply.status.code).to.equal(204); // write a foo record with a maximum `score` of 0. const validFooMinRecord = await TestDataGenerator.generateRecordsWrite({ @@ -750,7 +750,7 @@ export function testRecordsTags(): void { }); // should pass const validFooMinRecordReply = await dwn.processMessage(alice.did, validFooMinRecord.message, { dataStream: validFooMinRecord.dataStream }); - expect(validFooMinRecordReply.status.code).to.equal(202); + expect(validFooMinRecordReply.status.code).to.equal(204); // write a foo record within the range const validFooRecord = await TestDataGenerator.generateRecordsWrite({ @@ -764,7 +764,7 @@ export function testRecordsTags(): void { }); // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a record with a tag value that is not within the `exclusiveMinimum` and `exclusiveMaximum` range', async () => { @@ -846,7 +846,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject tag values that are not within the `minLength` and `maxLength` values', async () => { @@ -931,7 +931,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject tag values that do not contain the number of items within the `minItems` and `maxItems` values', async () => { @@ -1017,7 +1017,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a value within an array that should only include numbers', async () => { @@ -1082,7 +1082,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a value within an array that should only include integers', async () => { @@ -1147,7 +1147,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject tag values that do not contain the number of items within the `minContains` and `maxContains` values', async () => { @@ -1241,7 +1241,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject tag values that do not follow the constraints of the `uniqueItems` value', async () => { @@ -1307,7 +1307,7 @@ export function testRecordsTags(): void { // should pass const uniqueItemsReply = await dwn.processMessage(alice.did, uniqueItemsRecord.message, { dataStream: uniqueItemsRecord.dataStream }); - expect(uniqueItemsReply.status.code).to.equal(202); + expect(uniqueItemsReply.status.code).to.equal(204); }); it('should only accept a record containing tags required by $requiredTags', async () => { @@ -1367,7 +1367,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should accept any tag if $allowUndefinedTags is set to true', async () => { @@ -1413,7 +1413,7 @@ export function testRecordsTags(): void { }); const fooRecordReply = await dwn.processMessage(alice.did, fooRecord.message, { dataStream: fooRecord.dataStream }); - expect(fooRecordReply.status.code).to.equal(202); + expect(fooRecordReply.status.code).to.equal(204); }); describe('contains', () => { @@ -1486,7 +1486,7 @@ export function testRecordsTags(): void { // should pass const validEnumReply = await dwn.processMessage(alice.did, validEnumRecord.message, { dataStream: validEnumRecord.dataStream }); - expect(validEnumReply.status.code).to.equal(202); + expect(validEnumReply.status.code).to.equal(204); }); it('should reject a record tag that does not contain a value within the `minimum` and `maximum` range ', async () => { @@ -1559,7 +1559,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a record tag that does not contain a value within the `exclusiveMinimum` and `exclusiveMaximum` range ', async () => { @@ -1632,7 +1632,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a record tag that does not contain a value within the `minLength` and `maxLength` range ', async () => { @@ -1704,7 +1704,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); }); @@ -1775,7 +1775,7 @@ export function testRecordsTags(): void { // should pass const validEnumReply = await dwn.processMessage(alice.did, validEnumRecord.message, { dataStream: validEnumRecord.dataStream }); - expect(validEnumReply.status.code).to.equal(202); + expect(validEnumReply.status.code).to.equal(204); }); it('should reject a record tag which all items do not have a value within the `minimum` and `maximum` range ', async () => { @@ -1863,7 +1863,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a record tag which all items do not have a value within the `exclusiveMinimum` and `exclusiveMaximum` range ', async () => { @@ -1951,7 +1951,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); it('should reject a record tag that does not contain a value within the `minLength` and `maxLength` range ', async () => { @@ -2038,7 +2038,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(202); + expect(validFooRecordReply.status.code).to.equal(204); }); }); }); @@ -2067,7 +2067,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); // verify the record was written const tagsRecord1Read = await RecordsRead.create({ @@ -2101,7 +2101,7 @@ export function testRecordsTags(): void { // write the record const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); // verify the record was written const tagsRecord1Read = await RecordsRead.create({ @@ -2179,7 +2179,7 @@ export function testRecordsTags(): void { // write the record const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); // verify that construct Indexes was called expect(constructIndexesSpy.callCount).to.equal(1); @@ -2221,7 +2221,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -2279,7 +2279,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); // do an exact match for the tag value const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ @@ -2343,7 +2343,7 @@ export function testRecordsTags(): void { }); const tagsRecordTrueReply = await dwn.processMessage(alice.did, tagsRecordTrue.message, { dataStream: tagsRecordTrue.dataStream }); - expect(tagsRecordTrueReply.status.code).to.equal(202); + expect(tagsRecordTrueReply.status.code).to.equal(204); // write a record with a false boolean value tag const tagsRecordFalse = await TestDataGenerator.generateRecordsWrite({ @@ -2356,7 +2356,7 @@ export function testRecordsTags(): void { }); const tagsRecordFalseReply = await dwn.processMessage(alice.did, tagsRecordFalse.message, { dataStream: tagsRecordFalse.dataStream }); - expect(tagsRecordFalseReply.status.code).to.equal(202); + expect(tagsRecordFalseReply.status.code).to.equal(204); // query for records with a `booleanTag` set to true, should return the record with the true tag const tagsQueryMatchTrue = await TestDataGenerator.generateRecordsQuery({ @@ -2443,13 +2443,13 @@ export function testRecordsTags(): void { }); const aliceReply = await dwn.processMessage(alice.did, aliceRecord.message, { dataStream: aliceRecord.dataStream }); - expect(aliceReply.status.code).to.equal(202); + expect(aliceReply.status.code).to.equal(204); const bobReply = await dwn.processMessage(alice.did, bobRecord.message, { dataStream: bobRecord.dataStream }); - expect(bobReply.status.code).to.equal(202); + expect(bobReply.status.code).to.equal(204); const carolReply = await dwn.processMessage(alice.did, carolRecord.message, { dataStream: carolRecord.dataStream }); - expect(carolReply.status.code).to.equal(202); + expect(carolReply.status.code).to.equal(204); const danielReply = await dwn.processMessage(alice.did, danielRecord.message, { dataStream: danielRecord.dataStream }); - expect(danielReply.status.code).to.equal(202); + expect(danielReply.status.code).to.equal(204); // sanity query for all const queryForAll = await TestDataGenerator.generateRecordsQuery({ @@ -2535,9 +2535,9 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); const tagsRecord2Reply = await dwn.processMessage(alice.did, tagsRecord2.message, { dataStream: tagsRecord2.dataStream }); - expect(tagsRecord2Reply.status.code).to.equal(202); + expect(tagsRecord2Reply.status.code).to.equal(204); // control record that has a different prefix const tagsRecord3 = await TestDataGenerator.generateRecordsWrite({ @@ -2549,7 +2549,7 @@ export function testRecordsTags(): void { } }); const tagsRecord3Reply = await dwn.processMessage(alice.did, tagsRecord3.message, { dataStream: tagsRecord3.dataStream }); - expect(tagsRecord3Reply.status.code).to.equal(202); + expect(tagsRecord3Reply.status.code).to.equal(204); // a prefix search will return only the records matching the prefix const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ @@ -2628,13 +2628,13 @@ export function testRecordsTags(): void { }); const aliceReply = await dwn.processMessage(alice.did, aliceRecord.message, { dataStream: aliceRecord.dataStream }); - expect(aliceReply.status.code).to.equal(202); + expect(aliceReply.status.code).to.equal(204); const bobReply = await dwn.processMessage(alice.did, bobRecord.message, { dataStream: bobRecord.dataStream }); - expect(bobReply.status.code).to.equal(202); + expect(bobReply.status.code).to.equal(204); const carolReply = await dwn.processMessage(alice.did, carolRecord.message, { dataStream: carolRecord.dataStream }); - expect(carolReply.status.code).to.equal(202); + expect(carolReply.status.code).to.equal(204); const danielReply = await dwn.processMessage(alice.did, danielRecord.message, { dataStream: danielRecord.dataStream }); - expect(danielReply.status.code).to.equal(202); + expect(danielReply.status.code).to.equal(204); // sanity query for all const queryForAll = await TestDataGenerator.generateRecordsQuery({ @@ -2726,7 +2726,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -2771,7 +2771,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -2818,7 +2818,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(202); + expect(tagsRecord1Reply.status.code).to.equal(204); //sanity: query for the record const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ diff --git a/tests/features/resumable-tasks.spec.ts b/tests/features/resumable-tasks.spec.ts index c90d090fc..5e2def69a 100644 --- a/tests/features/resumable-tasks.spec.ts +++ b/tests/features/resumable-tasks.spec.ts @@ -102,7 +102,7 @@ export function testResumableTasks(): void { const recordsWrite = await RecordsWrite.create(messageOptions); const recordsWriteResponse = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: DataStream.fromBytes(data) }); - expect(recordsWriteResponse.status.code).equals(202); + expect(recordsWriteResponse.status.code).equals(204); // 2. Insert a resumable `RecordDelete` task into the resumable task store bypassing message handler to avoid it being processed. @@ -186,7 +186,7 @@ export function testResumableTasks(): void { const recordsWrite = await RecordsWrite.create(messageOptions); const recordsWriteResponse = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: DataStream.fromBytes(data) }); - expect(recordsWriteResponse.status.code).equals(202); + expect(recordsWriteResponse.status.code).equals(204); recordsWrites.push(recordsWrite); } @@ -336,7 +336,7 @@ export function testResumableTasks(): void { const recordsWrite = await RecordsWrite.create(messageOptions); const recordsWriteResponse = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: DataStream.fromBytes(data) }); - expect(recordsWriteResponse.status.code).equals(202); + expect(recordsWriteResponse.status.code).equals(204); // 3. Submit a `RecordsDelete` without awaiting on its completion. const resumableTaskRegisterSpy = sinon.spy(resumableTaskStore, 'register'); diff --git a/tests/handlers/messages-query.spec.ts b/tests/handlers/messages-query.spec.ts index 18210faf3..b3cf16533 100644 --- a/tests/handlers/messages-query.spec.ts +++ b/tests/handlers/messages-query.spec.ts @@ -130,7 +130,7 @@ export function testMessagesQueryHandler(): void { }); const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const messageCid = await Message.getCid(message); expectedCids.push(messageCid); } @@ -154,7 +154,7 @@ export function testMessagesQueryHandler(): void { author : alice }); const additionalReply = await dwn.processMessage(alice.did, additionalMessage, { dataStream: additionalDataStream }); - expect(additionalReply.status.code).to.equal(202); + expect(additionalReply.status.code).to.equal(204); // query for messages beyond the cursor const { message: messagesAfterCursor } = await TestDataGenerator.generateMessagesQuery({ author: alice, cursor: reply.cursor }); @@ -183,7 +183,7 @@ export function testMessagesQueryHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(202); + expect(grantReply.status.code).to.equal(204); // configure the freeForAll protocol const { message: freeForAllConfigure } = await TestDataGenerator.generateProtocolsConfigure({ @@ -209,14 +209,14 @@ export function testMessagesQueryHandler(): void { }); const recordReply = await dwn.processMessage(alice.did, recordMessage, { dataStream: recordDataStream }); - expect(recordReply.status.code).to.equal(202); + expect(recordReply.status.code).to.equal(204); // write a random message const { message: randomMessage, dataStream: randomDataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const randomReply = await dwn.processMessage(alice.did, randomMessage, { dataStream: randomDataStream }); - expect(randomReply.status.code).to.equal(202); + expect(randomReply.status.code).to.equal(204); // bob uses the grant to query for all of these messages const { message: bobQuery } = await TestDataGenerator.generateMessagesQuery({ @@ -250,7 +250,7 @@ export function testMessagesQueryHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(202); + expect(grantReply.status.code).to.equal(204); // bob attempts to use the `RecordsWrite` grant on an `MessagesQuery` message const { message: bobQuery } = await TestDataGenerator.generateMessagesQuery({ @@ -277,7 +277,7 @@ export function testMessagesQueryHandler(): void { }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(202); + expect(grantReply.status.code).to.equal(204); // bob attempts to use the `MessagesSubscribe` grant on an `MessagesQuery` message const { message: bobQuery } = await TestDataGenerator.generateMessagesQuery({ @@ -325,7 +325,7 @@ export function testMessagesQueryHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(202); + expect(grant1Reply.status.code).to.equal(204); // bob uses the grant to query for protocol 1 messages const { message: bobQuery1 } = await TestDataGenerator.generateMessagesQuery({ @@ -377,7 +377,7 @@ export function testMessagesQueryHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(202); + expect(grant1Reply.status.code).to.equal(204); // bob uses the grant for protocol 1 to query for protocol 2 messages const { message: bobQuery1 } = await TestDataGenerator.generateMessagesQuery({ diff --git a/tests/handlers/messages-read.spec.ts b/tests/handlers/messages-read.spec.ts index b97f6afb9..179475a39 100644 --- a/tests/handlers/messages-read.spec.ts +++ b/tests/handlers/messages-read.spec.ts @@ -136,7 +136,7 @@ export function testMessagesReadHandler(): void { // bob creates a record that alice will try and get const { message: recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: bob }); const { status } = await dwn.processMessage(bob.did, recordsWrite, { dataStream }); - expect(status.code).to.equal(202); + expect(status.code).to.equal(204); // alice tries to read the message const { message } = await TestDataGenerator.generateMessagesRead({ @@ -159,7 +159,7 @@ export function testMessagesReadHandler(): void { }); const reply = await dwn.processMessage(alice.did, recordsWrite, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const recordsWriteMessageCid = await Message.getCid(recordsWrite); const { message } = await TestDataGenerator.generateMessagesRead({ @@ -190,7 +190,7 @@ export function testMessagesReadHandler(): void { }); const reply = await dwn.processMessage(alice.did, recordsWrite, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const recordsWriteMessageCid = await Message.getCid(recordsWrite); const { message } = await TestDataGenerator.generateMessagesRead({ @@ -224,7 +224,7 @@ export function testMessagesReadHandler(): void { const initialMessageCid = await Message.getCid(recordsWriteMessage); let reply = await dwn.processMessage(alice.did, recordsWriteMessage, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const { recordsWrite: updateMessage, dataStream: updateDataStream } = await TestDataGenerator.generateFromRecordsWrite({ author : alice, @@ -358,7 +358,7 @@ export function testMessagesReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant scoped to a RecordsWrite and the protocol const permissionGrant = await PermissionsProtocol.createGrant({ @@ -377,7 +377,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob tries to MessagesRead using the RecordsWrite grant const messagesRead = await TestDataGenerator.generateMessagesRead({ @@ -402,7 +402,7 @@ export function testMessagesReadHandler(): void { author: alice, }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const messageCid = await Message.getCid(message); // Alice issues a permission grant allowing Bob to read any record in her DWN @@ -417,7 +417,7 @@ export function testMessagesReadHandler(): void { }); const grantDataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const grantReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream: grantDataStream }); - expect(grantReply.status.code).to.equal(202); + expect(grantReply.status.code).to.equal(204); // Bob invokes that grant to read a record from Alice's DWN const messagesRead = await TestDataGenerator.generateMessagesRead({ @@ -478,7 +478,7 @@ export function testMessagesReadHandler(): void { permissionRequestCarol.recordsWrite.message, { dataStream: requestDataStreamCarol } ); - expect(permissionRequestWriteReplyCarol.status.code).to.equal(202); + expect(permissionRequestWriteReplyCarol.status.code).to.equal(204); // Alice gives Carol a grant to write records to the protocol const permissionGrantCarol = await PermissionsProtocol.createGrant({ @@ -495,7 +495,7 @@ export function testMessagesReadHandler(): void { permissionGrantCarol.recordsWrite.message, { dataStream: grantDataStreamCarol } ); - expect(permissionGrantWriteReplyCarol.status.code).to.equal(202); + expect(permissionGrantWriteReplyCarol.status.code).to.equal(204); const carolGrantMessageCiD = await Message.getCid(permissionGrantCarol.recordsWrite.message); // Alice writes a record associated with the protocol @@ -505,7 +505,7 @@ export function testMessagesReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); const aliceRecordMessageCid = await Message.getCid(recordsWrite.message); // Alice deletes a record associated with the protocol @@ -524,7 +524,7 @@ export function testMessagesReadHandler(): void { permissionGrantId : permissionGrantCarol.recordsWrite.message.recordId, }); const recordsWriteReplyCarol = await dwn.processMessage(alice.did, recordsWriteCarol.message, { dataStream: dataStreamCarol }); - expect(recordsWriteReplyCarol.status.code).to.equal(202); + expect(recordsWriteReplyCarol.status.code).to.equal(204); const carolRecordMessageCid = await Message.getCid(recordsWriteCarol.message); // Alice revokes Carol's grant @@ -538,7 +538,7 @@ export function testMessagesReadHandler(): void { permissionRevocationCarol.recordsWrite.message, { dataStream: permissionRevocationCarolDataStream } ); - expect(permissionRevocationCarolReply.status.code).to.equal(202); + expect(permissionRevocationCarolReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope MessagesRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -557,7 +557,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the message without using the permission grant const messagesReadWithoutGrant = await TestDataGenerator.generateMessagesRead({ @@ -660,7 +660,7 @@ export function testMessagesReadHandler(): void { author: alice, }); const recordsWriteControlReply = await dwn.processMessage(alice.did, recordsWriteControl.message, { dataStream: dataStreamControl }); - expect(recordsWriteControlReply.status.code).to.equal(202); + expect(recordsWriteControlReply.status.code).to.equal(204); // Bob is unable to read the control message const messagesReadControl = await TestDataGenerator.generateMessagesRead({ @@ -696,7 +696,7 @@ export function testMessagesReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope MessagesRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -715,7 +715,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record using the mismatched permission grant const messagesReadWithoutGrant = await TestDataGenerator.generateMessagesRead({ @@ -761,7 +761,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Alice creates the records write and records delete messages const { recordsWrite } = await TestDataGenerator.generateRecordsWrite({ diff --git a/tests/handlers/messages-subscribe.spec.ts b/tests/handlers/messages-subscribe.spec.ts index 953c3c98e..37bbd975f 100644 --- a/tests/handlers/messages-subscribe.spec.ts +++ b/tests/handlers/messages-subscribe.spec.ts @@ -165,7 +165,7 @@ export function testMessagesSubscribeHandler(): void { const messageWrite = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, messageWrite.message, { dataStream: messageWrite.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const messageCid = await Message.getCid(messageWrite.message); // control: ensure that the event exists @@ -219,7 +219,7 @@ export function testMessagesSubscribeHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(202); + expect(grantReply.status.code).to.equal(204); // create a handler to capture the emitted messageCids const messageCids: string[] = []; @@ -262,14 +262,14 @@ export function testMessagesSubscribeHandler(): void { }); const recordReply = await dwn.processMessage(alice.did, recordMessage, { dataStream: recordDataStream }); - expect(recordReply.status.code).to.equal(202); + expect(recordReply.status.code).to.equal(204); // write a random message const { message: randomMessage, dataStream: randomDataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const randomReply = await dwn.processMessage(alice.did, randomMessage, { dataStream: randomDataStream }); - expect(randomReply.status.code).to.equal(202); + expect(randomReply.status.code).to.equal(204); // ensure that all messages have been received await Poller.pollUntilSuccessOrTimeout(async () => { @@ -298,7 +298,7 @@ export function testMessagesSubscribeHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(202); + expect(grantReply.status.code).to.equal(204); // bob attempts to use the `RecordsWrite` grant on an `MessagesSubscribe` message const { message: bobSubscribe } = await TestDataGenerator.generateMessagesSubscribe({ @@ -324,7 +324,7 @@ export function testMessagesSubscribeHandler(): void { } }); const grantWriteReply = await dwn.processMessage(alice.did, grantWrite.message, { dataStream }); - expect(grantWriteReply.status.code).to.equal(202); + expect(grantWriteReply.status.code).to.equal(204); // bob attempts to use the `MessagesQuery` grant on an `MessagesSubscribe` message @@ -373,7 +373,7 @@ export function testMessagesSubscribeHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(202); + expect(grant1Reply.status.code).to.equal(204); // bob uses the grant to subscribe to protocol 1 messages const proto1MessageCids: string[] = []; @@ -412,7 +412,7 @@ export function testMessagesSubscribeHandler(): void { author : alice }); const proto1Reply = await dwn.processMessage(alice.did, proto1Message, { dataStream: proto1DataStream }); - expect(proto1Reply.status.code).to.equal(202); + expect(proto1Reply.status.code).to.equal(204); // alice writes a message to protocol 2 const { message: proto2Message, dataStream: proto2DataStream } = await TestDataGenerator.generateRecordsWrite({ @@ -422,7 +422,7 @@ export function testMessagesSubscribeHandler(): void { author : alice }); const proto2Reply = await dwn.processMessage(alice.did, proto2Message, { dataStream: proto2DataStream }); - expect(proto2Reply.status.code).to.equal(202); + expect(proto2Reply.status.code).to.equal(204); // ensure that all messages have been received as a control await Poller.pollUntilSuccessOrTimeout(async () => { @@ -473,7 +473,7 @@ export function testMessagesSubscribeHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(202); + expect(grant1Reply.status.code).to.equal(204); // bob uses the grant for protocol 1 to subscribe for protocol 2 messages const { message: bobSubscribe1 } = await TestDataGenerator.generateMessagesSubscribe({ diff --git a/tests/handlers/protocols-query.spec.ts b/tests/handlers/protocols-query.spec.ts index eaf9f472e..dd59691b0 100644 --- a/tests/handlers/protocols-query.spec.ts +++ b/tests/handlers/protocols-query.spec.ts @@ -249,7 +249,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const grantRecordsWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(grantRecordsWriteReply.status.code).to.equal(202); + expect(grantRecordsWriteReply.status.code).to.equal(204); // 2. Verify Bob can perform a ProtocolsQuery const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -281,7 +281,7 @@ export function testProtocolsQueryHandler(): void { revokeWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeWrite.permissionRevocationBytes) } ); - expect(revokeWriteReply.status.code).to.equal(202); + expect(revokeWriteReply.status.code).to.equal(204); // 5. Verify Bob cannot perform ProtocolsQuery with the revoked grant const unauthorizedProtocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -309,7 +309,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const permissionGrantWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob does ProtocolsQuery after the grant has expired const protocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -342,7 +342,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const permissionGrantWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob does ProtocolsQuery but his message has timestamp before the grant is active const protocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -371,7 +371,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const grantRecordsWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(grantRecordsWriteReply.status.code).to.equal(202); + expect(grantRecordsWriteReply.status.code).to.equal(204); // Bob tries to ProtocolsQuery const protocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -422,7 +422,7 @@ export function testProtocolsQueryHandler(): void { await bobWrappedGrant.signAsOwner(Jws.createSigner(bob)); const grantRecordsWriteReply = await dwn.processMessage(bob.did, bobWrappedGrant.message, { dataStream }); - expect(grantRecordsWriteReply.status.code).to.equal(202); + expect(grantRecordsWriteReply.status.code).to.equal(204); // 3. Verify that Carol cannot use permission grant to gain access to Bob's DWN const permissionGrantId = permissionGrant.recordsWrite.message.recordId; diff --git a/tests/handlers/records-delete.spec.ts b/tests/handlers/records-delete.spec.ts index 36c2bacb1..6e3e008cc 100644 --- a/tests/handlers/records-delete.spec.ts +++ b/tests/handlers/records-delete.spec.ts @@ -83,7 +83,7 @@ export function testRecordsDeleteHandler(): void { // insert data const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // ensure data is inserted const queryData = await TestDataGenerator.generateRecordsQuery({ @@ -127,22 +127,22 @@ export function testRecordsDeleteHandler(): void { // alice writes a records with data const aliceWriteData = await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const aliceWriteReply = await dwn.processMessage(alice.did, aliceWriteData.message, { dataStream: aliceWriteData.dataStream }); - expect(aliceWriteReply.status.code).to.equal(202); + expect(aliceWriteReply.status.code).to.equal(204); // alice writes another record with the same data const aliceWrite2Data = await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const aliceWrite2Reply = await dwn.processMessage(alice.did, aliceWrite2Data.message, { dataStream: aliceWrite2Data.dataStream }); - expect(aliceWrite2Reply.status.code).to.equal(202); + expect(aliceWrite2Reply.status.code).to.equal(204); // bob writes a records with same data const bobWriteData = await TestDataGenerator.generateRecordsWrite({ author: bob, data }); const bobWriteReply = await dwn.processMessage(bob.did, bobWriteData.message, { dataStream: bobWriteData.dataStream }); - expect(bobWriteReply.status.code).to.equal(202); + expect(bobWriteReply.status.code).to.equal(204); // bob writes another record with the same data const bobWrite2Data = await TestDataGenerator.generateRecordsWrite({ author: bob, data }); const bobWrite2Reply = await dwn.processMessage(bob.did, bobWrite2Data.message, { dataStream: bobWrite2Data.dataStream }); - expect(bobWrite2Reply.status.code).to.equal(202); + expect(bobWrite2Reply.status.code).to.equal(204); // alice deletes one of the two records const aliceDeleteWriteData = await TestDataGenerator.generateRecordsDelete({ @@ -212,7 +212,7 @@ export function testRecordsDeleteHandler(): void { // initial write const initialWriteData = await TestDataGenerator.generateRecordsWrite({ author: alice }); const initialWriteReply = await dwn.processMessage(alice.did, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); // generate subsequent write and delete with the delete having an earlier timestamp // NOTE: creating RecordsDelete first ensures it has an earlier `messageTimestamp` time @@ -257,7 +257,7 @@ export function testRecordsDeleteHandler(): void { data }); const aliceWriteReply = await dwn.processMessage(alice.did, aliceWriteData.message, { dataStream: aliceWriteData.dataStream }); - expect(aliceWriteReply.status.code).to.equal(202); + expect(aliceWriteReply.status.code).to.equal(204); const aliceQueryWriteAfterAliceWriteData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -290,7 +290,7 @@ export function testRecordsDeleteHandler(): void { data }); const aliceRewriteReply = await dwn.processMessage(alice.did, aliceRewriteData.message, { dataStream: aliceRewriteData.dataStream }); - expect(aliceRewriteReply.status.code).to.equal(202); + expect(aliceRewriteReply.status.code).to.equal(204); const aliceQueryWriteAfterAliceRewriteData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -328,7 +328,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'doc', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.eq(202); + expect(recordsWriteReply.status.code).to.eq(204); // Bob (anyone) is able to delete the record const recordsDelete = await TestDataGenerator.generateRecordsDelete({ @@ -368,7 +368,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'post', }); const chatRecordsWriteReply = await dwn.processMessage(alice.did, chatRecordsWrite.message, { dataStream: chatRecordsWrite.dataStream }); - expect(chatRecordsWriteReply.status.code).to.eq(202); + expect(chatRecordsWriteReply.status.code).to.eq(204); // Alice writes a 'chat/tag' const tagRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -378,7 +378,7 @@ export function testRecordsDeleteHandler(): void { parentContextId : chatRecordsWrite.message.contextId, }); const tagRecordsWriteReply = await dwn.processMessage(alice.did, tagRecordsWrite.message, { dataStream: tagRecordsWrite.dataStream }); - expect(tagRecordsWriteReply.status.code).to.eq(202); + expect(tagRecordsWriteReply.status.code).to.eq(204); // Carol is unable to delete the 'chat/tag' const recordsDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -426,7 +426,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'post', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.eq(202); + expect(recordsWriteReply.status.code).to.eq(204); // Carol is unable to delete the 'post' const carolRecordsDelete = await TestDataGenerator.generateRecordsDelete({ @@ -475,7 +475,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'post', }); const postRecordsWriteReply = await dwn.processMessage(alice.did, postRecordsWrite.message, { dataStream: postRecordsWrite.dataStream }); - expect(postRecordsWriteReply.status.code).to.eq(202); + expect(postRecordsWriteReply.status.code).to.eq(204); // Alice writes a 'post/comment' const commentRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -486,7 +486,7 @@ export function testRecordsDeleteHandler(): void { }); const commentRecordsWriteReply = await dwn.processMessage(alice.did, commentRecordsWrite.message, { dataStream: commentRecordsWrite.dataStream }); - expect(commentRecordsWriteReply.status.code).to.eq(202); + expect(commentRecordsWriteReply.status.code).to.eq(204); // Carol is unable to delete Alice's 'post/comment' const recordsDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -534,7 +534,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(202); + expect(threadRecordReply.status.code).to.equal(204); // Alice adds Bob as a 'thread/admin' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -546,7 +546,7 @@ export function testRecordsDeleteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Alice writes a chat message in that thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -557,7 +557,7 @@ export function testRecordsDeleteHandler(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Verifies that Carol cannot delete without appropriate role const chatDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -604,7 +604,7 @@ export function testRecordsDeleteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Alice writes a chat message in that thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -614,7 +614,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'chat', }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Carol is unable to delete the chat message const chatDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -647,7 +647,7 @@ export function testRecordsDeleteHandler(): void { author: alice, }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); const recordsDelete = await TestDataGenerator.generateRecordsDelete({ author : bob, @@ -664,7 +664,7 @@ export function testRecordsDeleteHandler(): void { // initial write const initialWriteData = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'testSchema' }); const initialWriteReply = await dwn.processMessage(alice.did, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); // generate subsequent write and delete with the delete having an earlier timestamp // NOTE: creating RecordsDelete first ensures it has an earlier `messageTimestamp` time @@ -694,7 +694,7 @@ export function testRecordsDeleteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const recordsDelete = await RecordsDelete.create({ recordId : message.recordId, @@ -723,7 +723,7 @@ export function testRecordsDeleteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(author.did, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const newWrite = await RecordsWrite.createFrom({ recordsWriteMessage : recordsWrite.message, diff --git a/tests/handlers/records-query.spec.ts b/tests/handlers/records-query.spec.ts index d528114bf..e328a49f4 100644 --- a/tests/handlers/records-query.spec.ts +++ b/tests/handlers/records-query.spec.ts @@ -104,7 +104,7 @@ export function testRecordsQueryHandler(): void { const write = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [bob], dataFormat }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const query = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { dataFormat } }); const reply = await dwn.processMessage(alice.did, query.message); @@ -133,9 +133,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // testing singular conditional query const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { dataFormat } }); @@ -166,7 +166,7 @@ export function testRecordsQueryHandler(): void { const write= await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { recordId: write.message.recordId } }); const reply = await dwn.processMessage(alice.did, messageData.message); @@ -182,7 +182,7 @@ export function testRecordsQueryHandler(): void { const write= await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { recordId: write.message.recordId } }); const reply = await dwn.processMessage(alice.did, messageData.message); @@ -197,7 +197,7 @@ export function testRecordsQueryHandler(): void { const write = await TestDataGenerator.generateRecordsWrite({ author: alice, published: false }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // write an update to the record const write2 = await RecordsWrite.createFrom({ recordsWriteMessage: write.message, published: true, signer: Jws.createSigner(alice) }); @@ -225,8 +225,8 @@ export function testRecordsQueryHandler(): void { // insert data const writeReply1 = await dwn.processMessage(alice.did, recordsWrite1.message, { dataStream: recordsWrite1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, recordsWrite2.message, { dataStream: recordsWrite2.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); // testing attester filter const recordsQuery1 = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { attester: alice.did } }); @@ -275,7 +275,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'post' }); const aliceAuthorReply = await dwn.processMessage(alice.did, aliceAuthorWrite.message, { dataStream: aliceAuthorWrite.dataStream }); - expect(aliceAuthorReply.status.code).to.equal(202); + expect(aliceAuthorReply.status.code).to.equal(204); const bobAuthorWrite = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -285,7 +285,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'post' }); const bobAuthorReply = await dwn.processMessage(alice.did, bobAuthorWrite.message, { dataStream: bobAuthorWrite.dataStream }); - expect(bobAuthorReply.status.code).to.equal(202); + expect(bobAuthorReply.status.code).to.equal(204); // alice queries with an empty filter, gets both let recordsQuery = await TestDataGenerator.generateRecordsQuery({ @@ -325,12 +325,12 @@ export function testRecordsQueryHandler(): void { // create a published record const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' }); const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream }); - expect(publishedWriteReply.status.code).to.equal(202); + expect(publishedWriteReply.status.code).to.equal(204); // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(202); + expect(draftWriteReply.status.code).to.equal(204); // query for only published records const publishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: true } }); @@ -392,12 +392,12 @@ export function testRecordsQueryHandler(): void { // create a published record const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' }); const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream }); - expect(publishedWriteReply.status.code).to.equal(202); + expect(publishedWriteReply.status.code).to.equal(204); // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(202); + expect(draftWriteReply.status.code).to.equal(204); // query for only unpublished records const unpublishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: false } }); @@ -428,12 +428,12 @@ export function testRecordsQueryHandler(): void { // create a published record const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' }); const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream }); - expect(publishedWriteReply.status.code).to.equal(202); + expect(publishedWriteReply.status.code).to.equal(204); // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(202); + expect(draftWriteReply.status.code).to.equal(204); // bob queries for unpublished records returns zero const unpublishedNotOwner = await TestDataGenerator.generateRecordsQuery({ author: bob, filter: { schema: 'post', published: false } }); @@ -474,7 +474,7 @@ export function testRecordsQueryHandler(): void { // create a record const writeRecord = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeRecordReply = await dwn.processMessage(alice.did, writeRecord.message, { dataStream: writeRecord.dataStream }); - expect(writeRecordReply.status.code).to.equal(202); + expect(writeRecordReply.status.code).to.equal(204); const recordDataCid = writeRecord.message.descriptor.dataCid; // query for the record by it's dataCid @@ -495,9 +495,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // testing gt const recordsQuery1 = await TestDataGenerator.generateRecordsQuery({ @@ -569,9 +569,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // testing range using gt & lt const recordsQuery1 = await TestDataGenerator.generateRecordsQuery({ @@ -627,9 +627,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // testing `from` range const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -700,9 +700,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // confirm range before un-publishing. const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -818,9 +818,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // testing `from` range const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -919,9 +919,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // update to published const write1Update = await RecordsWrite.createFrom({ @@ -1022,9 +1022,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // testing range criterion with another exact match const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -1051,7 +1051,7 @@ export function testRecordsQueryHandler(): void { sinon.stub(didResolver, 'resolve').resolves(mockResolution); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const queryData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -1071,7 +1071,7 @@ export function testRecordsQueryHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [alice] }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const queryData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -1105,8 +1105,8 @@ export function testRecordsQueryHandler(): void { const publishedWriteReply = await dwn.processMessage(alice.did, publishedWriteData.message, { dataStream: publishedWriteData.dataStream }); const unpublishedWriteReply = await dwn.processMessage(alice.did, unpublishedWriteData.message, { dataStream: unpublishedWriteData.dataStream }); - expect(publishedWriteReply.status.code).to.equal(202); - expect(unpublishedWriteReply.status.code).to.equal(202); + expect(publishedWriteReply.status.code).to.equal(204); + expect(unpublishedWriteReply.status.code).to.equal(204); // test published date ascending sort does not include any records that are not published const publishedAscendingQueryData = await TestDataGenerator.generateRecordsQuery({ @@ -1148,9 +1148,9 @@ export function testRecordsQueryHandler(): void { const writeReply2 = await dwn.processMessage(alice.did, write2Data.message, { dataStream: write2Data.dataStream }); const writeReply1 = await dwn.processMessage(alice.did, write1Data.message, { dataStream: write1Data.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3Data.message, { dataStream: write3Data.dataStream }); - expect(writeReply1.status.code).to.equal(202); - expect(writeReply2.status.code).to.equal(202); - expect(writeReply3.status.code).to.equal(202); + expect(writeReply1.status.code).to.equal(204); + expect(writeReply2.status.code).to.equal(204); + expect(writeReply3.status.code).to.equal(204); // createdAscending test let createdAscendingQueryData = await TestDataGenerator.generateRecordsQuery({ @@ -1305,11 +1305,11 @@ export function testRecordsQueryHandler(): void { // intentionally write the RecordsWrite of out lexicographical order to avoid the test query below accidentally having the correct order const reply2 = await dwn.processMessage(alice.did, middleWrite.message, { dataStream: middleWrite.dataStream }); - expect(reply2.status.code).to.equal(202); + expect(reply2.status.code).to.equal(204); const reply3 = await dwn.processMessage(alice.did, newestWrite.message, { dataStream: newestWrite.dataStream }); - expect(reply3.status.code).to.equal(202); + expect(reply3.status.code).to.equal(204); const reply1 = await dwn.processMessage(alice.did, oldestWrite.message, { dataStream: oldestWrite.dataStream }); - expect(reply1.status.code).to.equal(202); + expect(reply1.status.code).to.equal(204); const queryMessageData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -1346,7 +1346,7 @@ export function testRecordsQueryHandler(): void { }))); for (const message of messages) { const result = await dwn.processMessage(alice.did, message.message, { dataStream: message.dataStream }); - expect(result.status.code).to.equal(202); + expect(result.status.code).to.equal(204); } const limit = 5; @@ -1387,7 +1387,7 @@ export function testRecordsQueryHandler(): void { }))); for (const message of messages) { const result = await dwn.processMessage(alice.did, message.message, { dataStream: message.dataStream }); - expect(result.status.code).to.equal(202); + expect(result.status.code).to.equal(204); } const limit = 5; @@ -1432,9 +1432,9 @@ export function testRecordsQueryHandler(): void { ); const recordsWrite1Reply = await dwn.processMessage(alice.did, record1Data.message, { dataStream: record1Data.dataStream }); - expect(recordsWrite1Reply.status.code).to.equal(202); + expect(recordsWrite1Reply.status.code).to.equal(204); const recordsWrite2Reply = await dwn.processMessage(alice.did, record2Data.message, { dataStream: record2Data.dataStream }); - expect(recordsWrite2Reply.status.code).to.equal(202); + expect(recordsWrite2Reply.status.code).to.equal(204); // test correctness for anonymous query const anonymousQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -1732,7 +1732,7 @@ export function testRecordsQueryHandler(): void { ); const result1 = await dwn.processMessage(alice.did, unpublishedRecordsWrite.message, { dataStream: unpublishedRecordsWrite.dataStream }); - expect(result1.status.code).to.equal(202); + expect(result1.status.code).to.equal(204); // alice should be able to see the unpublished record const queryByAlice = await TestDataGenerator.generateRecordsQuery({ @@ -1860,7 +1860,7 @@ export function testRecordsQueryHandler(): void { // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(202); + expect(draftWriteReply.status.code).to.equal(204); // validate that alice can query const unpublishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: false } }); @@ -1911,11 +1911,11 @@ export function testRecordsQueryHandler(): void { const foo1 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: foo1.dataStream }); - expect(foo1WriteResponse.status.code).equals(202); + expect(foo1WriteResponse.status.code).equals(204); const foo2 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo2WriteResponse = await dwn.processMessage(alice.did, foo2.message, { dataStream: foo2.dataStream }); - expect(foo2WriteResponse.status.code).equals(202); + expect(foo2WriteResponse.status.code).equals(204); // write 2 bars under foo1 const barOptions = { @@ -1929,11 +1929,11 @@ export function testRecordsQueryHandler(): void { const bar1 = await TestDataGenerator.generateRecordsWrite(barOptions); const bar1WriteResponse = await dwn.processMessage(alice.did, bar1.message, { dataStream: bar1.dataStream }); - expect(bar1WriteResponse.status.code).equals(202); + expect(bar1WriteResponse.status.code).equals(204); const bar2 = await TestDataGenerator.generateRecordsWrite(barOptions); const bar2WriteResponse = await dwn.processMessage(alice.did, bar2.message, { dataStream: bar2.dataStream }); - expect(bar2WriteResponse.status.code).equals(202); + expect(bar2WriteResponse.status.code).equals(204); // write 2 bazes under bar1 const bazOptions = { @@ -1947,11 +1947,11 @@ export function testRecordsQueryHandler(): void { const baz1 = await TestDataGenerator.generateRecordsWrite(bazOptions); const baz1WriteResponse = await dwn.processMessage(alice.did, baz1.message, { dataStream: baz1.dataStream }); - expect(baz1WriteResponse.status.code).equals(202); + expect(baz1WriteResponse.status.code).equals(204); const baz2 = await TestDataGenerator.generateRecordsWrite(bazOptions); const baz2WriteResponse = await dwn.processMessage(alice.did, baz2.message, { dataStream: baz2.dataStream }); - expect(baz2WriteResponse.status.code).equals(202); + expect(baz2WriteResponse.status.code).equals(204); // 2. Alice should be able to query for all messages under foo1 @@ -2020,7 +2020,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Alice writes one 'chat' record addressed to Bob const chatRecordForBob = await TestDataGenerator.generateRecordsWrite({ @@ -2033,7 +2033,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatRecordForBobReply = await dwn.processMessage(alice.did, chatRecordForBob.message, { dataStream: chatRecordForBob.dataStream }); - expect(chatRecordForBobReply.status.code).to.equal(202); + expect(chatRecordForBobReply.status.code).to.equal(204); // Alice writes two 'chat' records NOT addressed to Bob for (let i = 0; i < 2; i++) { @@ -2047,7 +2047,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob cannot read this'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); } // Bob queries without invoking any protocolRole @@ -2102,7 +2102,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2116,7 +2116,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } @@ -2172,7 +2172,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Alice writes a 'participant' role record with Bob as recipient const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2185,7 +2185,7 @@ export function testRecordsQueryHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2200,7 +2200,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } @@ -2245,7 +2245,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2259,7 +2259,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } @@ -2299,7 +2299,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Alice writes a 'friend' root-level role record with Bob as recipient const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2312,7 +2312,7 @@ export function testRecordsQueryHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2327,7 +2327,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } @@ -2374,7 +2374,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } @@ -2413,7 +2413,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2428,7 +2428,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } diff --git a/tests/handlers/records-read.spec.ts b/tests/handlers/records-read.spec.ts index 7bddd5f98..c92c0f089 100644 --- a/tests/handlers/records-read.spec.ts +++ b/tests/handlers/records-read.spec.ts @@ -85,7 +85,7 @@ export function testRecordsReadHandler(): void { // insert data const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // testing RecordsRead const recordsRead = await RecordsRead.create({ @@ -111,7 +111,7 @@ export function testRecordsReadHandler(): void { // insert data const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // testing RecordsRead const bob = await TestDataGenerator.generateDidKeyPersona(); @@ -133,7 +133,7 @@ export function testRecordsReadHandler(): void { // insert public data const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // testing public RecordsRead const recordsRead = await RecordsRead.create({ @@ -156,7 +156,7 @@ export function testRecordsReadHandler(): void { // insert public data const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // testing public RecordsRead const bob = await TestDataGenerator.generateDidKeyPersona(); @@ -185,7 +185,7 @@ export function testRecordsReadHandler(): void { recipient : bob.did, }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // Bob reads the data that Alice sent him const recordsRead = await RecordsRead.create({ @@ -209,7 +209,7 @@ export function testRecordsReadHandler(): void { const write = await TestDataGenerator.generateRecordsWrite({ author: alice, published: false }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // write an update to the record const write2 = await RecordsWrite.createFrom({ recordsWriteMessage: write.message, published: true, signer: Jws.createSigner(alice) }); @@ -255,7 +255,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(202); + expect(imageReply.status.code).to.equal(204); // Bob (anyone) reads the image that Alice wrote const imageRecordsRead = await RecordsRead.create({ @@ -295,7 +295,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('foo') }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Anonymous tries and fails to read Alice's message const recordsRead = await RecordsRead.create({ @@ -339,7 +339,7 @@ export function testRecordsReadHandler(): void { recipient : bob.did }); const imageReply = await dwn.processMessage(alice.did, emailRecordsWrite.message, { dataStream: emailRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(202); + expect(imageReply.status.code).to.equal(204); // Bob reads Alice's email const bobRecordsRead = await RecordsRead.create({ @@ -394,7 +394,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const imageReply = await dwn.processMessage(alice.did, emailRecordsWrite.message, { dataStream: emailRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(202); + expect(imageReply.status.code).to.equal(204); // Bob reads the email he just sent const bobRecordsRead = await RecordsRead.create({ @@ -441,7 +441,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const foo1WriteReply = await dwn.processMessage(alice.did, foo1Write.message, { dataStream: foo1Write.dataStream }); - expect(foo1WriteReply.status.code).to.equal(202); + expect(foo1WriteReply.status.code).to.equal(204); const fooPathRead = await RecordsRead.create({ filter: { @@ -477,7 +477,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const foo1WriteReply = await dwn.processMessage(alice.did, foo1Write.message, { dataStream: foo1Write.dataStream }); - expect(foo1WriteReply.status.code).to.equal(202); + expect(foo1WriteReply.status.code).to.equal(204); const foo2Write = await TestDataGenerator.generateRecordsWrite({ author : alice, @@ -489,7 +489,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const foo2WriteReply = await dwn.processMessage(alice.did, foo2Write.message, { dataStream: foo2Write.dataStream }); - expect(foo2WriteReply.status.code).to.equal(202); + expect(foo2WriteReply.status.code).to.equal(204); // Since there are two 'foo' records, this should fail. const fooPathRead = await RecordsRead.create({ @@ -531,7 +531,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Alice writes a 'chat' record const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -542,7 +542,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); // Bob reads Alice's chat record const readChatRecord = await RecordsRead.create({ @@ -582,7 +582,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Blah blah blah'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); // Bob tries to invoke a 'chat' role but 'chat' is not a role const readChatRecord = await RecordsRead.create({ @@ -622,7 +622,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Blah blah blah'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); // Bob tries to invoke a 'friend' role but he is not a 'friend' const readChatRecord = await RecordsRead.create({ @@ -660,7 +660,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(202); + expect(threadRecordReply.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -672,7 +672,7 @@ export function testRecordsReadHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Alice writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -682,7 +682,7 @@ export function testRecordsReadHandler(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Bob is able to read his own 'participant' role // He doesn't need to invoke the role because recipients of a record are always authorized to read it @@ -744,7 +744,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'thread' }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord1.message, { dataStream: threadRecord1.dataStream }); - expect(threadRecordReply1.status.code).to.equal(202); + expect(threadRecordReply1.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -756,7 +756,7 @@ export function testRecordsReadHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Alice creates a second thread const threadRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -766,7 +766,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'thread' }); const threadRecordReply2 = await dwn.processMessage(alice.did, threadRecord2.message, { dataStream: threadRecord2.dataStream }); - expect(threadRecordReply2.status.code).to.equal(202); + expect(threadRecordReply2.status.code).to.equal(204); // Alice writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -776,7 +776,7 @@ export function testRecordsReadHandler(): void { parentContextId : threadRecord2.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Bob invokes his 'participant' role to read the chat message const chatRead = await RecordsRead.create({ @@ -805,7 +805,7 @@ export function testRecordsReadHandler(): void { author: alice, }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -824,7 +824,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob tries to RecordsRead const recordsRead = await RecordsRead.create({ @@ -864,7 +864,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -883,7 +883,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record without using the permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -933,7 +933,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -952,7 +952,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record without using the permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1001,7 +1001,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1020,7 +1020,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1058,7 +1058,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1078,7 +1078,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1115,7 +1115,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1135,7 +1135,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1173,7 +1173,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1193,7 +1193,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1230,7 +1230,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1250,7 +1250,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1287,7 +1287,7 @@ export function testRecordsReadHandler(): void { // insert public data const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // ensure data is inserted const queryData = await TestDataGenerator.generateRecordsQuery({ @@ -1331,7 +1331,7 @@ export function testRecordsReadHandler(): void { data : TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded +1) }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // testing RecordsRead const recordsRead = await RecordsRead.create({ @@ -1356,7 +1356,7 @@ export function testRecordsReadHandler(): void { }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const recordRead = await RecordsRead.create({ filter: { @@ -1387,7 +1387,7 @@ export function testRecordsReadHandler(): void { }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const recordRead = await RecordsRead.create({ filter: { @@ -1471,7 +1471,7 @@ export function testRecordsReadHandler(): void { }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const recordsRead = await RecordsRead.create({ filter: { @@ -1559,7 +1559,7 @@ export function testRecordsReadHandler(): void { const dataStream = DataStream.fromBytes(encryptedDataBytes); const writeReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); const recordsRead = await RecordsRead.create({ filter: { @@ -1642,7 +1642,7 @@ export function testRecordsReadHandler(): void { // Bob writes the encrypted chat thread to Alice's DWN const bobToAliceWriteReply = await dwn.processMessage(alice.did, threadMessage, { dataStream }); - expect(bobToAliceWriteReply.status.code).to.equal(202); + expect(bobToAliceWriteReply.status.code).to.equal(204); // Bob also needs to write the same encrypted chat thread to his own DWN // Opportunity here to create a much nicer utility method for this entire block @@ -1675,7 +1675,7 @@ export function testRecordsReadHandler(): void { const dataStreamForBobsDwn = DataStream.fromBytes(encryptedDataBytes); const bobToBobWriteReply = await dwn.processMessage(bob.did, bobToBobRecordsWrite.message, { dataStream: dataStreamForBobsDwn }); - expect(bobToBobWriteReply.status.code).to.equal(202); + expect(bobToBobWriteReply.status.code).to.equal(204); // NOTE: we know Alice is able to decrypt the message using protocol-path derived key through other tests, so we won't verify it again @@ -1720,7 +1720,7 @@ export function testRecordsReadHandler(): void { // Alice sends the message to Bob const aliceWriteReply = await dwn.processMessage(bob.did, recordsWriteToBob.message, { dataStream: recordsWriteToBob.dataStream }); - expect(aliceWriteReply.status.code).to.equal(202); + expect(aliceWriteReply.status.code).to.equal(204); // test that Bob is able to read and decrypt Alice's message const recordsReadByBob = await RecordsRead.create({ @@ -1810,7 +1810,7 @@ export function testRecordsReadHandler(): void { // Bob writes the encrypted email to Alice's DWN const bobWriteReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(bobWriteReply.status.code).to.equal(202); + expect(bobWriteReply.status.code).to.equal(204); // Alice reads the encrypted email // assume Alice already made query to get the `recordId` of the email diff --git a/tests/handlers/records-subscribe.spec.ts b/tests/handlers/records-subscribe.spec.ts index fc5c156ca..be646ec29 100644 --- a/tests/handlers/records-subscribe.spec.ts +++ b/tests/handlers/records-subscribe.spec.ts @@ -208,7 +208,7 @@ export function testRecordsSubscribeHandler(): void { // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(202); + expect(draftWriteReply.status.code).to.equal(204); // validate that alice can subscribe const unpublishedPostSubscribe = await TestDataGenerator.generateRecordsSubscribe({ author: alice, filter: { schema: 'post', published: false } }); @@ -322,7 +322,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Alice writes one 'chat' record addressed to Bob const chatRecordForBob = await TestDataGenerator.generateRecordsWrite({ @@ -335,7 +335,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatRecordForBobReply = await dwn.processMessage(alice.did, chatRecordForBob.message, { dataStream: chatRecordForBob.dataStream }); - expect(chatRecordForBobReply.status.code).to.equal(202); + expect(chatRecordForBobReply.status.code).to.equal(204); const chatRecordForBobCid = await Message.getCid(chatRecordForBob.message); // Alice writes two 'chat' records addressed to Carol @@ -353,7 +353,7 @@ export function testRecordsSubscribeHandler(): void { chatRecordForCarol1.message, { dataStream: chatRecordForCarol1.dataStream } ); - expect(chatRecordForCarol1Reply.status.code).to.equal(202); + expect(chatRecordForCarol1Reply.status.code).to.equal(204); const chatRecordForCarol1Cid = await Message.getCid(chatRecordForCarol1.message); const chatRecordForCarol2 = await TestDataGenerator.generateRecordsWrite({ @@ -370,7 +370,7 @@ export function testRecordsSubscribeHandler(): void { chatRecordForCarol2.message, { dataStream: chatRecordForCarol2.dataStream } ); - expect(chatRecordForCarol2Reply.status.code).to.equal(202); + expect(chatRecordForCarol2Reply.status.code).to.equal(204); const chatRecordForCarol2Cid = await Message.getCid(chatRecordForCarol2.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -437,7 +437,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); const recordIds: Set = new Set(); const addRecord:RecordSubscriptionHandler = async (event) => { @@ -471,7 +471,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatRecordForBobReply = await dwn.processMessage(alice.did, chatRecordForBob.message, { dataStream: chatRecordForBob.dataStream }); - expect(chatRecordForBobReply.status.code).to.equal(202); + expect(chatRecordForBobReply.status.code).to.equal(204); // Alice writes three more 'chat' records for carol, Bob's friend role should allow him to see these messages. const chatRecordIds: string[] = []; @@ -485,7 +485,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } @@ -555,7 +555,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); const filter: RecordsFilter = { protocol : protocolDefinition.protocol, @@ -593,7 +593,7 @@ export function testRecordsSubscribeHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); const recordIds: string[] = []; const addRecord:RecordSubscriptionHandler = async (event) => { @@ -629,7 +629,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); chatRecordIds.push(chatRecord.message.recordId); } @@ -667,7 +667,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Bob invokes his friendRole to subscribe but does not have `protocolPath` in the filter const chatSubscribe = await TestDataGenerator.generateRecordsSubscribe({ @@ -706,7 +706,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Alice writes a 'friend' root-level role record with Bob as recipient const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -719,7 +719,7 @@ export function testRecordsSubscribeHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(202); + expect(participantRoleReply.status.code).to.equal(204); // Bob invokes his thread participant role to subscribe but omits the contextId const chatSubscribe = await TestDataGenerator.generateRecordsSubscribe({ @@ -789,7 +789,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(202); + expect(threadRoleReply.status.code).to.equal(204); // Bob invokes his a `thread/participant` role which he does not have to subscribe to the records const chatSubscribe = await TestDataGenerator.generateRecordsSubscribe({ diff --git a/tests/handlers/records-write.spec.ts b/tests/handlers/records-write.spec.ts index 26c84acfe..c12202d39 100644 --- a/tests/handlers/records-write.spec.ts +++ b/tests/handlers/records-write.spec.ts @@ -122,7 +122,7 @@ export function testRecordsWriteHandler(): void { const tenant = author.did; const recordsWriteReply = await dwn.processMessage(tenant, recordsWriteMessageData.message, { dataStream: recordsWriteMessageData.dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); const recordId = recordsWriteMessageData.message.recordId; const recordsQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -185,7 +185,7 @@ export function testRecordsWriteHandler(): void { const originatingMessageWriteReply = await dwn.processMessage(tenant, originatingMessageData.message, { dataStream: originatingMessageData.dataStream }); - expect(originatingMessageWriteReply.status.code).to.equal(202); + expect(originatingMessageWriteReply.status.code).to.equal(204); // generate two new RecordsWrite messages with the same `messageTimestamp` value const dateModified = Time.getCurrentTimestamp(); @@ -264,7 +264,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [initialWriteData.author]); const initialWriteReply = await dwn.processMessage(tenant, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); const newDataFormat = 'any-new-data-format'; const newDataBytes = TestDataGenerator.randomBytes(100); @@ -296,7 +296,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [initialWriteData.author]); const initialWriteReply = await dwn.processMessage(tenant, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); const recordId = initialWriteData.message.recordId; const dateCreated = initialWriteData.message.descriptor.dateCreated; @@ -340,7 +340,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); const write2 = await RecordsWrite.createFrom({ recordsWriteMessage : message, @@ -414,7 +414,7 @@ export function testRecordsWriteHandler(): void { // write a record into the dwn const { recordsWrite, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const reply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // verify `RecordsWrite` inserted can be queried const recordsQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -459,7 +459,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); const write2 = await RecordsWrite.createFrom({ recordsWriteMessage : message, @@ -492,7 +492,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); const write2 = await RecordsWrite.createFrom({ recordsWriteMessage : message, @@ -639,7 +639,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); const recordsDelete = await RecordsDelete.create({ recordId : message.recordId, @@ -671,7 +671,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(202); + expect(initialWriteReply.status.code).to.equal(204); const recordsDelete = await RecordsDelete.create({ recordId : message.recordId, @@ -764,12 +764,12 @@ export function testRecordsWriteHandler(): void { }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(202); + expect(write1Reply.status.code).to.equal(204); // alice writes another record (which will be modified later) const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(202); + expect(write2Reply.status.code).to.equal(204); // modify write2 by referencing the `dataCid` in write1 (which should not be allowed) const write2Change = await TestDataGenerator.generateRecordsWrite({ @@ -818,12 +818,12 @@ export function testRecordsWriteHandler(): void { }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(202); + expect(write1Reply.status.code).to.equal(204); // alice writes another record (which will be modified later) const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(202); + expect(write2Reply.status.code).to.equal(204); // modify write2 by referencing the `dataCid` in write1 (which should not be allowed) const write2Change = await TestDataGenerator.generateRecordsWrite({ @@ -874,7 +874,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(tenant, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // changing the `published` property const newWrite = await RecordsWrite.createFrom({ @@ -911,7 +911,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(tenant, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const newData = Encoder.stringToBytes('new data'); const newWrite = await RecordsWrite.createFrom({ @@ -990,7 +990,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(author.did, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const { events } = await eventLog.getEvents(author.did); expect(events.length).to.equal(1); @@ -1004,7 +1004,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(author.did, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const newWrite = await RecordsWrite.createFrom({ recordsWriteMessage : recordsWrite.message, @@ -1072,7 +1072,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, emailFromBob.message, { dataStream: emailFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(202); + expect(bobWriteReply.status.code).to.equal(204); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -1109,7 +1109,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'doc' }); const docRecordsReply = await dwn.processMessage(alice.did, docRecord.message, { dataStream: docRecord.dataStream }); - expect(docRecordsReply.status.code).to.equal(202); + expect(docRecordsReply.status.code).to.equal(204); // Bob updates Alice's doc const bobsData = await TestDataGenerator.randomBytes(10); @@ -1174,7 +1174,7 @@ export function testRecordsWriteHandler(): void { credentialApplication.message, { dataStream: credentialApplication.dataStream } ); - expect(credentialApplicationReply.status.code).to.equal(202); + expect(credentialApplicationReply.status.code).to.equal(204); // generate a credential application response message from VC issuer const encodedCredentialResponse = new TextEncoder().encode('credential response data'); @@ -1193,7 +1193,7 @@ export function testRecordsWriteHandler(): void { const credentialResponseReply = await dwn.processMessage(alice.did, credentialResponse.message, { dataStream: credentialResponse.dataStream }); - expect(credentialResponseReply.status.code).to.equal(202); + expect(credentialResponseReply.status.code).to.equal(204); // verify VC issuer's message got written to the DB const messageDataForQueryingCredentialResponse = await TestDataGenerator.generateRecordsQuery({ @@ -1231,7 +1231,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'post' }); const docRecordsReply = await dwn.processMessage(alice.did, docRecord.message, { dataStream: docRecord.dataStream }); - expect(docRecordsReply.status.code).to.equal(202); + expect(docRecordsReply.status.code).to.equal(204); // Alice creates a post/tag const tagRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1242,7 +1242,7 @@ export function testRecordsWriteHandler(): void { parentContextId : docRecord.message.contextId!, }); const tagRecordsReply = await dwn.processMessage(alice.did, tagRecord.message, { dataStream: tagRecord.dataStream }); - expect(tagRecordsReply.status.code).to.equal(202); + expect(tagRecordsReply.status.code).to.equal(204); // Bob updates Alice's post const bobsData = await TestDataGenerator.randomBytes(10); @@ -1297,7 +1297,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'post', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.eq(202); + expect(recordsWriteReply.status.code).to.eq(204); // Carol is unable to update the 'post' const carolRecordsWrite = await TestDataGenerator.generateFromRecordsWrite({ @@ -1350,7 +1350,7 @@ export function testRecordsWriteHandler(): void { data : encodedImage }); const imageReply = await dwn.processMessage(bob.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(202); + expect(imageReply.status.code).to.equal(204); // AliceImposter attempts and fails to caption Alice's image const encodedCaptionImposter = new TextEncoder().encode('bad vibes! >:('); @@ -1379,7 +1379,7 @@ export function testRecordsWriteHandler(): void { data : encodedCaption }); const captionResponse = await dwn.processMessage(bob.did, captionRecordsWrite.message, { dataStream: captionRecordsWrite.dataStream }); - expect(captionResponse.status.code).to.equal(202); + expect(captionResponse.status.code).to.equal(204); // Verify Alice's caption got written to the DB const messageDataForQueryingCaptionResponse = await TestDataGenerator.generateRecordsQuery({ @@ -1417,7 +1417,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'post' }); const postRecordsReply = await dwn.processMessage(alice.did, postRecord.message, { dataStream: postRecord.dataStream }); - expect(postRecordsReply.status.code).to.equal(202); + expect(postRecordsReply.status.code).to.equal(204); // Alice creates a post/comment const commentRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1428,7 +1428,7 @@ export function testRecordsWriteHandler(): void { parentContextId : postRecord.message.contextId!, }); const commentRecordsReply = await dwn.processMessage(alice.did, commentRecord.message, { dataStream: commentRecord.dataStream }); - expect(commentRecordsReply.status.code).to.equal(202); + expect(commentRecordsReply.status.code).to.equal(204); // Bob updates Alice's comment const bobsData = await TestDataGenerator.randomBytes(10); @@ -1481,7 +1481,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Alice updates Bob's 'friend' record const updateFriendRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -1543,7 +1543,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Alice deletes Bob's 'friend' role record const deleteFriend = await TestDataGenerator.generateRecordsDelete({ @@ -1563,7 +1563,7 @@ export function testRecordsWriteHandler(): void { }); const duplicateFriendReply = await dwn.processMessage(alice.did, duplicateFriendRecord.message, { dataStream: duplicateFriendRecord.dataStream }); - expect(duplicateFriendReply.status.code).to.equal(202); + expect(duplicateFriendReply.status.code).to.equal(204); }); }); @@ -1591,7 +1591,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(202); + expect(threadRecordReply.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1603,7 +1603,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Alice updates Bob's role record const participantUpdateRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -1638,7 +1638,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord1.message, { dataStream: threadRecord1.dataStream }); - expect(threadRecordReply1.status.code).to.equal(202); + expect(threadRecordReply1.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' to the first thread const participantRecord1 = await TestDataGenerator.generateRecordsWrite({ @@ -1650,7 +1650,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply1 = await dwn.processMessage(alice.did, participantRecord1.message, { dataStream: participantRecord1.dataStream }); - expect(participantRecordReply1.status.code).to.equal(202); + expect(participantRecordReply1.status.code).to.equal(204); // Alice creates a second thread const threadRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -1660,7 +1660,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply2 = await dwn.processMessage(alice.did, threadRecord2.message, { dataStream: threadRecord2.dataStream }); - expect(threadRecordReply2.status.code).to.equal(202); + expect(threadRecordReply2.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' to the second thread const participantRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -1672,7 +1672,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply2 = await dwn.processMessage(alice.did, participantRecord2.message, { dataStream: participantRecord2.dataStream }); - expect(participantRecordReply2.status.code).to.equal(202); + expect(participantRecordReply2.status.code).to.equal(204); }); it('rejects writes to a $role record if there already exists one in the same context', async () => { @@ -1698,7 +1698,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(202); + expect(threadRecordReply.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' to the thread const participantRecord1 = await TestDataGenerator.generateRecordsWrite({ @@ -1710,7 +1710,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply1 = await dwn.processMessage(alice.did, participantRecord1.message, { dataStream: participantRecord1.dataStream }); - expect(participantRecordReply1.status.code).to.equal(202); + expect(participantRecordReply1.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' again to the same thread const participantRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -1749,7 +1749,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(202); + expect(threadRecordReply.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' to the thread const participantRecord1 = await TestDataGenerator.generateRecordsWrite({ @@ -1761,7 +1761,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply1 = await dwn.processMessage(alice.did, participantRecord1.message, { dataStream: participantRecord1.dataStream }); - expect(participantRecordReply1.status.code).to.equal(202); + expect(participantRecordReply1.status.code).to.equal(204); // Alice deletes the participant record const participantDelete = await TestDataGenerator.generateRecordsDelete({ @@ -1781,7 +1781,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply2 = await dwn.processMessage(alice.did, participantRecord2.message, { dataStream: participantRecord2.dataStream }); - expect(participantRecordReply2.status.code).to.equal(202); + expect(participantRecordReply2.status.code).to.equal(204); }); }); @@ -1811,7 +1811,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Bob writes a 'chat' record const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1823,7 +1823,7 @@ export function testRecordsWriteHandler(): void { protocolRole : 'friend' }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); }); it('uses a root-level role to authorize a co-update', async () => { @@ -1851,7 +1851,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(202); + expect(friendRoleReply.status.code).to.equal(204); // Alice creates a 'chat' record const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1862,7 +1862,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob can write this cuz he is Alices friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); // Bob invokes his admin role to update the 'chat' record const chatUpdateRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -1898,7 +1898,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Blah blah blah'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(202); + expect(chatReply.status.code).to.equal(204); // Bob tries to invoke a 'chat' role but 'chat' is not a role const writeChatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1966,7 +1966,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(202); + expect(threadRecordReply.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1978,7 +1978,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Bob invokes the role to write to the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1989,7 +1989,7 @@ export function testRecordsWriteHandler(): void { protocolRole : 'thread/participant' }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); }); it('uses a context role to authorize a co-update', async () => { @@ -2016,7 +2016,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(202); + expect(threadRecordReply.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2028,7 +2028,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Alice writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2038,7 +2038,7 @@ export function testRecordsWriteHandler(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(202); + expect(chatRecordReply.status.code).to.equal(204); // Bob invokes his admin role to co-update the chat message const chatCoUpdateRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -2075,7 +2075,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord1.message, { dataStream: threadRecord1.dataStream }); - expect(threadRecordReply1.status.code).to.equal(202); + expect(threadRecordReply1.status.code).to.equal(204); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2087,7 +2087,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // Alice creates a second thread const threadRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -2097,7 +2097,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply2 = await dwn.processMessage(alice.did, threadRecord2.message, { dataStream: threadRecord2.dataStream }); - expect(threadRecordReply2.status.code).to.equal(202); + expect(threadRecordReply2.status.code).to.equal(204); // Bob invokes his role to try to write to the second thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2177,7 +2177,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, messageFromBob.message, { dataStream: messageFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(202); + expect(bobWriteReply.status.code).to.equal(204); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -2242,7 +2242,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, messageFromBob.message, { dataStream: messageFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(202); + expect(bobWriteReply.status.code).to.equal(204); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -2311,7 +2311,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, messageFromBob.message, { dataStream: messageFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(202); + expect(bobWriteReply.status.code).to.equal(204); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -2382,7 +2382,7 @@ export function testRecordsWriteHandler(): void { const credentialApplicationReply = await dwn.processMessage(alice.did, credentialApplication.message, { dataStream: credentialApplication.dataStream }); - expect(credentialApplicationReply.status.code).to.equal(202); + expect(credentialApplicationReply.status.code).to.equal(204); // generate a credential application response message from a fake VC issuer const encodedCredentialResponse = new TextEncoder().encode('credential response data'); @@ -2533,7 +2533,7 @@ export function testRecordsWriteHandler(): void { data }); const writeReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // update the image to a not-allowed data format const newDataBytes = TestDataGenerator.randomBytes(100); @@ -2597,7 +2597,7 @@ export function testRecordsWriteHandler(): void { data }); const writeReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // update the image to a different data format const newDataFormat = 'any-new-data-format'; @@ -2665,7 +2665,7 @@ export function testRecordsWriteHandler(): void { }); const credentialApplicationReply = await dwn.processMessage( alice.did, credentialApplication.message, { dataStream: credentialApplication.dataStream }); - expect(credentialApplicationReply.status.code).to.equal(202); + expect(credentialApplicationReply.status.code).to.equal(204); // Try and fail to write another 'credentialApplication' below the first 'credentialApplication' const failedCredentialApplication = await TestDataGenerator.generateRecordsWrite({ @@ -2694,7 +2694,7 @@ export function testRecordsWriteHandler(): void { }); const credentialResponseReply = await dwn.processMessage(alice.did, credentialResponse.message, { dataStream: credentialResponse.dataStream }); - expect(credentialResponseReply.status.code).to.equal(202); + expect(credentialResponseReply.status.code).to.equal(204); // Try and fail to write a 'credentialApplication' below 'credentialApplication/credentialResponse' // Testing case where there is no rule set for any record type at the given level in the hierarchy @@ -2740,7 +2740,7 @@ export function testRecordsWriteHandler(): void { }); let reply = await dwn.processMessage(alice.did, aliceWriteMessageData.message, { dataStream: aliceWriteMessageData.dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // test that Bob is not allowed to write to Alice's DWN const bob = await TestDataGenerator.generateDidKeyPersona(); @@ -2791,7 +2791,7 @@ export function testRecordsWriteHandler(): void { }); let reply = await dwn.processMessage(pfi.did, askMessageData.message, { dataStream: askMessageData.dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const offerMessageData = await TestDataGenerator.generateRecordsWrite({ author : pfi, @@ -2804,7 +2804,7 @@ export function testRecordsWriteHandler(): void { }); reply = await dwn.processMessage(pfi.did, offerMessageData.message, { dataStream: offerMessageData.dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // the actual test: making sure fulfillment message is accepted const fulfillmentMessageData = await TestDataGenerator.generateRecordsWrite({ @@ -2817,7 +2817,7 @@ export function testRecordsWriteHandler(): void { data }); reply = await dwn.processMessage(pfi.did, fulfillmentMessageData.message, { dataStream: fulfillmentMessageData.dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // verify the fulfillment message is stored const recordsQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -2866,7 +2866,7 @@ export function testRecordsWriteHandler(): void { }); let reply = await dwn.processMessage(pfi.did, askMessageData.message, { dataStream: askMessageData.dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // the actual test: making sure fulfillment message fails const fulfillmentMessageData = await TestDataGenerator.generateRecordsWrite({ @@ -2994,7 +2994,7 @@ export function testRecordsWriteHandler(): void { }); const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const protocolDefinition = socialMediaProtocolDefinition; const protocol = protocolDefinition.protocol; @@ -3086,7 +3086,7 @@ export function testRecordsWriteHandler(): void { }); const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); const protocolDefinition = socialMediaProtocolDefinition; const protocol = protocolDefinition.protocol; @@ -3191,7 +3191,7 @@ export function testRecordsWriteHandler(): void { ); const writeReply = await dwn.processMessage(alice.did, docWrite.message, { dataStream }); - expect(writeReply.status.code).to.equal(202); + expect(writeReply.status.code).to.equal(204); // write a `RecordsWrite` message with schema const data2 = TestDataGenerator.randomBytes(100); @@ -3208,7 +3208,7 @@ export function testRecordsWriteHandler(): void { ); const write2Reply = await dwn.processMessage(alice.did, doc2Write.message, { dataStream: data2Stream }); - expect(write2Reply.status.code).to.equal(202); + expect(write2Reply.status.code).to.equal(204); // verify messages got written to the DB const recordsQuery = await RecordsQuery.create({ @@ -3260,7 +3260,7 @@ export function testRecordsWriteHandler(): void { }); const reply = await dwn.processMessage(alice.did, testRecord.message, { dataStream: testRecord.dataStream }); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // test max record size const data2 = TestDataGenerator.randomBytes(1000); @@ -3273,7 +3273,7 @@ export function testRecordsWriteHandler(): void { }); const reply2 = await dwn.processMessage(alice.did, testRecord2.message, { dataStream: testRecord2.dataStream }); - expect(reply2.status.code).to.equal(202); + expect(reply2.status.code).to.equal(204); // test beyond max size const data3 = TestDataGenerator.randomBytes(1001); @@ -3342,7 +3342,7 @@ export function testRecordsWriteHandler(): void { }); const reply2 = await dwn.processMessage(alice.did, testRecord2.message, { dataStream: testRecord2.dataStream }); - expect(reply2.status.code).to.equal(202); + expect(reply2.status.code).to.equal(204); }); it('should fail authorization if protocol message size is more than specified maximum size', async () => { @@ -3397,7 +3397,7 @@ export function testRecordsWriteHandler(): void { }); const reply2 = await dwn.processMessage(alice.did, testRecord2.message, { dataStream: testRecord2.dataStream }); - expect(reply2.status.code).to.equal(202); + expect(reply2.status.code).to.equal(204); }); it('should fail if a write references a parent that has been deleted', async () => { @@ -3431,7 +3431,7 @@ export function testRecordsWriteHandler(): void { const foo1 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: foo1.dataStream }); - expect(foo1WriteResponse.status.code).equals(202); + expect(foo1WriteResponse.status.code).equals(204); // 2. Alice deletes foo1 const deleteFoo = await TestDataGenerator.generateRecordsDelete({ @@ -3486,7 +3486,7 @@ export function testRecordsWriteHandler(): void { const foo1 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: foo1.dataStream }); - expect(foo1WriteResponse.status.code).equals(202); + expect(foo1WriteResponse.status.code).equals(204); // 2. Alice tries to write a bar1 referencing the foo1 in parentId, but contextId does not reference the same parent const barOptions = { @@ -3560,7 +3560,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob invokes the grant in order to write a record to the protocol const { recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({ @@ -3570,7 +3570,7 @@ export function testRecordsWriteHandler(): void { permissionGrantId : permissionGrant.recordsWrite.message.recordId, }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(202); + expect(recordsWriteReply.status.code).to.equal(204); }); it('rejects writes of protocol records with mismatching protocol grant scopes', async () => { @@ -3607,7 +3607,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob invokes the grant, failing to write to a different protocol than the grant allows const { recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({ @@ -3649,7 +3649,7 @@ export function testRecordsWriteHandler(): void { }); const alicesRecordsWriteReply = await dwn.processMessage(alice.did, alicesRecordsWrite.message, { dataStream: alicesRecordsWrite.dataStream }); - expect(alicesRecordsWriteReply.status.code).to.equal(202); + expect(alicesRecordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant const permissionGrant = await PermissionsProtocol.createGrant({ @@ -3669,7 +3669,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3682,7 +3682,7 @@ export function testRecordsWriteHandler(): void { permissionGrantId : permissionGrant.recordsWrite.message.recordId, }); const bobsRecordsWriteReply = await dwn.processMessage(alice.did, bobsRecordsWrite.message, { dataStream: bobsRecordsWrite.dataStream }); - expect(bobsRecordsWriteReply.status.code).to.equal(202); + expect(bobsRecordsWriteReply.status.code).to.equal(204); }); it('rejects writes of protocol records with mismatching contextId grant scopes', async () => { @@ -3713,7 +3713,7 @@ export function testRecordsWriteHandler(): void { }); const alicesRecordsWriteReply = await dwn.processMessage(alice.did, alicesRecordsWrite.message, { dataStream: alicesRecordsWrite.dataStream }); - expect(alicesRecordsWriteReply.status.code).to.equal(202); + expect(alicesRecordsWriteReply.status.code).to.equal(204); // Alice gives Bob a permission grant const permissionGrant = await PermissionsProtocol.createGrant({ @@ -3733,7 +3733,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3785,7 +3785,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3795,7 +3795,7 @@ export function testRecordsWriteHandler(): void { permissionGrantId : permissionGrant.recordsWrite.message.recordId, }); const bobsRecordsWriteReply = await dwn.processMessage(alice.did, bobsRecordsWrite.message, { dataStream: bobsRecordsWrite.dataStream }); - expect(bobsRecordsWriteReply.status.code).to.equal(202); + expect(bobsRecordsWriteReply.status.code).to.equal(204); }); it('rejects writes of protocol records with mismatching protocolPath grant scopes', async () => { @@ -3833,7 +3833,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3885,7 +3885,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -3902,7 +3902,7 @@ export function testRecordsWriteHandler(): void { publishedRecordsWrite.message, { dataStream: publishedRecordsWrite.dataStream } ); - expect(publishedRecordsWriteReply.status.code).to.equal(202); + expect(publishedRecordsWriteReply.status.code).to.equal(204); // Bob is not able to write an unpublished record const unpublishedRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3954,7 +3954,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -3984,7 +3984,7 @@ export function testRecordsWriteHandler(): void { }); const unpublishedRecordsWriteReply = await dwn.processMessage(alice.did, unpublishedRecordsWrite.message, { dataStream: unpublishedRecordsWrite.dataStream }); - expect(unpublishedRecordsWriteReply.status.code).to.equal(202); + expect(unpublishedRecordsWriteReply.status.code).to.equal(204); }); it('Allows both published and unpublished records if grant condition `published` is undefined', async () => { @@ -4023,7 +4023,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(202); + expect(permissionGrantWriteReply.status.code).to.equal(204); const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -4040,7 +4040,7 @@ export function testRecordsWriteHandler(): void { publishedRecordsWrite.message, { dataStream: publishedRecordsWrite.dataStream } ); - expect(publishedRecordsWriteReply.status.code).to.equal(202); + expect(publishedRecordsWriteReply.status.code).to.equal(204); // Bob is able to write an unpublished record const unpublishedRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -4052,7 +4052,7 @@ export function testRecordsWriteHandler(): void { }); const unpublishedRecordsWriteReply = await dwn.processMessage(alice.did, unpublishedRecordsWrite.message, { dataStream: unpublishedRecordsWrite.dataStream }); - expect(unpublishedRecordsWriteReply.status.code).to.equal(202); + expect(unpublishedRecordsWriteReply.status.code).to.equal(204); }); }); }); @@ -4126,7 +4126,7 @@ export function testRecordsWriteHandler(): void { data }); const aliceWriteReply = await dwn.processMessage(alice.did, aliceWriteData.message, { dataStream: aliceWriteData.dataStream }); - expect(aliceWriteReply.status.code).to.equal(202); + expect(aliceWriteReply.status.code).to.equal(204); const aliceQueryWriteAfterAliceWriteData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -4173,7 +4173,7 @@ export function testRecordsWriteHandler(): void { const processEncoded = sinon.spy(RecordsWriteHandler.prototype as any, 'cloneAndAddEncodedData'); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(202); + expect(writeMessage.status.code).to.equal(204); sinon.assert.calledOnce(processEncoded); }); @@ -4184,7 +4184,7 @@ export function testRecordsWriteHandler(): void { const processEncoded = sinon.spy(RecordsWriteHandler.prototype as any, 'cloneAndAddEncodedData'); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(202); + expect(writeMessage.status.code).to.equal(204); sinon.assert.notCalled(processEncoded); }); @@ -4194,7 +4194,7 @@ export function testRecordsWriteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, data: dataBytes }); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(202); + expect(writeMessage.status.code).to.equal(204); const messageCid = await Message.getCid(message); const storedMessage = await messageStore.get(alice.did, messageCid); @@ -4207,7 +4207,7 @@ export function testRecordsWriteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, data: dataBytes }); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(202); + expect(writeMessage.status.code).to.equal(204); const messageCid = await Message.getCid(message); const storedMessage = await messageStore.get(alice.did, messageCid); @@ -4220,7 +4220,7 @@ export function testRecordsWriteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, data: dataBytes }); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(202); + expect(writeMessage.status.code).to.equal(204); const messageCid = await Message.getCid(message); const storedMessage = await messageStore.get(alice.did, messageCid); diff --git a/tests/scenarios/end-to-end-tests.spec.ts b/tests/scenarios/end-to-end-tests.spec.ts index d4caa2c84..c3ca34063 100644 --- a/tests/scenarios/end-to-end-tests.spec.ts +++ b/tests/scenarios/end-to-end-tests.spec.ts @@ -114,7 +114,7 @@ export function testEndToEndScenarios(): void { encryptSymmetricKeyWithProtocolContextDerivedKey : true }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply1.status.code).to.equal(202); + expect(threadRecordReply1.status.code).to.equal(204); // 2. Alice adds Bob as a participant giving him the [context-derived private key] encrypted using [Bob's participant-level public key] @@ -153,7 +153,7 @@ export function testEndToEndScenarios(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantBobRecord.message, { dataStream: participantBobRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(202); + expect(participantRecordReply.status.code).to.equal(204); // 3. Alice writes a chat message(s) in the thread const messageByAlice = 'Message from Alice'; @@ -170,7 +170,7 @@ export function testEndToEndScenarios(): void { encryptSymmetricKeyWithProtocolContextDerivedKey : true }); const chatMessageReply = await dwn.processMessage(alice.did, chatMessageByAlice.message, { dataStream: chatMessageByAlice.dataStream }); - expect(chatMessageReply.status.code).to.equal(202); + expect(chatMessageReply.status.code).to.equal(204); // Assume the below steps can be done since it is a common DWN usage pattern // 4. Alice sends an invite to Bob's DWN with the [context/thread ID] diff --git a/tests/scenarios/messages-query.spec.ts b/tests/scenarios/messages-query.spec.ts index 5d0acd8af..c880c70cd 100644 --- a/tests/scenarios/messages-query.spec.ts +++ b/tests/scenarios/messages-query.spec.ts @@ -62,7 +62,7 @@ export function testMessagesQueryScenarios(): void { // insert data const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); - expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); expect(protocolReply.status.code).to.equal(202, 'ProtocolConfigure'); const messagesQueryRecords = await TestDataGenerator.generateMessagesQuery({ @@ -95,7 +95,7 @@ export function testMessagesQueryScenarios(): void { // insert data const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); - expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); expect(protocolReply.status.code).to.equal(202, 'ProtocolConfigure'); let messagesQueryRecords = await TestDataGenerator.generateMessagesQuery({ @@ -154,7 +154,7 @@ export function testMessagesQueryScenarios(): void { // write 1 const record1 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record1Reply = await dwn.processMessage(alice.did, record1.message, { dataStream: record1.dataStream }); - expect(record1Reply.status.code).to.equal(202, 'RecordsWrite'); + expect(record1Reply.status.code).to.equal(204, 'RecordsWrite'); // other messages const protocol = await TestDataGenerator.generateProtocolsConfigure({ author: alice }); @@ -164,7 +164,7 @@ export function testMessagesQueryScenarios(): void { // write 2 const record2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record2Reply = await dwn.processMessage(alice.did, record2.message, { dataStream: record2.dataStream }); - expect(record2Reply.status.code).to.equal(202, 'RecordsWrite'); + expect(record2Reply.status.code).to.equal(204, 'RecordsWrite'); // delete write 1 const delete1 = await TestDataGenerator.generateRecordsDelete({ author: alice, recordId: record1.message.recordId }); @@ -217,7 +217,7 @@ export function testMessagesQueryScenarios(): void { // insert data const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); - expect(writeReply.status.code).to.equal(202, 'RecordsWrite'); + expect(writeReply.status.code).to.equal(204, 'RecordsWrite'); expect(protocolReply.status.code).to.equal(202, 'ProtocolConfigure'); // query from last day of 2021 @@ -296,12 +296,12 @@ export function testMessagesQueryScenarios(): void { // create a record for proto1 const write1proto1 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto1, ...postProperties }); const write1Response = await dwn.processMessage(alice.did, write1proto1.message, { dataStream: write1proto1.dataStream }); - expect(write1Response.status.code).equals(202); + expect(write1Response.status.code).equals(204); // create a record for proto2 const write1proto2 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto2, ...postProperties }); const write1Proto2Response = await dwn.processMessage(alice.did, write1proto2.message, { dataStream: write1proto2.dataStream }); - expect(write1Proto2Response.status.code).equals(202); + expect(write1Proto2Response.status.code).equals(204); // bob requests permissions for proto 1 const requestProto1 = await PermissionsProtocol.createRequest({ @@ -314,7 +314,7 @@ export function testMessagesQueryScenarios(): void { requestProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto1.permissionRequestBytes) } ); - expect(requestProto1Response.status.code).equals(202); + expect(requestProto1Response.status.code).equals(204); // bob requests permissions for proto 2 const requestProto2 = await PermissionsProtocol.createRequest({ @@ -327,7 +327,7 @@ export function testMessagesQueryScenarios(): void { requestProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto2.permissionRequestBytes) } ); - expect(requestProto2Response.status.code).equals(202); + expect(requestProto2Response.status.code).equals(204); // alice grants bob permissions for proto 1 const grantProto1 = await PermissionsProtocol.createGrant({ @@ -341,7 +341,7 @@ export function testMessagesQueryScenarios(): void { grantProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto1.permissionGrantBytes) } ); - expect(grantProto1Response.status.code).equals(202); + expect(grantProto1Response.status.code).equals(204); // alice grants bob permissions for proto 2 const grantProto2 = await PermissionsProtocol.createGrant({ @@ -355,7 +355,7 @@ export function testMessagesQueryScenarios(): void { grantProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto2.permissionGrantBytes) } ); - expect(grantProto2Response.status.code).equals(202); + expect(grantProto2Response.status.code).equals(204); // filter for proto1 messages let proto1MessagesQuery = await TestDataGenerator.generateMessagesQuery({ @@ -407,7 +407,7 @@ export function testMessagesQueryScenarios(): void { revokeProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto1.permissionRevocationBytes) } ); - expect(revokeProto1Response.status.code).equals(202); + expect(revokeProto1Response.status.code).equals(204); // revoke permissions for proto2 const revokeProto2 = await PermissionsProtocol.createRevocation({ @@ -419,7 +419,7 @@ export function testMessagesQueryScenarios(): void { revokeProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto2.permissionRevocationBytes) } ); - expect(revokeProto2Response.status.code).equals(202); + expect(revokeProto2Response.status.code).equals(204); //query messages beyond the cursor proto1MessagesQuery = await TestDataGenerator.generateMessagesQuery({ diff --git a/tests/scenarios/nested-roles.spec.ts b/tests/scenarios/nested-roles.spec.ts index 563d39ddb..962c6d3de 100644 --- a/tests/scenarios/nested-roles.spec.ts +++ b/tests/scenarios/nested-roles.spec.ts @@ -101,7 +101,7 @@ export function testNestedRoleScenarios(): void { protocolPath : 'community' }); const communityRecordReply = await dwn.processMessage(alice.did, communityRecord.message, { dataStream: communityRecord.dataStream }); - expect(communityRecordReply.status.code).to.equal(202); + expect(communityRecordReply.status.code).to.equal(204); // 3. Alice can assign Bob as an 'admin' in the community const communityAdminBobRecord = await TestDataGenerator.generateRecordsWrite({ @@ -113,7 +113,7 @@ export function testNestedRoleScenarios(): void { }); const communityAdminBobRecordReply = await dwn.processMessage(alice.did, communityAdminBobRecord.message, { dataStream: communityAdminBobRecord.dataStream }); - expect(communityAdminBobRecordReply.status.code).to.equal(202); + expect(communityAdminBobRecordReply.status.code).to.equal(204); // 4. Bob can invoke his `admin` role to perform actions: // 4a. Bob can read the community record @@ -139,7 +139,7 @@ export function testNestedRoleScenarios(): void { parentContextId : communityRecord.message.contextId }); const channel1RecordReply = await dwn.processMessage(alice.did, channel1Record.message, { dataStream: channel1Record.dataStream }); - expect(channel1RecordReply.status.code).to.equal(202); + expect(channel1RecordReply.status.code).to.equal(204); const channel2Record = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -149,7 +149,7 @@ export function testNestedRoleScenarios(): void { parentContextId : communityRecord.message.contextId }); const channel2RecordReply = await dwn.processMessage(alice.did, channel2Record.message, { dataStream: channel2Record.dataStream }); - expect(channel2RecordReply.status.code).to.equal(202); + expect(channel2RecordReply.status.code).to.equal(204); // 5. Bob as the creator/author of the channels can add participants in the gated-channels // 5a. Bob can add himself and Carol as participants in the gated-channel 1 @@ -162,7 +162,7 @@ export function testNestedRoleScenarios(): void { }); const channel1ParticipantBobRecordReply = await dwn.processMessage(alice.did, channel1ParticipantBobRecord.message, { dataStream: channel1ParticipantBobRecord.dataStream }); - expect(channel1ParticipantBobRecordReply.status.code).to.equal(202); + expect(channel1ParticipantBobRecordReply.status.code).to.equal(204); const channel1ParticipantCarolRecord = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -173,7 +173,7 @@ export function testNestedRoleScenarios(): void { }); const channel1ParticipantCarolRecordReply = await dwn.processMessage(alice.did, channel1ParticipantCarolRecord.message, { dataStream: channel1ParticipantCarolRecord.dataStream }); - expect(channel1ParticipantCarolRecordReply.status.code).to.equal(202); + expect(channel1ParticipantCarolRecordReply.status.code).to.equal(204); // 5b. Bob can add himself and Daniel as participants in the gated-channel 2 const channel2ParticipantBobRecord = await TestDataGenerator.generateRecordsWrite({ @@ -185,7 +185,7 @@ export function testNestedRoleScenarios(): void { }); const channel2ParticipantBobRecordReply = await dwn.processMessage(alice.did, channel2ParticipantBobRecord.message, { dataStream: channel2ParticipantBobRecord.dataStream }); - expect(channel2ParticipantBobRecordReply.status.code).to.equal(202); + expect(channel2ParticipantBobRecordReply.status.code).to.equal(204); const channel2ParticipantDanielRecord = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -196,7 +196,7 @@ export function testNestedRoleScenarios(): void { }); const channel2ParticipantDanielRecordReply = await dwn.processMessage(alice.did, channel2ParticipantDanielRecord.message, { dataStream: channel2ParticipantDanielRecord.dataStream }); - expect(channel2ParticipantDanielRecordReply.status.code).to.equal(202); + expect(channel2ParticipantDanielRecordReply.status.code).to.equal(204); // 6. Carol can read the gated channel 1 record by invoking her child participant role to the gated channel 1 const carolRead = await RecordsRead.create({ @@ -250,7 +250,7 @@ export function testNestedRoleScenarios(): void { }); const participantDanielRecordAttempt2Reply = await dwn.processMessage(alice.did, participantDanielRecordAttempt2.message, { dataStream: participantDanielRecordAttempt2.dataStream }); - expect(participantDanielRecordAttempt2Reply.status.code).to.equal(202); + expect(participantDanielRecordAttempt2Reply.status.code).to.equal(204); // 10. Bob can invoke the participant role to write a chat message in the channel const bobChatMessage = await TestDataGenerator.generateRecordsWrite({ @@ -261,7 +261,7 @@ export function testNestedRoleScenarios(): void { parentContextId : channel1Record.message.contextId }); const bobChatMessageReply = await dwn.processMessage(alice.did, bobChatMessage.message, { dataStream: bobChatMessage.dataStream }); - expect(bobChatMessageReply.status.code).to.equal(202); + expect(bobChatMessageReply.status.code).to.equal(204); // 11. Carol can invoke the participant role to read chat messages in the channel const carolQuery = await RecordsQuery.create({ @@ -286,7 +286,7 @@ export function testNestedRoleScenarios(): void { parentContextId : bobChatMessage.message.contextId }); const carolReactionReply = await dwn.processMessage(alice.did, carolReaction.message, { dataStream: carolReaction.dataStream }); - expect(carolReactionReply.status.code).to.equal(202); + expect(carolReactionReply.status.code).to.equal(204); // 13. Mallory CANNOT invoke the participant role (which she is not given) to read the chat messages in the channel const malloryQuery = await RecordsQuery.create({ diff --git a/tests/scenarios/subscriptions.spec.ts b/tests/scenarios/subscriptions.spec.ts index 580e789e9..8bc772a31 100644 --- a/tests/scenarios/subscriptions.spec.ts +++ b/tests/scenarios/subscriptions.spec.ts @@ -90,7 +90,7 @@ export function testSubscriptionScenarios(): void { const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const write1MessageCid = await Message.getCid(write1.message); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(202); + expect(write1Reply.status.code).to.equal(204); const protocol1 = await TestDataGenerator.generateProtocolsConfigure({ author: alice }); const protocol1MessageCid = await Message.getCid(protocol1.message); @@ -165,7 +165,7 @@ export function testSubscriptionScenarios(): void { // create one of each message types a RecordsWrite and a ProtocolsConfigure const record = await TestDataGenerator.generateRecordsWrite({ author: alice }); const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); - expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); const protocol = await TestDataGenerator.generateProtocolsConfigure({ author: alice }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); @@ -259,7 +259,7 @@ export function testSubscriptionScenarios(): void { // create and updates the record, this creates two RecordsWrite messages const record = await TestDataGenerator.generateRecordsWrite({ author: alice }); const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); - expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); const record1MessageCid = await Message.getCid(record.message); const recordUpdate = await TestDataGenerator.generateFromRecordsWrite({ author: alice, existingWrite: record.recordsWrite }); @@ -289,7 +289,7 @@ export function testSubscriptionScenarios(): void { // write a second record const record2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record2Reply = await dwn.processMessage(alice.did, record2.message, { dataStream: record2.dataStream }); - expect(record2Reply.status.code).to.equal(202, 'RecordsWrite'); + expect(record2Reply.status.code).to.equal(204, 'RecordsWrite'); const record2MessageCid = await Message.getCid(record2.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -388,12 +388,12 @@ export function testSubscriptionScenarios(): void { // create a record for proto1 const write1proto1 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto1, ...postProperties }); const write1Response = await dwn.processMessage(alice.did, write1proto1.message, { dataStream: write1proto1.dataStream }); - expect(write1Response.status.code).equals(202); + expect(write1Response.status.code).equals(204); // create a record for proto2 const write1proto2 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto2, ...postProperties }); const write1Proto2Response = await dwn.processMessage(alice.did, write1proto2.message, { dataStream: write1proto2.dataStream }); - expect(write1Proto2Response.status.code).equals(202); + expect(write1Proto2Response.status.code).equals(204); // bob requests permissions for proto1 const requestProto1 = await PermissionsProtocol.createRequest({ @@ -406,7 +406,7 @@ export function testSubscriptionScenarios(): void { requestProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto1.permissionRequestBytes) } ); - expect(requestProto1Response.status.code).equals(202); + expect(requestProto1Response.status.code).equals(204); // bob requests permissions for proto2 const requestProto2 = await PermissionsProtocol.createRequest({ @@ -419,7 +419,7 @@ export function testSubscriptionScenarios(): void { requestProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto2.permissionRequestBytes) } ); - expect(requestProto2Response.status.code).equals(202); + expect(requestProto2Response.status.code).equals(204); // alice grants permissions for proto1 const grantProto1 = await PermissionsProtocol.createGrant({ @@ -433,7 +433,7 @@ export function testSubscriptionScenarios(): void { grantProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto1.permissionGrantBytes) } ); - expect(grantProto1Response.status.code).equals(202); + expect(grantProto1Response.status.code).equals(204); // alice grants permissions for proto2 const grantProto2 = await PermissionsProtocol.createGrant({ @@ -447,7 +447,7 @@ export function testSubscriptionScenarios(): void { grantProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto2.permissionGrantBytes) } ); - expect(grantProto2Response.status.code).equals(202); + expect(grantProto2Response.status.code).equals(204); // poll until the messages are received by the handlers await Poller.pollUntilSuccessOrTimeout(async () => { @@ -490,7 +490,7 @@ export function testSubscriptionScenarios(): void { revokeProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto1.permissionRevocationBytes) } ); - expect(revokeProto1Response.status.code).equals(202); + expect(revokeProto1Response.status.code).equals(204); // revoke permissions for proto2 const revokeProto2 = await PermissionsProtocol.createRevocation({ @@ -502,7 +502,7 @@ export function testSubscriptionScenarios(): void { revokeProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto2.permissionRevocationBytes) } ); - expect(revokeProto2Response.status.code).equals(202); + expect(revokeProto2Response.status.code).equals(204); // poll until the messages are received by the handlers await Poller.pollUntilSuccessOrTimeout(async () => { @@ -563,7 +563,7 @@ export function testSubscriptionScenarios(): void { // write a record const record1 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record1Reply = await dwn.processMessage(alice.did, record1.message, { dataStream: record1.dataStream }); - expect(record1Reply.status.code).to.equal(202); + expect(record1Reply.status.code).to.equal(204); const record1MessageCid = await Message.getCid(record1.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -581,12 +581,12 @@ export function testSubscriptionScenarios(): void { // write two more message. const record2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record2Reply = await dwn.processMessage(alice.did, record2.message, { dataStream: record2.dataStream }); - expect(record2Reply.status.code).to.equal(202); + expect(record2Reply.status.code).to.equal(204); const record2MessageCid = await Message.getCid(record2.message); const record3 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record3Reply = await dwn.processMessage(alice.did, record3.message, { dataStream: record3.dataStream }); - expect(record3Reply.status.code).to.equal(202); + expect(record3Reply.status.code).to.equal(204); const record3MessageCid = await Message.getCid(record3.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -648,17 +648,17 @@ export function testSubscriptionScenarios(): void { // we create a non published record, this will only show up in the control subscription const writeNotPublished = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1' }); const writeNotPublishedReply = await dwn.processMessage(alice.did, writeNotPublished.message, { dataStream: writeNotPublished.dataStream }); - expect(writeNotPublishedReply.status.code).to.equal(202); + expect(writeNotPublishedReply.status.code).to.equal(204); // we create a published record, this will show up in both the control and anonymous subscription const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', published: true }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(202); + expect(write1Reply.status.code).to.equal(204); // we create another published record, this will show up in both the control and anonymous subscription const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', published: true }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(202); + expect(write2Reply.status.code).to.equal(204); await Poller.pollUntilSuccessOrTimeout(async () => { // publishedMessages array should only contain the two published messages @@ -722,16 +722,16 @@ export function testSubscriptionScenarios(): void { // write two messages for bob const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', recipient: bob.did }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(202); + expect(write1Reply.status.code).to.equal(204); const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', recipient: bob.did }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(202); + expect(write2Reply.status.code).to.equal(204); // write one message for carol const writeForCarol = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', recipient: carol.did }); const writeForCarolReply = await dwn.processMessage(alice.did, writeForCarol.message, { dataStream: writeForCarol.dataStream }); - expect(writeForCarolReply.status.code).to.equal(202); + expect(writeForCarolReply.status.code).to.equal(204); await Poller.pollUntilSuccessOrTimeout(async () => { // bob should have received the two messages intended for him @@ -778,7 +778,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread' }); const threadReply = await dwn.processMessage(alice.did, thread.message, { dataStream: thread.dataStream }); - expect(threadReply.status.code).to.equal(202); + expect(threadReply.status.code).to.equal(204); // subscribe to this thread's messages @@ -831,7 +831,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread/participant' }); const bobParticipantReply = await dwn.processMessage(alice.did, bobParticipant.message, { dataStream: bobParticipant.dataStream }); - expect(bobParticipantReply.status.code).to.equal(202); + expect(bobParticipantReply.status.code).to.equal(204); // add carol as participant const carolParticipant = await TestDataGenerator.generateRecordsWrite({ @@ -842,7 +842,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread/participant' }); const carolParticipantReply = await dwn.processMessage(alice.did, carolParticipant.message, { dataStream: carolParticipant.dataStream }); - expect(carolParticipantReply.status.code).to.equal(202); + expect(carolParticipantReply.status.code).to.equal(204); // add another thread as a control, will not show up in handled message events const additionalThread = await TestDataGenerator.generateRecordsWrite({ @@ -851,7 +851,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread' }); const additionalThreadReply = await dwn.processMessage(alice.did, additionalThread.message, { dataStream: additionalThread.dataStream }); - expect(additionalThreadReply.status.code).to.equal(202); + expect(additionalThreadReply.status.code).to.equal(204); await Poller.pollUntilSuccessOrTimeout(async () => { expect(messages.length).to.equal(2); @@ -871,7 +871,7 @@ export function testSubscriptionScenarios(): void { protocolRole : 'thread/participant', }); const message1Reply = await dwn.processMessage(alice.did, message1.message, { dataStream: message1.dataStream }); - expect(message1Reply.status.code).to.equal(202); + expect(message1Reply.status.code).to.equal(204); const message2 = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -882,7 +882,7 @@ export function testSubscriptionScenarios(): void { protocolRole : 'thread/participant', }); const message2Reply = await dwn.processMessage(alice.did, message2.message, { dataStream: message2.dataStream }); - expect(message2Reply.status.code).to.equal(202); + expect(message2Reply.status.code).to.equal(204); const message3 = await TestDataGenerator.generateRecordsWrite({ author : carol, @@ -893,7 +893,7 @@ export function testSubscriptionScenarios(): void { protocolRole : 'thread/participant', }); const message3Reply = await dwn.processMessage(alice.did, message3.message, { dataStream: message3.dataStream }); - expect(message3Reply.status.code).to.equal(202); + expect(message3Reply.status.code).to.equal(204); await Poller.pollUntilSuccessOrTimeout(async () => { expect(messages.length).to.equal(5); From 7c35227cb0c374b0de7cff816e83590f9c3c164a Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 11:12:00 -0400 Subject: [PATCH 4/9] Fix the lint. --- src/handlers/records-write.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/handlers/records-write.ts b/src/handlers/records-write.ts index e32427416..b0cc667bc 100644 --- a/src/handlers/records-write.ts +++ b/src/handlers/records-write.ts @@ -162,10 +162,10 @@ export class RecordsWriteHandler implements MethodHandler { throw error; } - const messageReply = { + const messageReply = { status: (newMessageIsInitialWrite && dataStream !== undefined) ? - { code: 204, detail: 'No Content' } : - { code: 202, detail: 'Accepted' } + { code: 204, detail: 'No Content' } : + { code: 202, detail: 'Accepted' } }; // delete all existing messages of the same record that are not newest, except for the initial write From 4907e7892a60ceea6d6006ace5e4cf493291da92 Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 11:20:28 -0400 Subject: [PATCH 5/9] boolean logic is hard --- src/handlers/records-write.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/records-write.ts b/src/handlers/records-write.ts index b0cc667bc..bb23288e3 100644 --- a/src/handlers/records-write.ts +++ b/src/handlers/records-write.ts @@ -163,7 +163,7 @@ export class RecordsWriteHandler implements MethodHandler { } const messageReply = { - status: (newMessageIsInitialWrite && dataStream !== undefined) ? + status: (newMessageIsInitialWrite && dataStream === undefined) ? { code: 204, detail: 'No Content' } : { code: 202, detail: 'Accepted' } }; From 8f6e4c3b9c716069f8bb7b2f4c41896a6a23242e Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 11:20:42 -0400 Subject: [PATCH 6/9] And now fix the tests again --- tests/dwn.spec.ts | 2 +- tests/features/author-delegated-grant.spec.ts | 42 ++-- tests/features/owner-delegated-grant.spec.ts | 6 +- tests/features/owner-signature.spec.ts | 6 +- tests/features/permissions.spec.ts | 44 ++-- tests/features/protocol-create-action.spec.ts | 10 +- tests/features/protocol-delete-action.spec.ts | 24 +- tests/features/protocol-update-action.spec.ts | 24 +- tests/features/records-prune.spec.ts | 32 +-- tests/features/records-tags.spec.ts | 94 ++++---- tests/features/resumable-tasks.spec.ts | 6 +- tests/handlers/messages-query.spec.ts | 18 +- tests/handlers/messages-read.spec.ts | 36 +-- tests/handlers/messages-subscribe.spec.ts | 18 +- tests/handlers/protocols-query.spec.ts | 12 +- tests/handlers/records-delete.spec.ts | 46 ++-- tests/handlers/records-query.spec.ts | 154 ++++++------ tests/handlers/records-read.spec.ts | 100 ++++---- tests/handlers/records-subscribe.spec.ts | 30 +-- tests/handlers/records-write.spec.ts | 220 +++++++++--------- tests/scenarios/end-to-end-tests.spec.ts | 6 +- tests/scenarios/messages-query.spec.ts | 26 +-- tests/scenarios/nested-roles.spec.ts | 18 +- tests/scenarios/subscriptions.spec.ts | 56 ++--- 24 files changed, 515 insertions(+), 515 deletions(-) diff --git a/tests/dwn.spec.ts b/tests/dwn.spec.ts index 3a223515b..d308c20ae 100644 --- a/tests/dwn.spec.ts +++ b/tests/dwn.spec.ts @@ -64,7 +64,7 @@ export function testDwnClass(): void { const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); }); it('should process RecordsQuery message', async () => { diff --git a/tests/features/author-delegated-grant.spec.ts b/tests/features/author-delegated-grant.spec.ts index 12dabcc43..05d4d0ce9 100644 --- a/tests/features/author-delegated-grant.spec.ts +++ b/tests/features/author-delegated-grant.spec.ts @@ -198,7 +198,7 @@ export function testAuthorDelegatedGrant(): void { }); const deviceXWriteReply = await dwn.processMessage(bob.did, messageByDeviceX.message, { dataStream: deviceXDataStream }); - expect(deviceXWriteReply.status.code).to.equal(204); + expect(deviceXWriteReply.status.code).to.equal(202); // verify the message by device X got written to Bob's DWN, AND Alice is the logical author const recordsQueryByBob = await TestDataGenerator.generateRecordsQuery({ @@ -285,7 +285,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Bob adds Alice as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -297,7 +297,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('Alice is my friend'), }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Bob writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -307,7 +307,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Alice creates a delegated query grant for device X to act as Alice. const queryGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -449,7 +449,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Bob adds Alice as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -461,7 +461,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('Alice is my friend'), }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Alice creates a delegated subscribe grant for device X to act as Alice. const subscribeGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -541,7 +541,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecord1Reply = await dwn.processMessage(bob.did, chatRecord1.message, { dataStream: chatRecord1.dataStream }); - expect(chatRecord1Reply.status.code).to.equal(204); + expect(chatRecord1Reply.status.code).to.equal(202); const chatRecord2 = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -550,7 +550,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecord2Reply = await dwn.processMessage(bob.did, chatRecord2.message, { dataStream: chatRecord2.dataStream }); - expect(chatRecord2Reply.status.code).to.equal(204); + expect(chatRecord2Reply.status.code).to.equal(202); await Poller.pollUntilSuccessOrTimeout(async () => { expect(subscriptionChatRecords.size).to.equal(2); @@ -591,7 +591,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('I trust Alice to manage my chat thread'), }); const globalAdminRecordReply = await dwn.processMessage(bob.did, globalAdminRecord.message, { dataStream: globalAdminRecord.dataStream }); - expect(globalAdminRecordReply.status.code).to.equal(204); + expect(globalAdminRecordReply.status.code).to.equal(202); // Bob starts a chat thread const threadRecord = await TestDataGenerator.generateRecordsWrite({ @@ -600,7 +600,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Bob adds Carol as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -611,7 +611,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Carol writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -623,7 +623,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('A rude message'), }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Alice creates a delegated delete grant for device X to act as Alice. const deleteGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -826,7 +826,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Bob adds Alice as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -838,7 +838,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('Alice is my friend'), }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Bob writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -848,7 +848,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // 2. Alice creates a delegated grant for device X to act as her for a protocol that is NOT chat protocol @@ -968,7 +968,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('I trust Alice to manage my chat thread'), }); const globalAdminRecordReply = await dwn.processMessage(bob.did, globalAdminRecord.message, { dataStream: globalAdminRecord.dataStream }); - expect(globalAdminRecordReply.status.code).to.equal(204); + expect(globalAdminRecordReply.status.code).to.equal(202); // Bob starts a chat thread const threadRecord = await TestDataGenerator.generateRecordsWrite({ @@ -977,7 +977,7 @@ export function testAuthorDelegatedGrant(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(bob.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Bob adds Carol as a participant in the thread const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -988,7 +988,7 @@ export function testAuthorDelegatedGrant(): void { parentContextId : threadRecord.message.contextId }); const participantRoleReply = await dwn.processMessage(bob.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Carol writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1000,7 +1000,7 @@ export function testAuthorDelegatedGrant(): void { data : new TextEncoder().encode('A rude message'), }); const chatRecordReply = await dwn.processMessage(bob.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Alice creates a delegated delete grant for Device X to act as her for a protocol that is NOT chat protocol const delegatedGrantForDeviceX = await PermissionsProtocol.createGrant({ @@ -1216,7 +1216,7 @@ export function testAuthorDelegatedGrant(): void { deviceXGrant.recordsWrite.message, { dataStream: deviceXGrantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // 3. Alice revokes the grant const permissionRevoke = await PermissionsProtocol.createRevocation({ @@ -1225,7 +1225,7 @@ export function testAuthorDelegatedGrant(): void { }); const revocationDataStream = DataStream.fromBytes(permissionRevoke.permissionRevocationBytes); const permissionRevokeReply = await dwn.processMessage(alice.did, permissionRevoke.recordsWrite.message, { dataStream: revocationDataStream }); - expect(permissionRevokeReply.status.code).to.equal(204); + expect(permissionRevokeReply.status.code).to.equal(202); // 3. Verify that device X cannot write a `RecordsWrite` message to Bob's DWN as Alice using a mismatching delegated grant ID const deviceXData = new TextEncoder().encode('message from device X'); diff --git a/tests/features/owner-delegated-grant.spec.ts b/tests/features/owner-delegated-grant.spec.ts index 517848d69..cc04e2a38 100644 --- a/tests/features/owner-delegated-grant.spec.ts +++ b/tests/features/owner-delegated-grant.spec.ts @@ -217,7 +217,7 @@ export function testOwnerDelegatedGrant(): void { appXAugmentedWrite.message, { dataStream: DataStream.fromBytes(bobRecordsWriteBytes) } ); - expect(appXWriteReply.status.code).to.equal(204); + expect(appXWriteReply.status.code).to.equal(202); // 7. Sanity verify the RecordsWrite written by App X const recordsQuery = await TestDataGenerator.generateRecordsQuery({ @@ -598,7 +598,7 @@ export function testOwnerDelegatedGrant(): void { }); const grantDataStream = DataStream.fromBytes(appXGrant.permissionGrantBytes); const permissionGrantWriteReply = await dwn.processMessage(alice.did, appXGrant.recordsWrite.message, { dataStream: grantDataStream }); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // 3. Alice revokes the grant const permissionRevoke = await PermissionsProtocol.createRevocation({ @@ -611,7 +611,7 @@ export function testOwnerDelegatedGrant(): void { permissionRevoke.recordsWrite.message, { dataStream: revocationDataStream } ); - expect(permissionRevokeReply.status.code).to.equal(204); + expect(permissionRevokeReply.status.code).to.equal(202); // 4. A third party (Bob) authors a RecordsWrite const bobRecordsWriteBytes = new TextEncoder().encode('message from Bob'); diff --git a/tests/features/owner-signature.spec.ts b/tests/features/owner-signature.spec.ts index 2aff5eab7..eed9cad07 100644 --- a/tests/features/owner-signature.spec.ts +++ b/tests/features/owner-signature.spec.ts @@ -68,7 +68,7 @@ export function testOwnerSignature(): void { // Bob writes a message to his DWN const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: bob, published: true }); const writeReply = await dwn.processMessage(bob.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // Alice fetches the message from Bob's DWN const recordsRead = await RecordsRead.create({ @@ -89,7 +89,7 @@ export function testOwnerSignature(): void { // Test that Alice can successfully retain/write Bob's message to her DWN const aliceDataStream = readReply.record!.data; const aliceWriteReply = await dwn.processMessage(alice.did, ownerSignedMessage.message, { dataStream: aliceDataStream }); - expect(aliceWriteReply.status.code).to.equal(204); + expect(aliceWriteReply.status.code).to.equal(202); // Test that Bob's message can be read from Alice's DWN const readReply2 = await dwn.processMessage(alice.did, recordsRead.message); @@ -135,7 +135,7 @@ export function testOwnerSignature(): void { // Test that Alice can successfully retain/write Bob's message to her DWN const aliceDataStream = DataStream.fromBytes(bobRecordsWrite.dataBytes!); const aliceWriteReply = await dwn.processMessage(alice.did, ownerSignedMessage.message, { dataStream: aliceDataStream }); - expect(aliceWriteReply.status.code).to.equal(204); + expect(aliceWriteReply.status.code).to.equal(202); // Test that Bob's message can be read from Alice's DWN const recordsRead = await RecordsRead.create({ diff --git a/tests/features/permissions.spec.ts b/tests/features/permissions.spec.ts index 1b25a8da2..e7a458099 100644 --- a/tests/features/permissions.spec.ts +++ b/tests/features/permissions.spec.ts @@ -183,7 +183,7 @@ export function testPermissions(): void { const grantWriteReply = await dwn.processMessage(alice.did, grantWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(grantWrite.permissionGrantBytes) }); - expect(grantWriteReply.status.code).to.equal(204); + expect(grantWriteReply.status.code).to.equal(202); // derive the grantId and protocol from the grant record const revokeWrite = await PermissionsProtocol.createRevocation({ @@ -233,7 +233,7 @@ export function testPermissions(): void { requestToAlice.recordsWrite.message, { dataStream: DataStream.fromBytes(requestToAlice.permissionRequestBytes) } ); - expect(requestWriteReply.status.code).to.equal(204); + expect(requestWriteReply.status.code).to.equal(202); // 2. Alice queries her DWN for new permission requests const requestQuery = await RecordsQuery.create({ @@ -283,7 +283,7 @@ export function testPermissions(): void { grantWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(grantWrite.permissionGrantBytes) } ); - expect(grantWriteReply.status.code).to.equal(204); + expect(grantWriteReply.status.code).to.equal(202); // 5. Verify that Bob can query the permission grant from Alice's DWN (even though Alice can also send it directly to Bob) const grantQuery = await RecordsQuery.create({ @@ -340,7 +340,7 @@ export function testPermissions(): void { revokeWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeWrite.permissionRevocationBytes) } ); - expect(revokeWriteReply.status.code).to.equal(204); + expect(revokeWriteReply.status.code).to.equal(202); // 9. Verify that any third-party can fetch the revocation status of the permission grant const revocationReadReply2 = await dwn.processMessage(alice.did, revocationRead.message); @@ -419,7 +419,7 @@ export function testPermissions(): void { const grantWriteReply = await dwn.processMessage(alice.did, grantWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(grantWrite.permissionGrantBytes) }); - expect(grantWriteReply.status.code).to.equal(204); + expect(grantWriteReply.status.code).to.equal(202); // attempt to revoke the grant without a protocol set const permissionRevocationBytes = Encoder.objectToBytes({ description: 'Revoking the grant' }); @@ -475,7 +475,7 @@ export function testPermissions(): void { const revokeWriteReply = await dwn.processMessage(alice.did, revokeWrite.message, { dataStream: DataStream.fromBytes(permissionRevocationBytes) }); - expect(revokeWriteReply.status.code).to.equal(204); + expect(revokeWriteReply.status.code).to.equal(202); }); // These set of tets are primarily to ensure SchemaValidation passes for the various permission request and grant messages and their scopes @@ -500,7 +500,7 @@ export function testPermissions(): void { const messagesQueryPermissionsReply = await dwn.processMessage(alice.did, messagesQueryPermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(messagesQueryPermissions.permissionGrantBytes) }); - expect(messagesQueryPermissionsReply.status.code).to.equal(204); + expect(messagesQueryPermissionsReply.status.code).to.equal(202); }); it('MessagesRead', async () => { @@ -523,7 +523,7 @@ export function testPermissions(): void { const messagesReadPermissionsReply = await dwn.processMessage(alice.did, messagesReadPermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(messagesReadPermissions.permissionGrantBytes) }); - expect(messagesReadPermissionsReply.status.code).to.equal(204); + expect(messagesReadPermissionsReply.status.code).to.equal(202); }); it('MessagesSubscribe', async () => { @@ -546,7 +546,7 @@ export function testPermissions(): void { const messagesSubscribePermissionsReply = await dwn.processMessage(alice.did, messagesSubscribePermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(messagesSubscribePermissions.permissionGrantBytes) }); - expect(messagesSubscribePermissionsReply.status.code).to.equal(204); + expect(messagesSubscribePermissionsReply.status.code).to.equal(202); }); it('RecordsDelete', async () => { @@ -570,7 +570,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(204); + expect(withContextIdReply.status.code).to.equal(202); // create a permission request with protocol and protocolPath const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -589,7 +589,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(204); + expect(withProtocolPathReply.status.code).to.equal(202); }); it('RecordsQuery', async () => { @@ -614,7 +614,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(204); + expect(withContextIdReply.status.code).to.equal(202); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createRequest({ @@ -632,7 +632,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(bob.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionRequestBytes) }); - expect(withProtocolPathReply.status.code).to.equal(204); + expect(withProtocolPathReply.status.code).to.equal(202); }); it('RecordsRead', async () => { @@ -657,7 +657,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(204); + expect(withContextIdReply.status.code).to.equal(202); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -677,7 +677,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(204); + expect(withProtocolPathReply.status.code).to.equal(202); }); it('RecordsSubscribe', async () => { @@ -702,7 +702,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(204); + expect(withContextIdReply.status.code).to.equal(202); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -722,7 +722,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(204); + expect(withProtocolPathReply.status.code).to.equal(202); }); it('RecordsWrite', async () => { @@ -747,7 +747,7 @@ export function testPermissions(): void { const withContextIdReply = await dwn.processMessage(alice.did, withContextId.recordsWrite.message, { dataStream: DataStream.fromBytes(withContextId.permissionGrantBytes) }); - expect(withContextIdReply.status.code).to.equal(204); + expect(withContextIdReply.status.code).to.equal(202); // create a permission request with protocol and protocolPath scope const withProtocolPath = await PermissionsProtocol.createGrant({ @@ -767,7 +767,7 @@ export function testPermissions(): void { const withProtocolPathReply = await dwn.processMessage(alice.did, withProtocolPath.recordsWrite.message, { dataStream: DataStream.fromBytes(withProtocolPath.permissionGrantBytes) }); - expect(withProtocolPathReply.status.code).to.equal(204); + expect(withProtocolPathReply.status.code).to.equal(202); }); it('ProtocolsQuery', async () => { @@ -789,7 +789,7 @@ export function testPermissions(): void { const protocolQueryPermissionsReply = await dwn.processMessage(alice.did, protocolQueryPermissions.recordsWrite.message, { dataStream: DataStream.fromBytes(protocolQueryPermissions.permissionGrantBytes) }); - expect(protocolQueryPermissionsReply.status.code).to.equal(204); + expect(protocolQueryPermissionsReply.status.code).to.equal(202); }); }); @@ -819,7 +819,7 @@ export function testPermissions(): void { requestToAlice.recordsWrite.message, { dataStream: DataStream.fromBytes(requestToAlice.permissionRequestBytes) } ); - expect(requestToAliceReply.status.code).to.equal(204); + expect(requestToAliceReply.status.code).to.equal(202); expect(validateScopeSpy.calledOnce).to.be.true; // create a grant @@ -836,7 +836,7 @@ export function testPermissions(): void { grantedToBob.recordsWrite.message, { dataStream: DataStream.fromBytes(grantedToBob.permissionGrantBytes) } ); - expect(grantWriteReply.status.code).to.equal(204); + expect(grantWriteReply.status.code).to.equal(202); expect(validateScopeSpy.calledTwice).to.be.true; // called twice, once for the request and once for the grant }); diff --git a/tests/features/protocol-create-action.spec.ts b/tests/features/protocol-create-action.spec.ts index 8db9c3d8d..73072ebab 100644 --- a/tests/features/protocol-create-action.spec.ts +++ b/tests/features/protocol-create-action.spec.ts @@ -156,7 +156,7 @@ export function testProtocolCreateAction(): void { }); const adminBobRecordsWriteReply = await dwn.processMessage(alice.did, adminBobRecordsWrite.message, { dataStream: adminBobRecordsWrite.dataStream }); - expect(adminBobRecordsWriteReply.status.code).to.equal(204); + expect(adminBobRecordsWriteReply.status.code).to.equal(202); // Verify that Bob can create `foo` by invoking the admin role. const bobRoleAuthorizedFoo = await RecordsWrite.create( @@ -173,7 +173,7 @@ export function testProtocolCreateAction(): void { ); const bobRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, bobRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobRoleAuthorizedCreateReply.status.code).to.equal(204); + expect(bobRoleAuthorizedCreateReply.status.code).to.equal(202); // Verify that Bob cannot update `foo` const bobUnauthorizedFooUpdate = await RecordsWrite.createFrom( @@ -203,7 +203,7 @@ export function testProtocolCreateAction(): void { ); const bobBarCreateReply = await dwn.processMessage(alice.did, bobAuthorAuthorizedBar.message, { dataStream: DataStream.fromBytes(bobBarBytes) }); - expect(bobBarCreateReply.status.code).to.equal(204); + expect(bobBarCreateReply.status.code).to.equal(202); // Verify that Bob cannot update `bar` const bobUnauthorizedBarUpdate = await RecordsWrite.createFrom( @@ -233,7 +233,7 @@ export function testProtocolCreateAction(): void { ); const carolBarCreateReply = await dwn.processMessage(alice.did, carolRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(carolBarBytes) }); - expect(carolBarCreateReply.status.code).to.equal(204); + expect(carolBarCreateReply.status.code).to.equal(202); // Verify that Carol cannot update `bar` const carolUnauthorizedBarUpdate = await RecordsWrite.createFrom( @@ -281,7 +281,7 @@ export function testProtocolCreateAction(): void { ); const danielBazCreateReply = await dwn.processMessage(alice.did, danielAnyoneAuthorizedBar.message, { dataStream: DataStream.fromBytes(danielBazBytes) }); - expect(danielBazCreateReply.status.code).to.equal(204); + expect(danielBazCreateReply.status.code).to.equal(202); // Verify that Daniel cannot update `baz` const danielUnauthorizedBazUpdate = await RecordsWrite.createFrom( diff --git a/tests/features/protocol-delete-action.spec.ts b/tests/features/protocol-delete-action.spec.ts index 7a969995d..42eb7020f 100644 --- a/tests/features/protocol-delete-action.spec.ts +++ b/tests/features/protocol-delete-action.spec.ts @@ -114,7 +114,7 @@ export function testProtocolDeleteAction(): void { }); const userBobRecordsWriteReply = await dwn.processMessage(alice.did, userBobRecordsWrite.message, { dataStream: userBobRecordsWrite.dataStream }); - expect(userBobRecordsWriteReply.status.code).to.equal(204); + expect(userBobRecordsWriteReply.status.code).to.equal(202); const userCarolRecordsWrite = await TestDataGenerator.generateRecordsWrite({ author : alice, @@ -124,7 +124,7 @@ export function testProtocolDeleteAction(): void { }); const userCarolRecordsWriteReply = await dwn.processMessage(alice.did, userCarolRecordsWrite.message, { dataStream: userCarolRecordsWrite.dataStream }); - expect(userCarolRecordsWriteReply.status.code).to.equal(204); + expect(userCarolRecordsWriteReply.status.code).to.equal(202); // 3. Bob creates a `foo` by invoking the user role. const bobFooBytes = TestDataGenerator.randomBytes(100); @@ -141,7 +141,7 @@ export function testProtocolDeleteAction(): void { ); const bobRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, bobRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobRoleAuthorizedCreateReply.status.code).to.equal(204); + expect(bobRoleAuthorizedCreateReply.status.code).to.equal(202); // 4. Verify that Bob can delete his `foo` const bobAuthorizedFooDelete = await RecordsDelete.create( @@ -180,7 +180,7 @@ export function testProtocolDeleteAction(): void { ); const carolRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, carolRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolRoleAuthorizedCreateReply.status.code).to.equal(204); + expect(carolRoleAuthorizedCreateReply.status.code).to.equal(202); // 6. Verify that Bob cannot delete Carol's `foo` const bobUnauthorizedFooDelete = await RecordsDelete.create( @@ -263,7 +263,7 @@ export function testProtocolDeleteAction(): void { protocolPath : 'foo' }); const fooForBobReply = await dwn.processMessage(alice.did, fooForBob.message, { dataStream: fooForBob.dataStream }); - expect(fooForBobReply.status.code).to.equal(204); + expect(fooForBobReply.status.code).to.equal(202); // 3. Alice creates a `foo` with Carol being the recipient, so that Carol can create `bar`. const fooForCarol = await TestDataGenerator.generateRecordsWrite({ @@ -273,7 +273,7 @@ export function testProtocolDeleteAction(): void { protocolPath : 'foo' }); const fooForCarolReply = await dwn.processMessage(alice.did, fooForCarol.message, { dataStream: fooForCarol.dataStream }); - expect(fooForCarolReply.status.code).to.equal(204); + expect(fooForCarolReply.status.code).to.equal(202); // 4. Bob creates a recipient-authorized `bar`. const bobBarBytes = TestDataGenerator.randomBytes(100); @@ -290,7 +290,7 @@ export function testProtocolDeleteAction(): void { ); const bobRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, bobRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(bobBarBytes) }); - expect(bobRecipientAuthorizedBarReply.status.code).to.equal(204); + expect(bobRecipientAuthorizedBarReply.status.code).to.equal(202); // 5. Bob creates a author-authorized `baz` after his `bar`. const bobBazBytes = TestDataGenerator.randomBytes(100); @@ -307,7 +307,7 @@ export function testProtocolDeleteAction(): void { ); const bobAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, bobAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(bobBazBytes) }); - expect(bobAuthorAuthorizedBazReply.status.code).to.equal(204); + expect(bobAuthorAuthorizedBazReply.status.code).to.equal(202); // 6. Carol creates a recipient-authorized `bar`. const carolBarBytes = TestDataGenerator.randomBytes(100); @@ -324,7 +324,7 @@ export function testProtocolDeleteAction(): void { ); const carolRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, carolRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(carolBarBytes) }); - expect(carolRecipientAuthorizedBarReply.status.code).to.equal(204); + expect(carolRecipientAuthorizedBarReply.status.code).to.equal(202); // 7. Carol creates a author-authorized `baz` after her `bar`. const carolBazBytes = TestDataGenerator.randomBytes(100); @@ -341,7 +341,7 @@ export function testProtocolDeleteAction(): void { ); const carolAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, carolAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(carolBazBytes) }); - expect(carolAuthorAuthorizedBazReply.status.code).to.equal(204); + expect(carolAuthorAuthorizedBazReply.status.code).to.equal(202); // 8. Verify that Bob can delete his `baz` const bobAuthorizedBazDelete = await RecordsDelete.create( @@ -453,7 +453,7 @@ export function testProtocolDeleteAction(): void { ); const bobAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, bobAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(204); + expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(202); // 3. Carol creates a anyone-authorized `foo`. const carolFooBytes = TestDataGenerator.randomBytes(100); @@ -469,7 +469,7 @@ export function testProtocolDeleteAction(): void { ); const carolAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, carolAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(204); + expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(202); // 4. Verify that Bob can delete his `foo`. const bobAuthorizedFooDelete = await RecordsDelete.create( diff --git a/tests/features/protocol-update-action.spec.ts b/tests/features/protocol-update-action.spec.ts index bf399b76a..9ac08d935 100644 --- a/tests/features/protocol-update-action.spec.ts +++ b/tests/features/protocol-update-action.spec.ts @@ -114,7 +114,7 @@ export function testProtocolUpdateAction(): void { }); const userBobRecordsWriteReply = await dwn.processMessage(alice.did, userBobRecordsWrite.message, { dataStream: userBobRecordsWrite.dataStream }); - expect(userBobRecordsWriteReply.status.code).to.equal(204); + expect(userBobRecordsWriteReply.status.code).to.equal(202); const userCarolRecordsWrite = await TestDataGenerator.generateRecordsWrite({ author : alice, @@ -124,7 +124,7 @@ export function testProtocolUpdateAction(): void { }); const userCarolRecordsWriteReply = await dwn.processMessage(alice.did, userCarolRecordsWrite.message, { dataStream: userCarolRecordsWrite.dataStream }); - expect(userCarolRecordsWriteReply.status.code).to.equal(204); + expect(userCarolRecordsWriteReply.status.code).to.equal(202); // 3. Bob creates a `foo` by invoking the user role. const bobFooBytes = TestDataGenerator.randomBytes(100); @@ -141,7 +141,7 @@ export function testProtocolUpdateAction(): void { ); const bobRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, bobRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobRoleAuthorizedCreateReply.status.code).to.equal(204); + expect(bobRoleAuthorizedCreateReply.status.code).to.equal(202); // 4. Verify that Bob can update his `foo` const bobFooNewBytes = TestDataGenerator.randomBytes(100); @@ -184,7 +184,7 @@ export function testProtocolUpdateAction(): void { ); const carolRoleAuthorizedCreateReply = await dwn.processMessage(alice.did, carolRoleAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolRoleAuthorizedCreateReply.status.code).to.equal(204); + expect(carolRoleAuthorizedCreateReply.status.code).to.equal(202); // 6. Verify that carol can update her `foo` const carolFooNewBytes = TestDataGenerator.randomBytes(100); @@ -282,7 +282,7 @@ export function testProtocolUpdateAction(): void { protocolPath : 'foo' }); const fooForBobReply = await dwn.processMessage(alice.did, fooForBob.message, { dataStream: fooForBob.dataStream }); - expect(fooForBobReply.status.code).to.equal(204); + expect(fooForBobReply.status.code).to.equal(202); // 3. Alice creates a `foo` with Carol being the recipient, so that Carol can create `bar`. const fooForCarol = await TestDataGenerator.generateRecordsWrite({ @@ -292,7 +292,7 @@ export function testProtocolUpdateAction(): void { protocolPath : 'foo' }); const fooForCarolReply = await dwn.processMessage(alice.did, fooForCarol.message, { dataStream: fooForCarol.dataStream }); - expect(fooForCarolReply.status.code).to.equal(204); + expect(fooForCarolReply.status.code).to.equal(202); // 4. Bob creates a recipient-authorized `bar`. const bobBarBytes = TestDataGenerator.randomBytes(100); @@ -309,7 +309,7 @@ export function testProtocolUpdateAction(): void { ); const bobRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, bobRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(bobBarBytes) }); - expect(bobRecipientAuthorizedBarReply.status.code).to.equal(204); + expect(bobRecipientAuthorizedBarReply.status.code).to.equal(202); // 5. Carol creates a recipient-authorized `bar`. const carolBarBytes = TestDataGenerator.randomBytes(100); @@ -326,7 +326,7 @@ export function testProtocolUpdateAction(): void { ); const carolRecipientAuthorizedBarReply = await dwn.processMessage(alice.did, carolRecipientAuthorizedBar.message, { dataStream: DataStream.fromBytes(carolBarBytes) }); - expect(carolRecipientAuthorizedBarReply.status.code).to.equal(204); + expect(carolRecipientAuthorizedBarReply.status.code).to.equal(202); // 6. Verify that Bob can update his `bar`. const bobBarNewBytes = TestDataGenerator.randomBytes(100); @@ -382,7 +382,7 @@ export function testProtocolUpdateAction(): void { ); const bobAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, bobAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(bobBazBytes) }); - expect(bobAuthorAuthorizedBazReply.status.code).to.equal(204); + expect(bobAuthorAuthorizedBazReply.status.code).to.equal(202); // 9. Carol creates a author-authorized `baz` after her `bar`. const carolBazBytes = TestDataGenerator.randomBytes(100); @@ -399,7 +399,7 @@ export function testProtocolUpdateAction(): void { ); const carolAuthorAuthorizedBazReply = await dwn.processMessage(alice.did, carolAuthorAuthorizedBaz.message, { dataStream: DataStream.fromBytes(carolBazBytes) }); - expect(carolAuthorAuthorizedBazReply.status.code).to.equal(204); + expect(carolAuthorAuthorizedBazReply.status.code).to.equal(202); // 10. Verify that Bob can update his `baz` const bobBazNewBytes = TestDataGenerator.randomBytes(100); @@ -494,7 +494,7 @@ export function testProtocolUpdateAction(): void { ); const bobAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, bobAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(bobFooBytes) }); - expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(204); + expect(bobAnyoneAuthorizedFooReply.status.code).to.equal(202); // 3. Carol creates a anyone-authorized `foo`. const carolFooBytes = TestDataGenerator.randomBytes(100); @@ -510,7 +510,7 @@ export function testProtocolUpdateAction(): void { ); const carolAnyoneAuthorizedFooReply = await dwn.processMessage(alice.did, carolAnyoneAuthorizedFoo.message, { dataStream: DataStream.fromBytes(carolFooBytes) }); - expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(204); + expect(carolAnyoneAuthorizedFooReply.status.code).to.equal(202); // 4. Verify that Bob can update his `foo`. const bobFooNewBytes = TestDataGenerator.randomBytes(100); diff --git a/tests/features/records-prune.spec.ts b/tests/features/records-prune.spec.ts index d0f824b00..47fec043b 100644 --- a/tests/features/records-prune.spec.ts +++ b/tests/features/records-prune.spec.ts @@ -90,11 +90,11 @@ export function testRecordsPrune(): void { const foo1 = await RecordsWrite.create(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: DataStream.fromBytes(fooData) }); - expect(foo1WriteResponse.status.code).equals(204); + expect(foo1WriteResponse.status.code).equals(202); const foo2 = await RecordsWrite.create(fooOptions); const foo2WriteResponse = await dwn.processMessage(alice.did, foo2.message, { dataStream: DataStream.fromBytes(fooData) }); - expect(foo2WriteResponse.status.code).equals(204); + expect(foo2WriteResponse.status.code).equals(202); // write 2 bars under foo1 with data large enough to be required to be stored in the data store so we can test purge in data store const barData = TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded + 1); @@ -110,11 +110,11 @@ export function testRecordsPrune(): void { const bar1 = await RecordsWrite.create({ ...barOptions }); const bar1WriteResponse = await dwn.processMessage(alice.did, bar1.message, { dataStream: DataStream.fromBytes(barData) }); - expect(bar1WriteResponse.status.code).equals(204); + expect(bar1WriteResponse.status.code).equals(202); const bar2 = await RecordsWrite.create({ ...barOptions }); const bar2WriteResponse = await dwn.processMessage(alice.did, bar2.message, { dataStream: DataStream.fromBytes(barData) }); - expect(bar2WriteResponse.status.code).equals(204); + expect(bar2WriteResponse.status.code).equals(202); // write 2 bazes under bar1, each has more than 1 message associated with the record so we can test multi-message purge const bazData = TestDataGenerator.randomBytes(100); @@ -130,11 +130,11 @@ export function testRecordsPrune(): void { const baz1 = await RecordsWrite.create({ ...bazOptions }); const baz1WriteResponse = await dwn.processMessage(alice.did, baz1.message, { dataStream: DataStream.fromBytes(bazData) }); - expect(baz1WriteResponse.status.code).equals(204); + expect(baz1WriteResponse.status.code).equals(202); const baz2 = await RecordsWrite.create({ ...bazOptions }); const baz2WriteResponse = await dwn.processMessage(alice.did, baz2.message, { dataStream: DataStream.fromBytes(bazData) }); - expect(baz2WriteResponse.status.code).equals(204); + expect(baz2WriteResponse.status.code).equals(202); // make latest state of baz1 a `RecordsWrite` const newBaz1Data = TestDataGenerator.randomBytes(100); @@ -280,7 +280,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(204); + expect(postWriteResponse.status.code).equals(202); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -294,7 +294,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(204); + expect(attachmentWriteResponse.status.code).equals(202); // 3. Verify Bob cannot prune the records if `prune` is not set to `true` in RecordsDelete. const unauthorizedPostPrune = await RecordsDelete.create({ @@ -358,7 +358,7 @@ export function testRecordsPrune(): void { const message = await RecordsWrite.create(messageOptions); const messageWriteResponse = await dwn.processMessage(alice.did, message.message, { dataStream: DataStream.fromBytes(messageData) }); - expect(messageWriteResponse.status.code).equals(204); + expect(messageWriteResponse.status.code).equals(202); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -372,7 +372,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(204); + expect(attachmentWriteResponse.status.code).equals(202); // 3. Verify Bob cannot prune the records. const messagePrune = await RecordsDelete.create({ @@ -459,7 +459,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(204); + expect(postWriteResponse.status.code).equals(202); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -473,7 +473,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(204); + expect(attachmentWriteResponse.status.code).equals(202); // 3. Verify Carol cannot prune the records if `prune` is not set to `true` in RecordsDelete. const unauthorizedPostPrune = await RecordsDelete.create({ @@ -571,7 +571,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(204); + expect(postWriteResponse.status.code).equals(202); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -585,7 +585,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(204); + expect(attachmentWriteResponse.status.code).equals(202); // 3. Verify Carol cannot prune the records. const postPrune = await RecordsDelete.create({ @@ -670,7 +670,7 @@ export function testRecordsPrune(): void { const post = await RecordsWrite.create(postOptions); const postWriteResponse = await dwn.processMessage(alice.did, post.message, { dataStream: DataStream.fromBytes(postData) }); - expect(postWriteResponse.status.code).equals(204); + expect(postWriteResponse.status.code).equals(202); const attachmentData = TestDataGenerator.randomBytes(100); const attachmentOptions = { @@ -684,7 +684,7 @@ export function testRecordsPrune(): void { const attachment = await RecordsWrite.create(attachmentOptions); const attachmentWriteResponse = await dwn.processMessage(alice.did, attachment.message, { dataStream: DataStream.fromBytes(attachmentData) }); - expect(attachmentWriteResponse.status.code).equals(204); + expect(attachmentWriteResponse.status.code).equals(202); // 3. Verify Bob cannot prune the records. const unauthorizedPostPrune = await RecordsDelete.create({ diff --git a/tests/features/records-tags.spec.ts b/tests/features/records-tags.spec.ts index 465c8d947..e6a8ea717 100644 --- a/tests/features/records-tags.spec.ts +++ b/tests/features/records-tags.spec.ts @@ -391,7 +391,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a tag value that does not match the boolean type', async () => { @@ -452,7 +452,7 @@ export function testRecordsTags(): void { }); const fooRecord2Reply = await dwn.processMessage(alice.did, fooRecord2.message, { dataStream: fooRecord2.dataStream }); - expect(fooRecord2Reply.status.code).to.equal(204); + expect(fooRecord2Reply.status.code).to.equal(202); }); it('should reject a tag value that does not match the number type', async () => { @@ -513,7 +513,7 @@ export function testRecordsTags(): void { }); const fooRecord2Reply = await dwn.processMessage(alice.did, fooRecord2.message, { dataStream: fooRecord2.dataStream }); - expect(fooRecord2Reply.status.code).to.equal(204); + expect(fooRecord2Reply.status.code).to.equal(202); // positive tests with a decimal number const fooRecord3 = await TestDataGenerator.generateRecordsWrite({ @@ -527,7 +527,7 @@ export function testRecordsTags(): void { }); const fooRecord3Reply = await dwn.processMessage(alice.did, fooRecord3.message, { dataStream: fooRecord3.dataStream }); - expect(fooRecord3Reply.status.code).to.equal(204); + expect(fooRecord3Reply.status.code).to.equal(202); }); it('should reject a tag value that does not match the integer type', async () => { @@ -587,7 +587,7 @@ export function testRecordsTags(): void { }); const fooRecord2Reply = await dwn.processMessage(alice.did, fooRecord2.message, { dataStream: fooRecord2.dataStream }); - expect(fooRecord2Reply.status.code).to.equal(204); + expect(fooRecord2Reply.status.code).to.equal(202); }); it('should reject a record with a tag value that does not match a given enum in the protocol definition', async () => { @@ -654,7 +654,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a record with a tag value that is not within the `minimum` and `maximum` range', async () => { @@ -736,7 +736,7 @@ export function testRecordsTags(): void { // should pass const validFooMaxRecordReply = await dwn.processMessage(alice.did, validFooMaxRecord.message, { dataStream: validFooMaxRecord.dataStream }); - expect(validFooMaxRecordReply.status.code).to.equal(204); + expect(validFooMaxRecordReply.status.code).to.equal(202); // write a foo record with a maximum `score` of 0. const validFooMinRecord = await TestDataGenerator.generateRecordsWrite({ @@ -750,7 +750,7 @@ export function testRecordsTags(): void { }); // should pass const validFooMinRecordReply = await dwn.processMessage(alice.did, validFooMinRecord.message, { dataStream: validFooMinRecord.dataStream }); - expect(validFooMinRecordReply.status.code).to.equal(204); + expect(validFooMinRecordReply.status.code).to.equal(202); // write a foo record within the range const validFooRecord = await TestDataGenerator.generateRecordsWrite({ @@ -764,7 +764,7 @@ export function testRecordsTags(): void { }); // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a record with a tag value that is not within the `exclusiveMinimum` and `exclusiveMaximum` range', async () => { @@ -846,7 +846,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject tag values that are not within the `minLength` and `maxLength` values', async () => { @@ -931,7 +931,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject tag values that do not contain the number of items within the `minItems` and `maxItems` values', async () => { @@ -1017,7 +1017,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a value within an array that should only include numbers', async () => { @@ -1082,7 +1082,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a value within an array that should only include integers', async () => { @@ -1147,7 +1147,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject tag values that do not contain the number of items within the `minContains` and `maxContains` values', async () => { @@ -1241,7 +1241,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject tag values that do not follow the constraints of the `uniqueItems` value', async () => { @@ -1307,7 +1307,7 @@ export function testRecordsTags(): void { // should pass const uniqueItemsReply = await dwn.processMessage(alice.did, uniqueItemsRecord.message, { dataStream: uniqueItemsRecord.dataStream }); - expect(uniqueItemsReply.status.code).to.equal(204); + expect(uniqueItemsReply.status.code).to.equal(202); }); it('should only accept a record containing tags required by $requiredTags', async () => { @@ -1367,7 +1367,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should accept any tag if $allowUndefinedTags is set to true', async () => { @@ -1413,7 +1413,7 @@ export function testRecordsTags(): void { }); const fooRecordReply = await dwn.processMessage(alice.did, fooRecord.message, { dataStream: fooRecord.dataStream }); - expect(fooRecordReply.status.code).to.equal(204); + expect(fooRecordReply.status.code).to.equal(202); }); describe('contains', () => { @@ -1486,7 +1486,7 @@ export function testRecordsTags(): void { // should pass const validEnumReply = await dwn.processMessage(alice.did, validEnumRecord.message, { dataStream: validEnumRecord.dataStream }); - expect(validEnumReply.status.code).to.equal(204); + expect(validEnumReply.status.code).to.equal(202); }); it('should reject a record tag that does not contain a value within the `minimum` and `maximum` range ', async () => { @@ -1559,7 +1559,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a record tag that does not contain a value within the `exclusiveMinimum` and `exclusiveMaximum` range ', async () => { @@ -1632,7 +1632,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a record tag that does not contain a value within the `minLength` and `maxLength` range ', async () => { @@ -1704,7 +1704,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); }); @@ -1775,7 +1775,7 @@ export function testRecordsTags(): void { // should pass const validEnumReply = await dwn.processMessage(alice.did, validEnumRecord.message, { dataStream: validEnumRecord.dataStream }); - expect(validEnumReply.status.code).to.equal(204); + expect(validEnumReply.status.code).to.equal(202); }); it('should reject a record tag which all items do not have a value within the `minimum` and `maximum` range ', async () => { @@ -1863,7 +1863,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a record tag which all items do not have a value within the `exclusiveMinimum` and `exclusiveMaximum` range ', async () => { @@ -1951,7 +1951,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); it('should reject a record tag that does not contain a value within the `minLength` and `maxLength` range ', async () => { @@ -2038,7 +2038,7 @@ export function testRecordsTags(): void { // should pass const validFooRecordReply = await dwn.processMessage(alice.did, validFooRecord.message, { dataStream: validFooRecord.dataStream }); - expect(validFooRecordReply.status.code).to.equal(204); + expect(validFooRecordReply.status.code).to.equal(202); }); }); }); @@ -2067,7 +2067,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); // verify the record was written const tagsRecord1Read = await RecordsRead.create({ @@ -2101,7 +2101,7 @@ export function testRecordsTags(): void { // write the record const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); // verify the record was written const tagsRecord1Read = await RecordsRead.create({ @@ -2179,7 +2179,7 @@ export function testRecordsTags(): void { // write the record const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); // verify that construct Indexes was called expect(constructIndexesSpy.callCount).to.equal(1); @@ -2221,7 +2221,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -2279,7 +2279,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); // do an exact match for the tag value const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ @@ -2343,7 +2343,7 @@ export function testRecordsTags(): void { }); const tagsRecordTrueReply = await dwn.processMessage(alice.did, tagsRecordTrue.message, { dataStream: tagsRecordTrue.dataStream }); - expect(tagsRecordTrueReply.status.code).to.equal(204); + expect(tagsRecordTrueReply.status.code).to.equal(202); // write a record with a false boolean value tag const tagsRecordFalse = await TestDataGenerator.generateRecordsWrite({ @@ -2356,7 +2356,7 @@ export function testRecordsTags(): void { }); const tagsRecordFalseReply = await dwn.processMessage(alice.did, tagsRecordFalse.message, { dataStream: tagsRecordFalse.dataStream }); - expect(tagsRecordFalseReply.status.code).to.equal(204); + expect(tagsRecordFalseReply.status.code).to.equal(202); // query for records with a `booleanTag` set to true, should return the record with the true tag const tagsQueryMatchTrue = await TestDataGenerator.generateRecordsQuery({ @@ -2443,13 +2443,13 @@ export function testRecordsTags(): void { }); const aliceReply = await dwn.processMessage(alice.did, aliceRecord.message, { dataStream: aliceRecord.dataStream }); - expect(aliceReply.status.code).to.equal(204); + expect(aliceReply.status.code).to.equal(202); const bobReply = await dwn.processMessage(alice.did, bobRecord.message, { dataStream: bobRecord.dataStream }); - expect(bobReply.status.code).to.equal(204); + expect(bobReply.status.code).to.equal(202); const carolReply = await dwn.processMessage(alice.did, carolRecord.message, { dataStream: carolRecord.dataStream }); - expect(carolReply.status.code).to.equal(204); + expect(carolReply.status.code).to.equal(202); const danielReply = await dwn.processMessage(alice.did, danielRecord.message, { dataStream: danielRecord.dataStream }); - expect(danielReply.status.code).to.equal(204); + expect(danielReply.status.code).to.equal(202); // sanity query for all const queryForAll = await TestDataGenerator.generateRecordsQuery({ @@ -2535,9 +2535,9 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); const tagsRecord2Reply = await dwn.processMessage(alice.did, tagsRecord2.message, { dataStream: tagsRecord2.dataStream }); - expect(tagsRecord2Reply.status.code).to.equal(204); + expect(tagsRecord2Reply.status.code).to.equal(202); // control record that has a different prefix const tagsRecord3 = await TestDataGenerator.generateRecordsWrite({ @@ -2549,7 +2549,7 @@ export function testRecordsTags(): void { } }); const tagsRecord3Reply = await dwn.processMessage(alice.did, tagsRecord3.message, { dataStream: tagsRecord3.dataStream }); - expect(tagsRecord3Reply.status.code).to.equal(204); + expect(tagsRecord3Reply.status.code).to.equal(202); // a prefix search will return only the records matching the prefix const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ @@ -2628,13 +2628,13 @@ export function testRecordsTags(): void { }); const aliceReply = await dwn.processMessage(alice.did, aliceRecord.message, { dataStream: aliceRecord.dataStream }); - expect(aliceReply.status.code).to.equal(204); + expect(aliceReply.status.code).to.equal(202); const bobReply = await dwn.processMessage(alice.did, bobRecord.message, { dataStream: bobRecord.dataStream }); - expect(bobReply.status.code).to.equal(204); + expect(bobReply.status.code).to.equal(202); const carolReply = await dwn.processMessage(alice.did, carolRecord.message, { dataStream: carolRecord.dataStream }); - expect(carolReply.status.code).to.equal(204); + expect(carolReply.status.code).to.equal(202); const danielReply = await dwn.processMessage(alice.did, danielRecord.message, { dataStream: danielRecord.dataStream }); - expect(danielReply.status.code).to.equal(204); + expect(danielReply.status.code).to.equal(202); // sanity query for all const queryForAll = await TestDataGenerator.generateRecordsQuery({ @@ -2726,7 +2726,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -2771,7 +2771,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -2818,7 +2818,7 @@ export function testRecordsTags(): void { }); const tagsRecord1Reply = await dwn.processMessage(alice.did, tagsRecord1.message, { dataStream: tagsRecord1.dataStream }); - expect(tagsRecord1Reply.status.code).to.equal(204); + expect(tagsRecord1Reply.status.code).to.equal(202); //sanity: query for the record const tagsQueryMatch = await TestDataGenerator.generateRecordsQuery({ diff --git a/tests/features/resumable-tasks.spec.ts b/tests/features/resumable-tasks.spec.ts index 5e2def69a..c90d090fc 100644 --- a/tests/features/resumable-tasks.spec.ts +++ b/tests/features/resumable-tasks.spec.ts @@ -102,7 +102,7 @@ export function testResumableTasks(): void { const recordsWrite = await RecordsWrite.create(messageOptions); const recordsWriteResponse = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: DataStream.fromBytes(data) }); - expect(recordsWriteResponse.status.code).equals(204); + expect(recordsWriteResponse.status.code).equals(202); // 2. Insert a resumable `RecordDelete` task into the resumable task store bypassing message handler to avoid it being processed. @@ -186,7 +186,7 @@ export function testResumableTasks(): void { const recordsWrite = await RecordsWrite.create(messageOptions); const recordsWriteResponse = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: DataStream.fromBytes(data) }); - expect(recordsWriteResponse.status.code).equals(204); + expect(recordsWriteResponse.status.code).equals(202); recordsWrites.push(recordsWrite); } @@ -336,7 +336,7 @@ export function testResumableTasks(): void { const recordsWrite = await RecordsWrite.create(messageOptions); const recordsWriteResponse = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: DataStream.fromBytes(data) }); - expect(recordsWriteResponse.status.code).equals(204); + expect(recordsWriteResponse.status.code).equals(202); // 3. Submit a `RecordsDelete` without awaiting on its completion. const resumableTaskRegisterSpy = sinon.spy(resumableTaskStore, 'register'); diff --git a/tests/handlers/messages-query.spec.ts b/tests/handlers/messages-query.spec.ts index b3cf16533..18210faf3 100644 --- a/tests/handlers/messages-query.spec.ts +++ b/tests/handlers/messages-query.spec.ts @@ -130,7 +130,7 @@ export function testMessagesQueryHandler(): void { }); const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const messageCid = await Message.getCid(message); expectedCids.push(messageCid); } @@ -154,7 +154,7 @@ export function testMessagesQueryHandler(): void { author : alice }); const additionalReply = await dwn.processMessage(alice.did, additionalMessage, { dataStream: additionalDataStream }); - expect(additionalReply.status.code).to.equal(204); + expect(additionalReply.status.code).to.equal(202); // query for messages beyond the cursor const { message: messagesAfterCursor } = await TestDataGenerator.generateMessagesQuery({ author: alice, cursor: reply.cursor }); @@ -183,7 +183,7 @@ export function testMessagesQueryHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(204); + expect(grantReply.status.code).to.equal(202); // configure the freeForAll protocol const { message: freeForAllConfigure } = await TestDataGenerator.generateProtocolsConfigure({ @@ -209,14 +209,14 @@ export function testMessagesQueryHandler(): void { }); const recordReply = await dwn.processMessage(alice.did, recordMessage, { dataStream: recordDataStream }); - expect(recordReply.status.code).to.equal(204); + expect(recordReply.status.code).to.equal(202); // write a random message const { message: randomMessage, dataStream: randomDataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const randomReply = await dwn.processMessage(alice.did, randomMessage, { dataStream: randomDataStream }); - expect(randomReply.status.code).to.equal(204); + expect(randomReply.status.code).to.equal(202); // bob uses the grant to query for all of these messages const { message: bobQuery } = await TestDataGenerator.generateMessagesQuery({ @@ -250,7 +250,7 @@ export function testMessagesQueryHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(204); + expect(grantReply.status.code).to.equal(202); // bob attempts to use the `RecordsWrite` grant on an `MessagesQuery` message const { message: bobQuery } = await TestDataGenerator.generateMessagesQuery({ @@ -277,7 +277,7 @@ export function testMessagesQueryHandler(): void { }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(204); + expect(grantReply.status.code).to.equal(202); // bob attempts to use the `MessagesSubscribe` grant on an `MessagesQuery` message const { message: bobQuery } = await TestDataGenerator.generateMessagesQuery({ @@ -325,7 +325,7 @@ export function testMessagesQueryHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(204); + expect(grant1Reply.status.code).to.equal(202); // bob uses the grant to query for protocol 1 messages const { message: bobQuery1 } = await TestDataGenerator.generateMessagesQuery({ @@ -377,7 +377,7 @@ export function testMessagesQueryHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(204); + expect(grant1Reply.status.code).to.equal(202); // bob uses the grant for protocol 1 to query for protocol 2 messages const { message: bobQuery1 } = await TestDataGenerator.generateMessagesQuery({ diff --git a/tests/handlers/messages-read.spec.ts b/tests/handlers/messages-read.spec.ts index 179475a39..b97f6afb9 100644 --- a/tests/handlers/messages-read.spec.ts +++ b/tests/handlers/messages-read.spec.ts @@ -136,7 +136,7 @@ export function testMessagesReadHandler(): void { // bob creates a record that alice will try and get const { message: recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: bob }); const { status } = await dwn.processMessage(bob.did, recordsWrite, { dataStream }); - expect(status.code).to.equal(204); + expect(status.code).to.equal(202); // alice tries to read the message const { message } = await TestDataGenerator.generateMessagesRead({ @@ -159,7 +159,7 @@ export function testMessagesReadHandler(): void { }); const reply = await dwn.processMessage(alice.did, recordsWrite, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const recordsWriteMessageCid = await Message.getCid(recordsWrite); const { message } = await TestDataGenerator.generateMessagesRead({ @@ -190,7 +190,7 @@ export function testMessagesReadHandler(): void { }); const reply = await dwn.processMessage(alice.did, recordsWrite, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const recordsWriteMessageCid = await Message.getCid(recordsWrite); const { message } = await TestDataGenerator.generateMessagesRead({ @@ -224,7 +224,7 @@ export function testMessagesReadHandler(): void { const initialMessageCid = await Message.getCid(recordsWriteMessage); let reply = await dwn.processMessage(alice.did, recordsWriteMessage, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const { recordsWrite: updateMessage, dataStream: updateDataStream } = await TestDataGenerator.generateFromRecordsWrite({ author : alice, @@ -358,7 +358,7 @@ export function testMessagesReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant scoped to a RecordsWrite and the protocol const permissionGrant = await PermissionsProtocol.createGrant({ @@ -377,7 +377,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob tries to MessagesRead using the RecordsWrite grant const messagesRead = await TestDataGenerator.generateMessagesRead({ @@ -402,7 +402,7 @@ export function testMessagesReadHandler(): void { author: alice, }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const messageCid = await Message.getCid(message); // Alice issues a permission grant allowing Bob to read any record in her DWN @@ -417,7 +417,7 @@ export function testMessagesReadHandler(): void { }); const grantDataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const grantReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream: grantDataStream }); - expect(grantReply.status.code).to.equal(204); + expect(grantReply.status.code).to.equal(202); // Bob invokes that grant to read a record from Alice's DWN const messagesRead = await TestDataGenerator.generateMessagesRead({ @@ -478,7 +478,7 @@ export function testMessagesReadHandler(): void { permissionRequestCarol.recordsWrite.message, { dataStream: requestDataStreamCarol } ); - expect(permissionRequestWriteReplyCarol.status.code).to.equal(204); + expect(permissionRequestWriteReplyCarol.status.code).to.equal(202); // Alice gives Carol a grant to write records to the protocol const permissionGrantCarol = await PermissionsProtocol.createGrant({ @@ -495,7 +495,7 @@ export function testMessagesReadHandler(): void { permissionGrantCarol.recordsWrite.message, { dataStream: grantDataStreamCarol } ); - expect(permissionGrantWriteReplyCarol.status.code).to.equal(204); + expect(permissionGrantWriteReplyCarol.status.code).to.equal(202); const carolGrantMessageCiD = await Message.getCid(permissionGrantCarol.recordsWrite.message); // Alice writes a record associated with the protocol @@ -505,7 +505,7 @@ export function testMessagesReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); const aliceRecordMessageCid = await Message.getCid(recordsWrite.message); // Alice deletes a record associated with the protocol @@ -524,7 +524,7 @@ export function testMessagesReadHandler(): void { permissionGrantId : permissionGrantCarol.recordsWrite.message.recordId, }); const recordsWriteReplyCarol = await dwn.processMessage(alice.did, recordsWriteCarol.message, { dataStream: dataStreamCarol }); - expect(recordsWriteReplyCarol.status.code).to.equal(204); + expect(recordsWriteReplyCarol.status.code).to.equal(202); const carolRecordMessageCid = await Message.getCid(recordsWriteCarol.message); // Alice revokes Carol's grant @@ -538,7 +538,7 @@ export function testMessagesReadHandler(): void { permissionRevocationCarol.recordsWrite.message, { dataStream: permissionRevocationCarolDataStream } ); - expect(permissionRevocationCarolReply.status.code).to.equal(204); + expect(permissionRevocationCarolReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope MessagesRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -557,7 +557,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the message without using the permission grant const messagesReadWithoutGrant = await TestDataGenerator.generateMessagesRead({ @@ -660,7 +660,7 @@ export function testMessagesReadHandler(): void { author: alice, }); const recordsWriteControlReply = await dwn.processMessage(alice.did, recordsWriteControl.message, { dataStream: dataStreamControl }); - expect(recordsWriteControlReply.status.code).to.equal(204); + expect(recordsWriteControlReply.status.code).to.equal(202); // Bob is unable to read the control message const messagesReadControl = await TestDataGenerator.generateMessagesRead({ @@ -696,7 +696,7 @@ export function testMessagesReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope MessagesRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -715,7 +715,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record using the mismatched permission grant const messagesReadWithoutGrant = await TestDataGenerator.generateMessagesRead({ @@ -761,7 +761,7 @@ export function testMessagesReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Alice creates the records write and records delete messages const { recordsWrite } = await TestDataGenerator.generateRecordsWrite({ diff --git a/tests/handlers/messages-subscribe.spec.ts b/tests/handlers/messages-subscribe.spec.ts index 37bbd975f..e986c1a19 100644 --- a/tests/handlers/messages-subscribe.spec.ts +++ b/tests/handlers/messages-subscribe.spec.ts @@ -165,7 +165,7 @@ export function testMessagesSubscribeHandler(): void { const messageWrite = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, messageWrite.message, { dataStream: messageWrite.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const messageCid = await Message.getCid(messageWrite.message); // control: ensure that the event exists @@ -219,7 +219,7 @@ export function testMessagesSubscribeHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(204); + expect(grantReply.status.code).to.equal(202); // create a handler to capture the emitted messageCids const messageCids: string[] = []; @@ -262,14 +262,14 @@ export function testMessagesSubscribeHandler(): void { }); const recordReply = await dwn.processMessage(alice.did, recordMessage, { dataStream: recordDataStream }); - expect(recordReply.status.code).to.equal(204); + expect(recordReply.status.code).to.equal(202); // write a random message const { message: randomMessage, dataStream: randomDataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const randomReply = await dwn.processMessage(alice.did, randomMessage, { dataStream: randomDataStream }); - expect(randomReply.status.code).to.equal(204); + expect(randomReply.status.code).to.equal(202); // ensure that all messages have been received await Poller.pollUntilSuccessOrTimeout(async () => { @@ -298,7 +298,7 @@ export function testMessagesSubscribeHandler(): void { } }); const grantReply = await dwn.processMessage(alice.did, grantMessage, { dataStream }); - expect(grantReply.status.code).to.equal(204); + expect(grantReply.status.code).to.equal(202); // bob attempts to use the `RecordsWrite` grant on an `MessagesSubscribe` message const { message: bobSubscribe } = await TestDataGenerator.generateMessagesSubscribe({ @@ -373,7 +373,7 @@ export function testMessagesSubscribeHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(204); + expect(grant1Reply.status.code).to.equal(202); // bob uses the grant to subscribe to protocol 1 messages const proto1MessageCids: string[] = []; @@ -412,7 +412,7 @@ export function testMessagesSubscribeHandler(): void { author : alice }); const proto1Reply = await dwn.processMessage(alice.did, proto1Message, { dataStream: proto1DataStream }); - expect(proto1Reply.status.code).to.equal(204); + expect(proto1Reply.status.code).to.equal(202); // alice writes a message to protocol 2 const { message: proto2Message, dataStream: proto2DataStream } = await TestDataGenerator.generateRecordsWrite({ @@ -422,7 +422,7 @@ export function testMessagesSubscribeHandler(): void { author : alice }); const proto2Reply = await dwn.processMessage(alice.did, proto2Message, { dataStream: proto2DataStream }); - expect(proto2Reply.status.code).to.equal(204); + expect(proto2Reply.status.code).to.equal(202); // ensure that all messages have been received as a control await Poller.pollUntilSuccessOrTimeout(async () => { @@ -473,7 +473,7 @@ export function testMessagesSubscribeHandler(): void { }); const grant1Reply = await dwn.processMessage(alice.did, grant1Message, { dataStream: grant1DataStream }); - expect(grant1Reply.status.code).to.equal(204); + expect(grant1Reply.status.code).to.equal(202); // bob uses the grant for protocol 1 to subscribe for protocol 2 messages const { message: bobSubscribe1 } = await TestDataGenerator.generateMessagesSubscribe({ diff --git a/tests/handlers/protocols-query.spec.ts b/tests/handlers/protocols-query.spec.ts index dd59691b0..eaf9f472e 100644 --- a/tests/handlers/protocols-query.spec.ts +++ b/tests/handlers/protocols-query.spec.ts @@ -249,7 +249,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const grantRecordsWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(grantRecordsWriteReply.status.code).to.equal(204); + expect(grantRecordsWriteReply.status.code).to.equal(202); // 2. Verify Bob can perform a ProtocolsQuery const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -281,7 +281,7 @@ export function testProtocolsQueryHandler(): void { revokeWrite.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeWrite.permissionRevocationBytes) } ); - expect(revokeWriteReply.status.code).to.equal(204); + expect(revokeWriteReply.status.code).to.equal(202); // 5. Verify Bob cannot perform ProtocolsQuery with the revoked grant const unauthorizedProtocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -309,7 +309,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const permissionGrantWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob does ProtocolsQuery after the grant has expired const protocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -342,7 +342,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const permissionGrantWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob does ProtocolsQuery but his message has timestamp before the grant is active const protocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -371,7 +371,7 @@ export function testProtocolsQueryHandler(): void { const dataStream = DataStream.fromBytes(permissionGrant.permissionGrantBytes); const grantRecordsWriteReply = await dwn.processMessage(alice.did, permissionGrant.recordsWrite.message, { dataStream }); - expect(grantRecordsWriteReply.status.code).to.equal(204); + expect(grantRecordsWriteReply.status.code).to.equal(202); // Bob tries to ProtocolsQuery const protocolsQuery = await TestDataGenerator.generateProtocolsQuery({ @@ -422,7 +422,7 @@ export function testProtocolsQueryHandler(): void { await bobWrappedGrant.signAsOwner(Jws.createSigner(bob)); const grantRecordsWriteReply = await dwn.processMessage(bob.did, bobWrappedGrant.message, { dataStream }); - expect(grantRecordsWriteReply.status.code).to.equal(204); + expect(grantRecordsWriteReply.status.code).to.equal(202); // 3. Verify that Carol cannot use permission grant to gain access to Bob's DWN const permissionGrantId = permissionGrant.recordsWrite.message.recordId; diff --git a/tests/handlers/records-delete.spec.ts b/tests/handlers/records-delete.spec.ts index 6e3e008cc..36c2bacb1 100644 --- a/tests/handlers/records-delete.spec.ts +++ b/tests/handlers/records-delete.spec.ts @@ -83,7 +83,7 @@ export function testRecordsDeleteHandler(): void { // insert data const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // ensure data is inserted const queryData = await TestDataGenerator.generateRecordsQuery({ @@ -127,22 +127,22 @@ export function testRecordsDeleteHandler(): void { // alice writes a records with data const aliceWriteData = await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const aliceWriteReply = await dwn.processMessage(alice.did, aliceWriteData.message, { dataStream: aliceWriteData.dataStream }); - expect(aliceWriteReply.status.code).to.equal(204); + expect(aliceWriteReply.status.code).to.equal(202); // alice writes another record with the same data const aliceWrite2Data = await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const aliceWrite2Reply = await dwn.processMessage(alice.did, aliceWrite2Data.message, { dataStream: aliceWrite2Data.dataStream }); - expect(aliceWrite2Reply.status.code).to.equal(204); + expect(aliceWrite2Reply.status.code).to.equal(202); // bob writes a records with same data const bobWriteData = await TestDataGenerator.generateRecordsWrite({ author: bob, data }); const bobWriteReply = await dwn.processMessage(bob.did, bobWriteData.message, { dataStream: bobWriteData.dataStream }); - expect(bobWriteReply.status.code).to.equal(204); + expect(bobWriteReply.status.code).to.equal(202); // bob writes another record with the same data const bobWrite2Data = await TestDataGenerator.generateRecordsWrite({ author: bob, data }); const bobWrite2Reply = await dwn.processMessage(bob.did, bobWrite2Data.message, { dataStream: bobWrite2Data.dataStream }); - expect(bobWrite2Reply.status.code).to.equal(204); + expect(bobWrite2Reply.status.code).to.equal(202); // alice deletes one of the two records const aliceDeleteWriteData = await TestDataGenerator.generateRecordsDelete({ @@ -212,7 +212,7 @@ export function testRecordsDeleteHandler(): void { // initial write const initialWriteData = await TestDataGenerator.generateRecordsWrite({ author: alice }); const initialWriteReply = await dwn.processMessage(alice.did, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); // generate subsequent write and delete with the delete having an earlier timestamp // NOTE: creating RecordsDelete first ensures it has an earlier `messageTimestamp` time @@ -257,7 +257,7 @@ export function testRecordsDeleteHandler(): void { data }); const aliceWriteReply = await dwn.processMessage(alice.did, aliceWriteData.message, { dataStream: aliceWriteData.dataStream }); - expect(aliceWriteReply.status.code).to.equal(204); + expect(aliceWriteReply.status.code).to.equal(202); const aliceQueryWriteAfterAliceWriteData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -290,7 +290,7 @@ export function testRecordsDeleteHandler(): void { data }); const aliceRewriteReply = await dwn.processMessage(alice.did, aliceRewriteData.message, { dataStream: aliceRewriteData.dataStream }); - expect(aliceRewriteReply.status.code).to.equal(204); + expect(aliceRewriteReply.status.code).to.equal(202); const aliceQueryWriteAfterAliceRewriteData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -328,7 +328,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'doc', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.eq(204); + expect(recordsWriteReply.status.code).to.eq(202); // Bob (anyone) is able to delete the record const recordsDelete = await TestDataGenerator.generateRecordsDelete({ @@ -368,7 +368,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'post', }); const chatRecordsWriteReply = await dwn.processMessage(alice.did, chatRecordsWrite.message, { dataStream: chatRecordsWrite.dataStream }); - expect(chatRecordsWriteReply.status.code).to.eq(204); + expect(chatRecordsWriteReply.status.code).to.eq(202); // Alice writes a 'chat/tag' const tagRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -378,7 +378,7 @@ export function testRecordsDeleteHandler(): void { parentContextId : chatRecordsWrite.message.contextId, }); const tagRecordsWriteReply = await dwn.processMessage(alice.did, tagRecordsWrite.message, { dataStream: tagRecordsWrite.dataStream }); - expect(tagRecordsWriteReply.status.code).to.eq(204); + expect(tagRecordsWriteReply.status.code).to.eq(202); // Carol is unable to delete the 'chat/tag' const recordsDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -426,7 +426,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'post', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.eq(204); + expect(recordsWriteReply.status.code).to.eq(202); // Carol is unable to delete the 'post' const carolRecordsDelete = await TestDataGenerator.generateRecordsDelete({ @@ -475,7 +475,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'post', }); const postRecordsWriteReply = await dwn.processMessage(alice.did, postRecordsWrite.message, { dataStream: postRecordsWrite.dataStream }); - expect(postRecordsWriteReply.status.code).to.eq(204); + expect(postRecordsWriteReply.status.code).to.eq(202); // Alice writes a 'post/comment' const commentRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -486,7 +486,7 @@ export function testRecordsDeleteHandler(): void { }); const commentRecordsWriteReply = await dwn.processMessage(alice.did, commentRecordsWrite.message, { dataStream: commentRecordsWrite.dataStream }); - expect(commentRecordsWriteReply.status.code).to.eq(204); + expect(commentRecordsWriteReply.status.code).to.eq(202); // Carol is unable to delete Alice's 'post/comment' const recordsDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -534,7 +534,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(204); + expect(threadRecordReply.status.code).to.equal(202); // Alice adds Bob as a 'thread/admin' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -546,7 +546,7 @@ export function testRecordsDeleteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Alice writes a chat message in that thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -557,7 +557,7 @@ export function testRecordsDeleteHandler(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Verifies that Carol cannot delete without appropriate role const chatDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -604,7 +604,7 @@ export function testRecordsDeleteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Alice writes a chat message in that thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -614,7 +614,7 @@ export function testRecordsDeleteHandler(): void { protocolPath : 'chat', }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Carol is unable to delete the chat message const chatDeleteCarol = await TestDataGenerator.generateRecordsDelete({ @@ -647,7 +647,7 @@ export function testRecordsDeleteHandler(): void { author: alice, }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); const recordsDelete = await TestDataGenerator.generateRecordsDelete({ author : bob, @@ -664,7 +664,7 @@ export function testRecordsDeleteHandler(): void { // initial write const initialWriteData = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'testSchema' }); const initialWriteReply = await dwn.processMessage(alice.did, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); // generate subsequent write and delete with the delete having an earlier timestamp // NOTE: creating RecordsDelete first ensures it has an earlier `messageTimestamp` time @@ -694,7 +694,7 @@ export function testRecordsDeleteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const recordsDelete = await RecordsDelete.create({ recordId : message.recordId, @@ -723,7 +723,7 @@ export function testRecordsDeleteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(author.did, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const newWrite = await RecordsWrite.createFrom({ recordsWriteMessage : recordsWrite.message, diff --git a/tests/handlers/records-query.spec.ts b/tests/handlers/records-query.spec.ts index e328a49f4..d528114bf 100644 --- a/tests/handlers/records-query.spec.ts +++ b/tests/handlers/records-query.spec.ts @@ -104,7 +104,7 @@ export function testRecordsQueryHandler(): void { const write = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [bob], dataFormat }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const query = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { dataFormat } }); const reply = await dwn.processMessage(alice.did, query.message); @@ -133,9 +133,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // testing singular conditional query const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { dataFormat } }); @@ -166,7 +166,7 @@ export function testRecordsQueryHandler(): void { const write= await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { recordId: write.message.recordId } }); const reply = await dwn.processMessage(alice.did, messageData.message); @@ -182,7 +182,7 @@ export function testRecordsQueryHandler(): void { const write= await TestDataGenerator.generateRecordsWrite({ author: alice, data }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { recordId: write.message.recordId } }); const reply = await dwn.processMessage(alice.did, messageData.message); @@ -197,7 +197,7 @@ export function testRecordsQueryHandler(): void { const write = await TestDataGenerator.generateRecordsWrite({ author: alice, published: false }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // write an update to the record const write2 = await RecordsWrite.createFrom({ recordsWriteMessage: write.message, published: true, signer: Jws.createSigner(alice) }); @@ -225,8 +225,8 @@ export function testRecordsQueryHandler(): void { // insert data const writeReply1 = await dwn.processMessage(alice.did, recordsWrite1.message, { dataStream: recordsWrite1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, recordsWrite2.message, { dataStream: recordsWrite2.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); // testing attester filter const recordsQuery1 = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { attester: alice.did } }); @@ -275,7 +275,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'post' }); const aliceAuthorReply = await dwn.processMessage(alice.did, aliceAuthorWrite.message, { dataStream: aliceAuthorWrite.dataStream }); - expect(aliceAuthorReply.status.code).to.equal(204); + expect(aliceAuthorReply.status.code).to.equal(202); const bobAuthorWrite = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -285,7 +285,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'post' }); const bobAuthorReply = await dwn.processMessage(alice.did, bobAuthorWrite.message, { dataStream: bobAuthorWrite.dataStream }); - expect(bobAuthorReply.status.code).to.equal(204); + expect(bobAuthorReply.status.code).to.equal(202); // alice queries with an empty filter, gets both let recordsQuery = await TestDataGenerator.generateRecordsQuery({ @@ -325,12 +325,12 @@ export function testRecordsQueryHandler(): void { // create a published record const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' }); const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream }); - expect(publishedWriteReply.status.code).to.equal(204); + expect(publishedWriteReply.status.code).to.equal(202); // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(204); + expect(draftWriteReply.status.code).to.equal(202); // query for only published records const publishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: true } }); @@ -392,12 +392,12 @@ export function testRecordsQueryHandler(): void { // create a published record const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' }); const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream }); - expect(publishedWriteReply.status.code).to.equal(204); + expect(publishedWriteReply.status.code).to.equal(202); // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(204); + expect(draftWriteReply.status.code).to.equal(202); // query for only unpublished records const unpublishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: false } }); @@ -428,12 +428,12 @@ export function testRecordsQueryHandler(): void { // create a published record const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' }); const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream }); - expect(publishedWriteReply.status.code).to.equal(204); + expect(publishedWriteReply.status.code).to.equal(202); // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(204); + expect(draftWriteReply.status.code).to.equal(202); // bob queries for unpublished records returns zero const unpublishedNotOwner = await TestDataGenerator.generateRecordsQuery({ author: bob, filter: { schema: 'post', published: false } }); @@ -474,7 +474,7 @@ export function testRecordsQueryHandler(): void { // create a record const writeRecord = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeRecordReply = await dwn.processMessage(alice.did, writeRecord.message, { dataStream: writeRecord.dataStream }); - expect(writeRecordReply.status.code).to.equal(204); + expect(writeRecordReply.status.code).to.equal(202); const recordDataCid = writeRecord.message.descriptor.dataCid; // query for the record by it's dataCid @@ -495,9 +495,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // testing gt const recordsQuery1 = await TestDataGenerator.generateRecordsQuery({ @@ -569,9 +569,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // testing range using gt & lt const recordsQuery1 = await TestDataGenerator.generateRecordsQuery({ @@ -627,9 +627,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // testing `from` range const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -700,9 +700,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // confirm range before un-publishing. const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -818,9 +818,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // testing `from` range const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -919,9 +919,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // update to published const write1Update = await RecordsWrite.createFrom({ @@ -1022,9 +1022,9 @@ export function testRecordsQueryHandler(): void { const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3.message, { dataStream: write3.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // testing range criterion with another exact match const lastDayOf2021 = Time.createTimestamp({ year: 2021, month: 12, day: 31 }); @@ -1051,7 +1051,7 @@ export function testRecordsQueryHandler(): void { sinon.stub(didResolver, 'resolve').resolves(mockResolution); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const queryData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -1071,7 +1071,7 @@ export function testRecordsQueryHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [alice] }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const queryData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -1105,8 +1105,8 @@ export function testRecordsQueryHandler(): void { const publishedWriteReply = await dwn.processMessage(alice.did, publishedWriteData.message, { dataStream: publishedWriteData.dataStream }); const unpublishedWriteReply = await dwn.processMessage(alice.did, unpublishedWriteData.message, { dataStream: unpublishedWriteData.dataStream }); - expect(publishedWriteReply.status.code).to.equal(204); - expect(unpublishedWriteReply.status.code).to.equal(204); + expect(publishedWriteReply.status.code).to.equal(202); + expect(unpublishedWriteReply.status.code).to.equal(202); // test published date ascending sort does not include any records that are not published const publishedAscendingQueryData = await TestDataGenerator.generateRecordsQuery({ @@ -1148,9 +1148,9 @@ export function testRecordsQueryHandler(): void { const writeReply2 = await dwn.processMessage(alice.did, write2Data.message, { dataStream: write2Data.dataStream }); const writeReply1 = await dwn.processMessage(alice.did, write1Data.message, { dataStream: write1Data.dataStream }); const writeReply3 = await dwn.processMessage(alice.did, write3Data.message, { dataStream: write3Data.dataStream }); - expect(writeReply1.status.code).to.equal(204); - expect(writeReply2.status.code).to.equal(204); - expect(writeReply3.status.code).to.equal(204); + expect(writeReply1.status.code).to.equal(202); + expect(writeReply2.status.code).to.equal(202); + expect(writeReply3.status.code).to.equal(202); // createdAscending test let createdAscendingQueryData = await TestDataGenerator.generateRecordsQuery({ @@ -1305,11 +1305,11 @@ export function testRecordsQueryHandler(): void { // intentionally write the RecordsWrite of out lexicographical order to avoid the test query below accidentally having the correct order const reply2 = await dwn.processMessage(alice.did, middleWrite.message, { dataStream: middleWrite.dataStream }); - expect(reply2.status.code).to.equal(204); + expect(reply2.status.code).to.equal(202); const reply3 = await dwn.processMessage(alice.did, newestWrite.message, { dataStream: newestWrite.dataStream }); - expect(reply3.status.code).to.equal(204); + expect(reply3.status.code).to.equal(202); const reply1 = await dwn.processMessage(alice.did, oldestWrite.message, { dataStream: oldestWrite.dataStream }); - expect(reply1.status.code).to.equal(204); + expect(reply1.status.code).to.equal(202); const queryMessageData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -1346,7 +1346,7 @@ export function testRecordsQueryHandler(): void { }))); for (const message of messages) { const result = await dwn.processMessage(alice.did, message.message, { dataStream: message.dataStream }); - expect(result.status.code).to.equal(204); + expect(result.status.code).to.equal(202); } const limit = 5; @@ -1387,7 +1387,7 @@ export function testRecordsQueryHandler(): void { }))); for (const message of messages) { const result = await dwn.processMessage(alice.did, message.message, { dataStream: message.dataStream }); - expect(result.status.code).to.equal(204); + expect(result.status.code).to.equal(202); } const limit = 5; @@ -1432,9 +1432,9 @@ export function testRecordsQueryHandler(): void { ); const recordsWrite1Reply = await dwn.processMessage(alice.did, record1Data.message, { dataStream: record1Data.dataStream }); - expect(recordsWrite1Reply.status.code).to.equal(204); + expect(recordsWrite1Reply.status.code).to.equal(202); const recordsWrite2Reply = await dwn.processMessage(alice.did, record2Data.message, { dataStream: record2Data.dataStream }); - expect(recordsWrite2Reply.status.code).to.equal(204); + expect(recordsWrite2Reply.status.code).to.equal(202); // test correctness for anonymous query const anonymousQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -1732,7 +1732,7 @@ export function testRecordsQueryHandler(): void { ); const result1 = await dwn.processMessage(alice.did, unpublishedRecordsWrite.message, { dataStream: unpublishedRecordsWrite.dataStream }); - expect(result1.status.code).to.equal(204); + expect(result1.status.code).to.equal(202); // alice should be able to see the unpublished record const queryByAlice = await TestDataGenerator.generateRecordsQuery({ @@ -1860,7 +1860,7 @@ export function testRecordsQueryHandler(): void { // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(204); + expect(draftWriteReply.status.code).to.equal(202); // validate that alice can query const unpublishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: false } }); @@ -1911,11 +1911,11 @@ export function testRecordsQueryHandler(): void { const foo1 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: foo1.dataStream }); - expect(foo1WriteResponse.status.code).equals(204); + expect(foo1WriteResponse.status.code).equals(202); const foo2 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo2WriteResponse = await dwn.processMessage(alice.did, foo2.message, { dataStream: foo2.dataStream }); - expect(foo2WriteResponse.status.code).equals(204); + expect(foo2WriteResponse.status.code).equals(202); // write 2 bars under foo1 const barOptions = { @@ -1929,11 +1929,11 @@ export function testRecordsQueryHandler(): void { const bar1 = await TestDataGenerator.generateRecordsWrite(barOptions); const bar1WriteResponse = await dwn.processMessage(alice.did, bar1.message, { dataStream: bar1.dataStream }); - expect(bar1WriteResponse.status.code).equals(204); + expect(bar1WriteResponse.status.code).equals(202); const bar2 = await TestDataGenerator.generateRecordsWrite(barOptions); const bar2WriteResponse = await dwn.processMessage(alice.did, bar2.message, { dataStream: bar2.dataStream }); - expect(bar2WriteResponse.status.code).equals(204); + expect(bar2WriteResponse.status.code).equals(202); // write 2 bazes under bar1 const bazOptions = { @@ -1947,11 +1947,11 @@ export function testRecordsQueryHandler(): void { const baz1 = await TestDataGenerator.generateRecordsWrite(bazOptions); const baz1WriteResponse = await dwn.processMessage(alice.did, baz1.message, { dataStream: baz1.dataStream }); - expect(baz1WriteResponse.status.code).equals(204); + expect(baz1WriteResponse.status.code).equals(202); const baz2 = await TestDataGenerator.generateRecordsWrite(bazOptions); const baz2WriteResponse = await dwn.processMessage(alice.did, baz2.message, { dataStream: baz2.dataStream }); - expect(baz2WriteResponse.status.code).equals(204); + expect(baz2WriteResponse.status.code).equals(202); // 2. Alice should be able to query for all messages under foo1 @@ -2020,7 +2020,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Alice writes one 'chat' record addressed to Bob const chatRecordForBob = await TestDataGenerator.generateRecordsWrite({ @@ -2033,7 +2033,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatRecordForBobReply = await dwn.processMessage(alice.did, chatRecordForBob.message, { dataStream: chatRecordForBob.dataStream }); - expect(chatRecordForBobReply.status.code).to.equal(204); + expect(chatRecordForBobReply.status.code).to.equal(202); // Alice writes two 'chat' records NOT addressed to Bob for (let i = 0; i < 2; i++) { @@ -2047,7 +2047,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob cannot read this'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); } // Bob queries without invoking any protocolRole @@ -2102,7 +2102,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2116,7 +2116,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } @@ -2172,7 +2172,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Alice writes a 'participant' role record with Bob as recipient const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2185,7 +2185,7 @@ export function testRecordsQueryHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2200,7 +2200,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } @@ -2245,7 +2245,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2259,7 +2259,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } @@ -2299,7 +2299,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Alice writes a 'friend' root-level role record with Bob as recipient const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2312,7 +2312,7 @@ export function testRecordsQueryHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2327,7 +2327,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } @@ -2374,7 +2374,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } @@ -2413,7 +2413,7 @@ export function testRecordsQueryHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Alice writes three 'chat' records const chatRecordIds = []; @@ -2428,7 +2428,7 @@ export function testRecordsQueryHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } diff --git a/tests/handlers/records-read.spec.ts b/tests/handlers/records-read.spec.ts index c92c0f089..7bddd5f98 100644 --- a/tests/handlers/records-read.spec.ts +++ b/tests/handlers/records-read.spec.ts @@ -85,7 +85,7 @@ export function testRecordsReadHandler(): void { // insert data const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // testing RecordsRead const recordsRead = await RecordsRead.create({ @@ -111,7 +111,7 @@ export function testRecordsReadHandler(): void { // insert data const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // testing RecordsRead const bob = await TestDataGenerator.generateDidKeyPersona(); @@ -133,7 +133,7 @@ export function testRecordsReadHandler(): void { // insert public data const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // testing public RecordsRead const recordsRead = await RecordsRead.create({ @@ -156,7 +156,7 @@ export function testRecordsReadHandler(): void { // insert public data const { message, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // testing public RecordsRead const bob = await TestDataGenerator.generateDidKeyPersona(); @@ -185,7 +185,7 @@ export function testRecordsReadHandler(): void { recipient : bob.did, }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // Bob reads the data that Alice sent him const recordsRead = await RecordsRead.create({ @@ -209,7 +209,7 @@ export function testRecordsReadHandler(): void { const write = await TestDataGenerator.generateRecordsWrite({ author: alice, published: false }); const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // write an update to the record const write2 = await RecordsWrite.createFrom({ recordsWriteMessage: write.message, published: true, signer: Jws.createSigner(alice) }); @@ -255,7 +255,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(204); + expect(imageReply.status.code).to.equal(202); // Bob (anyone) reads the image that Alice wrote const imageRecordsRead = await RecordsRead.create({ @@ -295,7 +295,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('foo') }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Anonymous tries and fails to read Alice's message const recordsRead = await RecordsRead.create({ @@ -339,7 +339,7 @@ export function testRecordsReadHandler(): void { recipient : bob.did }); const imageReply = await dwn.processMessage(alice.did, emailRecordsWrite.message, { dataStream: emailRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(204); + expect(imageReply.status.code).to.equal(202); // Bob reads Alice's email const bobRecordsRead = await RecordsRead.create({ @@ -394,7 +394,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const imageReply = await dwn.processMessage(alice.did, emailRecordsWrite.message, { dataStream: emailRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(204); + expect(imageReply.status.code).to.equal(202); // Bob reads the email he just sent const bobRecordsRead = await RecordsRead.create({ @@ -441,7 +441,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const foo1WriteReply = await dwn.processMessage(alice.did, foo1Write.message, { dataStream: foo1Write.dataStream }); - expect(foo1WriteReply.status.code).to.equal(204); + expect(foo1WriteReply.status.code).to.equal(202); const fooPathRead = await RecordsRead.create({ filter: { @@ -477,7 +477,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const foo1WriteReply = await dwn.processMessage(alice.did, foo1Write.message, { dataStream: foo1Write.dataStream }); - expect(foo1WriteReply.status.code).to.equal(204); + expect(foo1WriteReply.status.code).to.equal(202); const foo2Write = await TestDataGenerator.generateRecordsWrite({ author : alice, @@ -489,7 +489,7 @@ export function testRecordsReadHandler(): void { recipient : alice.did }); const foo2WriteReply = await dwn.processMessage(alice.did, foo2Write.message, { dataStream: foo2Write.dataStream }); - expect(foo2WriteReply.status.code).to.equal(204); + expect(foo2WriteReply.status.code).to.equal(202); // Since there are two 'foo' records, this should fail. const fooPathRead = await RecordsRead.create({ @@ -531,7 +531,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Alice writes a 'chat' record const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -542,7 +542,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); // Bob reads Alice's chat record const readChatRecord = await RecordsRead.create({ @@ -582,7 +582,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Blah blah blah'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); // Bob tries to invoke a 'chat' role but 'chat' is not a role const readChatRecord = await RecordsRead.create({ @@ -622,7 +622,7 @@ export function testRecordsReadHandler(): void { data : new TextEncoder().encode('Blah blah blah'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); // Bob tries to invoke a 'friend' role but he is not a 'friend' const readChatRecord = await RecordsRead.create({ @@ -660,7 +660,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(204); + expect(threadRecordReply.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -672,7 +672,7 @@ export function testRecordsReadHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Alice writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -682,7 +682,7 @@ export function testRecordsReadHandler(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Bob is able to read his own 'participant' role // He doesn't need to invoke the role because recipients of a record are always authorized to read it @@ -744,7 +744,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'thread' }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord1.message, { dataStream: threadRecord1.dataStream }); - expect(threadRecordReply1.status.code).to.equal(204); + expect(threadRecordReply1.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -756,7 +756,7 @@ export function testRecordsReadHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Alice creates a second thread const threadRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -766,7 +766,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'thread' }); const threadRecordReply2 = await dwn.processMessage(alice.did, threadRecord2.message, { dataStream: threadRecord2.dataStream }); - expect(threadRecordReply2.status.code).to.equal(204); + expect(threadRecordReply2.status.code).to.equal(202); // Alice writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -776,7 +776,7 @@ export function testRecordsReadHandler(): void { parentContextId : threadRecord2.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Bob invokes his 'participant' role to read the chat message const chatRead = await RecordsRead.create({ @@ -805,7 +805,7 @@ export function testRecordsReadHandler(): void { author: alice, }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -824,7 +824,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob tries to RecordsRead const recordsRead = await RecordsRead.create({ @@ -864,7 +864,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -883,7 +883,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record without using the permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -933,7 +933,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -952,7 +952,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record without using the permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1001,7 +1001,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1020,7 +1020,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1058,7 +1058,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1078,7 +1078,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1115,7 +1115,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1135,7 +1135,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1173,7 +1173,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1193,7 +1193,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1230,7 +1230,7 @@ export function testRecordsReadHandler(): void { protocolPath : 'foo', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant with scope RecordsRead const permissionGrant = await PermissionsProtocol.createGrant({ @@ -1250,7 +1250,7 @@ export function testRecordsReadHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob is unable to read the record using the mismatched permission grant const recordsReadWithoutGrant = await RecordsRead.create({ @@ -1287,7 +1287,7 @@ export function testRecordsReadHandler(): void { // insert public data const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // ensure data is inserted const queryData = await TestDataGenerator.generateRecordsQuery({ @@ -1331,7 +1331,7 @@ export function testRecordsReadHandler(): void { data : TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded +1) }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // testing RecordsRead const recordsRead = await RecordsRead.create({ @@ -1356,7 +1356,7 @@ export function testRecordsReadHandler(): void { }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const recordRead = await RecordsRead.create({ filter: { @@ -1387,7 +1387,7 @@ export function testRecordsReadHandler(): void { }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const recordRead = await RecordsRead.create({ filter: { @@ -1471,7 +1471,7 @@ export function testRecordsReadHandler(): void { }); const writeReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const recordsRead = await RecordsRead.create({ filter: { @@ -1559,7 +1559,7 @@ export function testRecordsReadHandler(): void { const dataStream = DataStream.fromBytes(encryptedDataBytes); const writeReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); const recordsRead = await RecordsRead.create({ filter: { @@ -1642,7 +1642,7 @@ export function testRecordsReadHandler(): void { // Bob writes the encrypted chat thread to Alice's DWN const bobToAliceWriteReply = await dwn.processMessage(alice.did, threadMessage, { dataStream }); - expect(bobToAliceWriteReply.status.code).to.equal(204); + expect(bobToAliceWriteReply.status.code).to.equal(202); // Bob also needs to write the same encrypted chat thread to his own DWN // Opportunity here to create a much nicer utility method for this entire block @@ -1675,7 +1675,7 @@ export function testRecordsReadHandler(): void { const dataStreamForBobsDwn = DataStream.fromBytes(encryptedDataBytes); const bobToBobWriteReply = await dwn.processMessage(bob.did, bobToBobRecordsWrite.message, { dataStream: dataStreamForBobsDwn }); - expect(bobToBobWriteReply.status.code).to.equal(204); + expect(bobToBobWriteReply.status.code).to.equal(202); // NOTE: we know Alice is able to decrypt the message using protocol-path derived key through other tests, so we won't verify it again @@ -1720,7 +1720,7 @@ export function testRecordsReadHandler(): void { // Alice sends the message to Bob const aliceWriteReply = await dwn.processMessage(bob.did, recordsWriteToBob.message, { dataStream: recordsWriteToBob.dataStream }); - expect(aliceWriteReply.status.code).to.equal(204); + expect(aliceWriteReply.status.code).to.equal(202); // test that Bob is able to read and decrypt Alice's message const recordsReadByBob = await RecordsRead.create({ @@ -1810,7 +1810,7 @@ export function testRecordsReadHandler(): void { // Bob writes the encrypted email to Alice's DWN const bobWriteReply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(bobWriteReply.status.code).to.equal(204); + expect(bobWriteReply.status.code).to.equal(202); // Alice reads the encrypted email // assume Alice already made query to get the `recordId` of the email diff --git a/tests/handlers/records-subscribe.spec.ts b/tests/handlers/records-subscribe.spec.ts index be646ec29..fc5c156ca 100644 --- a/tests/handlers/records-subscribe.spec.ts +++ b/tests/handlers/records-subscribe.spec.ts @@ -208,7 +208,7 @@ export function testRecordsSubscribeHandler(): void { // create an unpublished record const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' }); const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream }); - expect(draftWriteReply.status.code).to.equal(204); + expect(draftWriteReply.status.code).to.equal(202); // validate that alice can subscribe const unpublishedPostSubscribe = await TestDataGenerator.generateRecordsSubscribe({ author: alice, filter: { schema: 'post', published: false } }); @@ -322,7 +322,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Alice writes one 'chat' record addressed to Bob const chatRecordForBob = await TestDataGenerator.generateRecordsWrite({ @@ -335,7 +335,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatRecordForBobReply = await dwn.processMessage(alice.did, chatRecordForBob.message, { dataStream: chatRecordForBob.dataStream }); - expect(chatRecordForBobReply.status.code).to.equal(204); + expect(chatRecordForBobReply.status.code).to.equal(202); const chatRecordForBobCid = await Message.getCid(chatRecordForBob.message); // Alice writes two 'chat' records addressed to Carol @@ -353,7 +353,7 @@ export function testRecordsSubscribeHandler(): void { chatRecordForCarol1.message, { dataStream: chatRecordForCarol1.dataStream } ); - expect(chatRecordForCarol1Reply.status.code).to.equal(204); + expect(chatRecordForCarol1Reply.status.code).to.equal(202); const chatRecordForCarol1Cid = await Message.getCid(chatRecordForCarol1.message); const chatRecordForCarol2 = await TestDataGenerator.generateRecordsWrite({ @@ -370,7 +370,7 @@ export function testRecordsSubscribeHandler(): void { chatRecordForCarol2.message, { dataStream: chatRecordForCarol2.dataStream } ); - expect(chatRecordForCarol2Reply.status.code).to.equal(204); + expect(chatRecordForCarol2Reply.status.code).to.equal(202); const chatRecordForCarol2Cid = await Message.getCid(chatRecordForCarol2.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -437,7 +437,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); const recordIds: Set = new Set(); const addRecord:RecordSubscriptionHandler = async (event) => { @@ -471,7 +471,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatRecordForBobReply = await dwn.processMessage(alice.did, chatRecordForBob.message, { dataStream: chatRecordForBob.dataStream }); - expect(chatRecordForBobReply.status.code).to.equal(204); + expect(chatRecordForBobReply.status.code).to.equal(202); // Alice writes three more 'chat' records for carol, Bob's friend role should allow him to see these messages. const chatRecordIds: string[] = []; @@ -485,7 +485,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } @@ -555,7 +555,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); const filter: RecordsFilter = { protocol : protocolDefinition.protocol, @@ -593,7 +593,7 @@ export function testRecordsSubscribeHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); const recordIds: string[] = []; const addRecord:RecordSubscriptionHandler = async (event) => { @@ -629,7 +629,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob can read this cuz he is my friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); chatRecordIds.push(chatRecord.message.recordId); } @@ -667,7 +667,7 @@ export function testRecordsSubscribeHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Bob invokes his friendRole to subscribe but does not have `protocolPath` in the filter const chatSubscribe = await TestDataGenerator.generateRecordsSubscribe({ @@ -706,7 +706,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Alice writes a 'friend' root-level role record with Bob as recipient const participantRoleRecord = await TestDataGenerator.generateRecordsWrite({ @@ -719,7 +719,7 @@ export function testRecordsSubscribeHandler(): void { }); const participantRoleReply = await dwn.processMessage(alice.did, participantRoleRecord.message, { dataStream: participantRoleRecord.dataStream }); - expect(participantRoleReply.status.code).to.equal(204); + expect(participantRoleReply.status.code).to.equal(202); // Bob invokes his thread participant role to subscribe but omits the contextId const chatSubscribe = await TestDataGenerator.generateRecordsSubscribe({ @@ -789,7 +789,7 @@ export function testRecordsSubscribeHandler(): void { protocolPath : 'thread', }); const threadRoleReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRoleReply.status.code).to.equal(204); + expect(threadRoleReply.status.code).to.equal(202); // Bob invokes his a `thread/participant` role which he does not have to subscribe to the records const chatSubscribe = await TestDataGenerator.generateRecordsSubscribe({ diff --git a/tests/handlers/records-write.spec.ts b/tests/handlers/records-write.spec.ts index c12202d39..30134c3a7 100644 --- a/tests/handlers/records-write.spec.ts +++ b/tests/handlers/records-write.spec.ts @@ -122,7 +122,7 @@ export function testRecordsWriteHandler(): void { const tenant = author.did; const recordsWriteReply = await dwn.processMessage(tenant, recordsWriteMessageData.message, { dataStream: recordsWriteMessageData.dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); const recordId = recordsWriteMessageData.message.recordId; const recordsQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -185,7 +185,7 @@ export function testRecordsWriteHandler(): void { const originatingMessageWriteReply = await dwn.processMessage(tenant, originatingMessageData.message, { dataStream: originatingMessageData.dataStream }); - expect(originatingMessageWriteReply.status.code).to.equal(204); + expect(originatingMessageWriteReply.status.code).to.equal(202); // generate two new RecordsWrite messages with the same `messageTimestamp` value const dateModified = Time.getCurrentTimestamp(); @@ -264,7 +264,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [initialWriteData.author]); const initialWriteReply = await dwn.processMessage(tenant, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); const newDataFormat = 'any-new-data-format'; const newDataBytes = TestDataGenerator.randomBytes(100); @@ -296,7 +296,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [initialWriteData.author]); const initialWriteReply = await dwn.processMessage(tenant, initialWriteData.message, { dataStream: initialWriteData.dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); const recordId = initialWriteData.message.recordId; const dateCreated = initialWriteData.message.descriptor.dateCreated; @@ -340,7 +340,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); const write2 = await RecordsWrite.createFrom({ recordsWriteMessage : message, @@ -373,7 +373,7 @@ export function testRecordsWriteHandler(): void { // simulate synchronize of pruned initial `RecordsWrite` const reply = await dwn.processMessage(alice.did, recordsWrite.message); - expect(reply.status.code).to.equal(202); + expect(reply.status.code).to.equal(204); // verify `RecordsWrite` inserted is not returned with a query const recordsQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -414,7 +414,7 @@ export function testRecordsWriteHandler(): void { // write a record into the dwn const { recordsWrite, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({ author: alice }); const reply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); // verify `RecordsWrite` inserted can be queried const recordsQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -459,7 +459,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); const write2 = await RecordsWrite.createFrom({ recordsWriteMessage : message, @@ -492,7 +492,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); const write2 = await RecordsWrite.createFrom({ recordsWriteMessage : message, @@ -639,7 +639,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); const recordsDelete = await RecordsDelete.create({ recordId : message.recordId, @@ -671,7 +671,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const initialWriteReply = await dwn.processMessage(tenant, message, { dataStream }); - expect(initialWriteReply.status.code).to.equal(204); + expect(initialWriteReply.status.code).to.equal(202); const recordsDelete = await RecordsDelete.create({ recordId : message.recordId, @@ -764,12 +764,12 @@ export function testRecordsWriteHandler(): void { }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(204); + expect(write1Reply.status.code).to.equal(202); // alice writes another record (which will be modified later) const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(204); + expect(write2Reply.status.code).to.equal(202); // modify write2 by referencing the `dataCid` in write1 (which should not be allowed) const write2Change = await TestDataGenerator.generateRecordsWrite({ @@ -818,12 +818,12 @@ export function testRecordsWriteHandler(): void { }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(204); + expect(write1Reply.status.code).to.equal(202); // alice writes another record (which will be modified later) const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(204); + expect(write2Reply.status.code).to.equal(202); // modify write2 by referencing the `dataCid` in write1 (which should not be allowed) const write2Change = await TestDataGenerator.generateRecordsWrite({ @@ -874,7 +874,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(tenant, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); // changing the `published` property const newWrite = await RecordsWrite.createFrom({ @@ -911,7 +911,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(tenant, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const newData = Encoder.stringToBytes('new data'); const newWrite = await RecordsWrite.createFrom({ @@ -990,7 +990,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(author.did, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const { events } = await eventLog.getEvents(author.did); expect(events.length).to.equal(1); @@ -1004,7 +1004,7 @@ export function testRecordsWriteHandler(): void { TestStubGenerator.stubDidResolver(didResolver, [author]); const reply = await dwn.processMessage(author.did, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const newWrite = await RecordsWrite.createFrom({ recordsWriteMessage : recordsWrite.message, @@ -1072,7 +1072,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, emailFromBob.message, { dataStream: emailFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(204); + expect(bobWriteReply.status.code).to.equal(202); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -1109,7 +1109,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'doc' }); const docRecordsReply = await dwn.processMessage(alice.did, docRecord.message, { dataStream: docRecord.dataStream }); - expect(docRecordsReply.status.code).to.equal(204); + expect(docRecordsReply.status.code).to.equal(202); // Bob updates Alice's doc const bobsData = await TestDataGenerator.randomBytes(10); @@ -1174,7 +1174,7 @@ export function testRecordsWriteHandler(): void { credentialApplication.message, { dataStream: credentialApplication.dataStream } ); - expect(credentialApplicationReply.status.code).to.equal(204); + expect(credentialApplicationReply.status.code).to.equal(202); // generate a credential application response message from VC issuer const encodedCredentialResponse = new TextEncoder().encode('credential response data'); @@ -1193,7 +1193,7 @@ export function testRecordsWriteHandler(): void { const credentialResponseReply = await dwn.processMessage(alice.did, credentialResponse.message, { dataStream: credentialResponse.dataStream }); - expect(credentialResponseReply.status.code).to.equal(204); + expect(credentialResponseReply.status.code).to.equal(202); // verify VC issuer's message got written to the DB const messageDataForQueryingCredentialResponse = await TestDataGenerator.generateRecordsQuery({ @@ -1231,7 +1231,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'post' }); const docRecordsReply = await dwn.processMessage(alice.did, docRecord.message, { dataStream: docRecord.dataStream }); - expect(docRecordsReply.status.code).to.equal(204); + expect(docRecordsReply.status.code).to.equal(202); // Alice creates a post/tag const tagRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1242,7 +1242,7 @@ export function testRecordsWriteHandler(): void { parentContextId : docRecord.message.contextId!, }); const tagRecordsReply = await dwn.processMessage(alice.did, tagRecord.message, { dataStream: tagRecord.dataStream }); - expect(tagRecordsReply.status.code).to.equal(204); + expect(tagRecordsReply.status.code).to.equal(202); // Bob updates Alice's post const bobsData = await TestDataGenerator.randomBytes(10); @@ -1297,7 +1297,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'post', }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream: recordsWrite.dataStream }); - expect(recordsWriteReply.status.code).to.eq(204); + expect(recordsWriteReply.status.code).to.eq(202); // Carol is unable to update the 'post' const carolRecordsWrite = await TestDataGenerator.generateFromRecordsWrite({ @@ -1350,7 +1350,7 @@ export function testRecordsWriteHandler(): void { data : encodedImage }); const imageReply = await dwn.processMessage(bob.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(204); + expect(imageReply.status.code).to.equal(202); // AliceImposter attempts and fails to caption Alice's image const encodedCaptionImposter = new TextEncoder().encode('bad vibes! >:('); @@ -1379,7 +1379,7 @@ export function testRecordsWriteHandler(): void { data : encodedCaption }); const captionResponse = await dwn.processMessage(bob.did, captionRecordsWrite.message, { dataStream: captionRecordsWrite.dataStream }); - expect(captionResponse.status.code).to.equal(204); + expect(captionResponse.status.code).to.equal(202); // Verify Alice's caption got written to the DB const messageDataForQueryingCaptionResponse = await TestDataGenerator.generateRecordsQuery({ @@ -1417,7 +1417,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'post' }); const postRecordsReply = await dwn.processMessage(alice.did, postRecord.message, { dataStream: postRecord.dataStream }); - expect(postRecordsReply.status.code).to.equal(204); + expect(postRecordsReply.status.code).to.equal(202); // Alice creates a post/comment const commentRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1428,7 +1428,7 @@ export function testRecordsWriteHandler(): void { parentContextId : postRecord.message.contextId!, }); const commentRecordsReply = await dwn.processMessage(alice.did, commentRecord.message, { dataStream: commentRecord.dataStream }); - expect(commentRecordsReply.status.code).to.equal(204); + expect(commentRecordsReply.status.code).to.equal(202); // Bob updates Alice's comment const bobsData = await TestDataGenerator.randomBytes(10); @@ -1481,7 +1481,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Alice updates Bob's 'friend' record const updateFriendRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -1543,7 +1543,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Alice deletes Bob's 'friend' role record const deleteFriend = await TestDataGenerator.generateRecordsDelete({ @@ -1563,7 +1563,7 @@ export function testRecordsWriteHandler(): void { }); const duplicateFriendReply = await dwn.processMessage(alice.did, duplicateFriendRecord.message, { dataStream: duplicateFriendRecord.dataStream }); - expect(duplicateFriendReply.status.code).to.equal(204); + expect(duplicateFriendReply.status.code).to.equal(202); }); }); @@ -1591,7 +1591,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(204); + expect(threadRecordReply.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1603,7 +1603,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Alice updates Bob's role record const participantUpdateRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -1638,7 +1638,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord1.message, { dataStream: threadRecord1.dataStream }); - expect(threadRecordReply1.status.code).to.equal(204); + expect(threadRecordReply1.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' to the first thread const participantRecord1 = await TestDataGenerator.generateRecordsWrite({ @@ -1650,7 +1650,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply1 = await dwn.processMessage(alice.did, participantRecord1.message, { dataStream: participantRecord1.dataStream }); - expect(participantRecordReply1.status.code).to.equal(204); + expect(participantRecordReply1.status.code).to.equal(202); // Alice creates a second thread const threadRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -1660,7 +1660,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply2 = await dwn.processMessage(alice.did, threadRecord2.message, { dataStream: threadRecord2.dataStream }); - expect(threadRecordReply2.status.code).to.equal(204); + expect(threadRecordReply2.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' to the second thread const participantRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -1672,7 +1672,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply2 = await dwn.processMessage(alice.did, participantRecord2.message, { dataStream: participantRecord2.dataStream }); - expect(participantRecordReply2.status.code).to.equal(204); + expect(participantRecordReply2.status.code).to.equal(202); }); it('rejects writes to a $role record if there already exists one in the same context', async () => { @@ -1698,7 +1698,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(204); + expect(threadRecordReply.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' to the thread const participantRecord1 = await TestDataGenerator.generateRecordsWrite({ @@ -1710,7 +1710,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply1 = await dwn.processMessage(alice.did, participantRecord1.message, { dataStream: participantRecord1.dataStream }); - expect(participantRecordReply1.status.code).to.equal(204); + expect(participantRecordReply1.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' again to the same thread const participantRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -1749,7 +1749,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(204); + expect(threadRecordReply.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' to the thread const participantRecord1 = await TestDataGenerator.generateRecordsWrite({ @@ -1761,7 +1761,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply1 = await dwn.processMessage(alice.did, participantRecord1.message, { dataStream: participantRecord1.dataStream }); - expect(participantRecordReply1.status.code).to.equal(204); + expect(participantRecordReply1.status.code).to.equal(202); // Alice deletes the participant record const participantDelete = await TestDataGenerator.generateRecordsDelete({ @@ -1781,7 +1781,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply2 = await dwn.processMessage(alice.did, participantRecord2.message, { dataStream: participantRecord2.dataStream }); - expect(participantRecordReply2.status.code).to.equal(204); + expect(participantRecordReply2.status.code).to.equal(202); }); }); @@ -1811,7 +1811,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Bob writes a 'chat' record const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1823,7 +1823,7 @@ export function testRecordsWriteHandler(): void { protocolRole : 'friend' }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); }); it('uses a root-level role to authorize a co-update', async () => { @@ -1851,7 +1851,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob is my friend'), }); const friendRoleReply = await dwn.processMessage(alice.did, friendRoleRecord.message, { dataStream: friendRoleRecord.dataStream }); - expect(friendRoleReply.status.code).to.equal(204); + expect(friendRoleReply.status.code).to.equal(202); // Alice creates a 'chat' record const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1862,7 +1862,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Bob can write this cuz he is Alices friend'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); // Bob invokes his admin role to update the 'chat' record const chatUpdateRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -1898,7 +1898,7 @@ export function testRecordsWriteHandler(): void { data : new TextEncoder().encode('Blah blah blah'), }); const chatReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatReply.status.code).to.equal(204); + expect(chatReply.status.code).to.equal(202); // Bob tries to invoke a 'chat' role but 'chat' is not a role const writeChatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1966,7 +1966,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(204); + expect(threadRecordReply.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1978,7 +1978,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Bob invokes the role to write to the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -1989,7 +1989,7 @@ export function testRecordsWriteHandler(): void { protocolRole : 'thread/participant' }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); }); it('uses a context role to authorize a co-update', async () => { @@ -2016,7 +2016,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply.status.code).to.equal(204); + expect(threadRecordReply.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2028,7 +2028,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Alice writes a chat message in the thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2038,7 +2038,7 @@ export function testRecordsWriteHandler(): void { parentContextId : threadRecord.message.contextId, }); const chatRecordReply = await dwn.processMessage(alice.did, chatRecord.message, { dataStream: chatRecord.dataStream }); - expect(chatRecordReply.status.code).to.equal(204); + expect(chatRecordReply.status.code).to.equal(202); // Bob invokes his admin role to co-update the chat message const chatCoUpdateRecord = await TestDataGenerator.generateFromRecordsWrite({ @@ -2075,7 +2075,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord1.message, { dataStream: threadRecord1.dataStream }); - expect(threadRecordReply1.status.code).to.equal(204); + expect(threadRecordReply1.status.code).to.equal(202); // Alice adds Bob as a 'thread/participant' in that thread const participantRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2087,7 +2087,7 @@ export function testRecordsWriteHandler(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantRecord.message, { dataStream: participantRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // Alice creates a second thread const threadRecord2 = await TestDataGenerator.generateRecordsWrite({ @@ -2097,7 +2097,7 @@ export function testRecordsWriteHandler(): void { protocolPath : 'thread' }); const threadRecordReply2 = await dwn.processMessage(alice.did, threadRecord2.message, { dataStream: threadRecord2.dataStream }); - expect(threadRecordReply2.status.code).to.equal(204); + expect(threadRecordReply2.status.code).to.equal(202); // Bob invokes his role to try to write to the second thread const chatRecord = await TestDataGenerator.generateRecordsWrite({ @@ -2177,7 +2177,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, messageFromBob.message, { dataStream: messageFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(204); + expect(bobWriteReply.status.code).to.equal(202); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -2242,7 +2242,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, messageFromBob.message, { dataStream: messageFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(204); + expect(bobWriteReply.status.code).to.equal(202); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -2311,7 +2311,7 @@ export function testRecordsWriteHandler(): void { ); const bobWriteReply = await dwn.processMessage(alice.did, messageFromBob.message, { dataStream: messageFromBob.dataStream }); - expect(bobWriteReply.status.code).to.equal(204); + expect(bobWriteReply.status.code).to.equal(202); // verify bob's message got written to the DB const messageDataForQueryingBobsWrite = await TestDataGenerator.generateRecordsQuery({ @@ -2382,7 +2382,7 @@ export function testRecordsWriteHandler(): void { const credentialApplicationReply = await dwn.processMessage(alice.did, credentialApplication.message, { dataStream: credentialApplication.dataStream }); - expect(credentialApplicationReply.status.code).to.equal(204); + expect(credentialApplicationReply.status.code).to.equal(202); // generate a credential application response message from a fake VC issuer const encodedCredentialResponse = new TextEncoder().encode('credential response data'); @@ -2533,7 +2533,7 @@ export function testRecordsWriteHandler(): void { data }); const writeReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // update the image to a not-allowed data format const newDataBytes = TestDataGenerator.randomBytes(100); @@ -2597,7 +2597,7 @@ export function testRecordsWriteHandler(): void { data }); const writeReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // update the image to a different data format const newDataFormat = 'any-new-data-format'; @@ -2665,7 +2665,7 @@ export function testRecordsWriteHandler(): void { }); const credentialApplicationReply = await dwn.processMessage( alice.did, credentialApplication.message, { dataStream: credentialApplication.dataStream }); - expect(credentialApplicationReply.status.code).to.equal(204); + expect(credentialApplicationReply.status.code).to.equal(202); // Try and fail to write another 'credentialApplication' below the first 'credentialApplication' const failedCredentialApplication = await TestDataGenerator.generateRecordsWrite({ @@ -2694,7 +2694,7 @@ export function testRecordsWriteHandler(): void { }); const credentialResponseReply = await dwn.processMessage(alice.did, credentialResponse.message, { dataStream: credentialResponse.dataStream }); - expect(credentialResponseReply.status.code).to.equal(204); + expect(credentialResponseReply.status.code).to.equal(202); // Try and fail to write a 'credentialApplication' below 'credentialApplication/credentialResponse' // Testing case where there is no rule set for any record type at the given level in the hierarchy @@ -2740,7 +2740,7 @@ export function testRecordsWriteHandler(): void { }); let reply = await dwn.processMessage(alice.did, aliceWriteMessageData.message, { dataStream: aliceWriteMessageData.dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); // test that Bob is not allowed to write to Alice's DWN const bob = await TestDataGenerator.generateDidKeyPersona(); @@ -2791,7 +2791,7 @@ export function testRecordsWriteHandler(): void { }); let reply = await dwn.processMessage(pfi.did, askMessageData.message, { dataStream: askMessageData.dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const offerMessageData = await TestDataGenerator.generateRecordsWrite({ author : pfi, @@ -2804,7 +2804,7 @@ export function testRecordsWriteHandler(): void { }); reply = await dwn.processMessage(pfi.did, offerMessageData.message, { dataStream: offerMessageData.dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); // the actual test: making sure fulfillment message is accepted const fulfillmentMessageData = await TestDataGenerator.generateRecordsWrite({ @@ -2817,7 +2817,7 @@ export function testRecordsWriteHandler(): void { data }); reply = await dwn.processMessage(pfi.did, fulfillmentMessageData.message, { dataStream: fulfillmentMessageData.dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); // verify the fulfillment message is stored const recordsQueryMessageData = await TestDataGenerator.generateRecordsQuery({ @@ -2866,7 +2866,7 @@ export function testRecordsWriteHandler(): void { }); let reply = await dwn.processMessage(pfi.did, askMessageData.message, { dataStream: askMessageData.dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); // the actual test: making sure fulfillment message fails const fulfillmentMessageData = await TestDataGenerator.generateRecordsWrite({ @@ -2994,7 +2994,7 @@ export function testRecordsWriteHandler(): void { }); const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const protocolDefinition = socialMediaProtocolDefinition; const protocol = protocolDefinition.protocol; @@ -3020,7 +3020,7 @@ export function testRecordsWriteHandler(): void { recipient : alice.did }); const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(202); // allows write but is not readable or queryable + expect(imageReply.status.code).to.equal(204); // allows write but is not readable or queryable // verify the record is not able to be read const bobRecordsReadData = await RecordsRead.create({ @@ -3086,7 +3086,7 @@ export function testRecordsWriteHandler(): void { }); const reply = await dwn.processMessage(alice.did, message, { dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); const protocolDefinition = socialMediaProtocolDefinition; const protocol = protocolDefinition.protocol; @@ -3112,7 +3112,7 @@ export function testRecordsWriteHandler(): void { recipient : alice.did }); const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); - expect(imageReply.status.code).to.equal(202); // allows write but is not readable or queryable + expect(imageReply.status.code).to.equal(204); // allows write but is not readable or queryable // verify the record is not able to be read const bobRecordsReadData = await RecordsRead.create({ @@ -3191,7 +3191,7 @@ export function testRecordsWriteHandler(): void { ); const writeReply = await dwn.processMessage(alice.did, docWrite.message, { dataStream }); - expect(writeReply.status.code).to.equal(204); + expect(writeReply.status.code).to.equal(202); // write a `RecordsWrite` message with schema const data2 = TestDataGenerator.randomBytes(100); @@ -3208,7 +3208,7 @@ export function testRecordsWriteHandler(): void { ); const write2Reply = await dwn.processMessage(alice.did, doc2Write.message, { dataStream: data2Stream }); - expect(write2Reply.status.code).to.equal(204); + expect(write2Reply.status.code).to.equal(202); // verify messages got written to the DB const recordsQuery = await RecordsQuery.create({ @@ -3260,7 +3260,7 @@ export function testRecordsWriteHandler(): void { }); const reply = await dwn.processMessage(alice.did, testRecord.message, { dataStream: testRecord.dataStream }); - expect(reply.status.code).to.equal(204); + expect(reply.status.code).to.equal(202); // test max record size const data2 = TestDataGenerator.randomBytes(1000); @@ -3273,7 +3273,7 @@ export function testRecordsWriteHandler(): void { }); const reply2 = await dwn.processMessage(alice.did, testRecord2.message, { dataStream: testRecord2.dataStream }); - expect(reply2.status.code).to.equal(204); + expect(reply2.status.code).to.equal(202); // test beyond max size const data3 = TestDataGenerator.randomBytes(1001); @@ -3342,7 +3342,7 @@ export function testRecordsWriteHandler(): void { }); const reply2 = await dwn.processMessage(alice.did, testRecord2.message, { dataStream: testRecord2.dataStream }); - expect(reply2.status.code).to.equal(204); + expect(reply2.status.code).to.equal(202); }); it('should fail authorization if protocol message size is more than specified maximum size', async () => { @@ -3397,7 +3397,7 @@ export function testRecordsWriteHandler(): void { }); const reply2 = await dwn.processMessage(alice.did, testRecord2.message, { dataStream: testRecord2.dataStream }); - expect(reply2.status.code).to.equal(204); + expect(reply2.status.code).to.equal(202); }); it('should fail if a write references a parent that has been deleted', async () => { @@ -3431,7 +3431,7 @@ export function testRecordsWriteHandler(): void { const foo1 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: foo1.dataStream }); - expect(foo1WriteResponse.status.code).equals(204); + expect(foo1WriteResponse.status.code).equals(202); // 2. Alice deletes foo1 const deleteFoo = await TestDataGenerator.generateRecordsDelete({ @@ -3486,7 +3486,7 @@ export function testRecordsWriteHandler(): void { const foo1 = await TestDataGenerator.generateRecordsWrite(fooOptions); const foo1WriteResponse = await dwn.processMessage(alice.did, foo1.message, { dataStream: foo1.dataStream }); - expect(foo1WriteResponse.status.code).equals(204); + expect(foo1WriteResponse.status.code).equals(202); // 2. Alice tries to write a bar1 referencing the foo1 in parentId, but contextId does not reference the same parent const barOptions = { @@ -3560,7 +3560,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob invokes the grant in order to write a record to the protocol const { recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({ @@ -3570,7 +3570,7 @@ export function testRecordsWriteHandler(): void { permissionGrantId : permissionGrant.recordsWrite.message.recordId, }); const recordsWriteReply = await dwn.processMessage(alice.did, recordsWrite.message, { dataStream }); - expect(recordsWriteReply.status.code).to.equal(204); + expect(recordsWriteReply.status.code).to.equal(202); }); it('rejects writes of protocol records with mismatching protocol grant scopes', async () => { @@ -3607,7 +3607,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob invokes the grant, failing to write to a different protocol than the grant allows const { recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({ @@ -3649,7 +3649,7 @@ export function testRecordsWriteHandler(): void { }); const alicesRecordsWriteReply = await dwn.processMessage(alice.did, alicesRecordsWrite.message, { dataStream: alicesRecordsWrite.dataStream }); - expect(alicesRecordsWriteReply.status.code).to.equal(204); + expect(alicesRecordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant const permissionGrant = await PermissionsProtocol.createGrant({ @@ -3669,7 +3669,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3682,7 +3682,7 @@ export function testRecordsWriteHandler(): void { permissionGrantId : permissionGrant.recordsWrite.message.recordId, }); const bobsRecordsWriteReply = await dwn.processMessage(alice.did, bobsRecordsWrite.message, { dataStream: bobsRecordsWrite.dataStream }); - expect(bobsRecordsWriteReply.status.code).to.equal(204); + expect(bobsRecordsWriteReply.status.code).to.equal(202); }); it('rejects writes of protocol records with mismatching contextId grant scopes', async () => { @@ -3713,7 +3713,7 @@ export function testRecordsWriteHandler(): void { }); const alicesRecordsWriteReply = await dwn.processMessage(alice.did, alicesRecordsWrite.message, { dataStream: alicesRecordsWrite.dataStream }); - expect(alicesRecordsWriteReply.status.code).to.equal(204); + expect(alicesRecordsWriteReply.status.code).to.equal(202); // Alice gives Bob a permission grant const permissionGrant = await PermissionsProtocol.createGrant({ @@ -3733,7 +3733,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3785,7 +3785,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3795,7 +3795,7 @@ export function testRecordsWriteHandler(): void { permissionGrantId : permissionGrant.recordsWrite.message.recordId, }); const bobsRecordsWriteReply = await dwn.processMessage(alice.did, bobsRecordsWrite.message, { dataStream: bobsRecordsWrite.dataStream }); - expect(bobsRecordsWriteReply.status.code).to.equal(204); + expect(bobsRecordsWriteReply.status.code).to.equal(202); }); it('rejects writes of protocol records with mismatching protocolPath grant scopes', async () => { @@ -3833,7 +3833,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); // Bob invokes the grant in order to write a record to the protocol const bobsRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3885,7 +3885,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -3902,7 +3902,7 @@ export function testRecordsWriteHandler(): void { publishedRecordsWrite.message, { dataStream: publishedRecordsWrite.dataStream } ); - expect(publishedRecordsWriteReply.status.code).to.equal(204); + expect(publishedRecordsWriteReply.status.code).to.equal(202); // Bob is not able to write an unpublished record const unpublishedRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -3954,7 +3954,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -3984,7 +3984,7 @@ export function testRecordsWriteHandler(): void { }); const unpublishedRecordsWriteReply = await dwn.processMessage(alice.did, unpublishedRecordsWrite.message, { dataStream: unpublishedRecordsWrite.dataStream }); - expect(unpublishedRecordsWriteReply.status.code).to.equal(204); + expect(unpublishedRecordsWriteReply.status.code).to.equal(202); }); it('Allows both published and unpublished records if grant condition `published` is undefined', async () => { @@ -4023,7 +4023,7 @@ export function testRecordsWriteHandler(): void { permissionGrant.recordsWrite.message, { dataStream: grantDataStream } ); - expect(permissionGrantWriteReply.status.code).to.equal(204); + expect(permissionGrantWriteReply.status.code).to.equal(202); const permissionGrantId = permissionGrant.recordsWrite.message.recordId; @@ -4040,7 +4040,7 @@ export function testRecordsWriteHandler(): void { publishedRecordsWrite.message, { dataStream: publishedRecordsWrite.dataStream } ); - expect(publishedRecordsWriteReply.status.code).to.equal(204); + expect(publishedRecordsWriteReply.status.code).to.equal(202); // Bob is able to write an unpublished record const unpublishedRecordsWrite = await TestDataGenerator.generateRecordsWrite({ @@ -4052,7 +4052,7 @@ export function testRecordsWriteHandler(): void { }); const unpublishedRecordsWriteReply = await dwn.processMessage(alice.did, unpublishedRecordsWrite.message, { dataStream: unpublishedRecordsWrite.dataStream }); - expect(unpublishedRecordsWriteReply.status.code).to.equal(204); + expect(unpublishedRecordsWriteReply.status.code).to.equal(202); }); }); }); @@ -4071,7 +4071,7 @@ export function testRecordsWriteHandler(): void { data, }); const prunedRecordsWriteReply = await dwn.processMessage(alice.did, prunedRecordsWrite.message); - expect(prunedRecordsWriteReply.status.code).to.equal(202); + expect(prunedRecordsWriteReply.status.code).to.equal(204); // Update record to published, omitting dataStream const recordsWrite = await TestDataGenerator.generateFromRecordsWrite({ @@ -4099,7 +4099,7 @@ export function testRecordsWriteHandler(): void { data, }); const prunedRecordsWriteReply = await dwn.processMessage(alice.did, prunedRecordsWrite.message); - expect(prunedRecordsWriteReply.status.code).to.equal(202); + expect(prunedRecordsWriteReply.status.code).to.equal(204); // Update record to published, omitting dataStream const recordsWrite = await TestDataGenerator.generateFromRecordsWrite({ @@ -4126,7 +4126,7 @@ export function testRecordsWriteHandler(): void { data }); const aliceWriteReply = await dwn.processMessage(alice.did, aliceWriteData.message, { dataStream: aliceWriteData.dataStream }); - expect(aliceWriteReply.status.code).to.equal(204); + expect(aliceWriteReply.status.code).to.equal(202); const aliceQueryWriteAfterAliceWriteData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -4144,7 +4144,7 @@ export function testRecordsWriteHandler(): void { dataSize : 4 }); const bobWriteReply = await dwn.processMessage(bob.did, bobWriteData.message); // intentionally missing data stream - expect(bobWriteReply.status.code).to.equal(202); // NOTE: allows write here but does not allow read or query later + expect(bobWriteReply.status.code).to.equal(204); // NOTE: allows write here but does not allow read or query later const aliceQueryWriteAfterBobWriteData = await TestDataGenerator.generateRecordsQuery({ author : alice, @@ -4173,7 +4173,7 @@ export function testRecordsWriteHandler(): void { const processEncoded = sinon.spy(RecordsWriteHandler.prototype as any, 'cloneAndAddEncodedData'); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(204); + expect(writeMessage.status.code).to.equal(202); sinon.assert.calledOnce(processEncoded); }); @@ -4184,7 +4184,7 @@ export function testRecordsWriteHandler(): void { const processEncoded = sinon.spy(RecordsWriteHandler.prototype as any, 'cloneAndAddEncodedData'); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(204); + expect(writeMessage.status.code).to.equal(202); sinon.assert.notCalled(processEncoded); }); @@ -4194,7 +4194,7 @@ export function testRecordsWriteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, data: dataBytes }); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(204); + expect(writeMessage.status.code).to.equal(202); const messageCid = await Message.getCid(message); const storedMessage = await messageStore.get(alice.did, messageCid); @@ -4207,7 +4207,7 @@ export function testRecordsWriteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, data: dataBytes }); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(204); + expect(writeMessage.status.code).to.equal(202); const messageCid = await Message.getCid(message); const storedMessage = await messageStore.get(alice.did, messageCid); @@ -4220,7 +4220,7 @@ export function testRecordsWriteHandler(): void { const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, data: dataBytes }); const writeMessage = await dwn.processMessage(alice.did, message, { dataStream }); - expect(writeMessage.status.code).to.equal(204); + expect(writeMessage.status.code).to.equal(202); const messageCid = await Message.getCid(message); const storedMessage = await messageStore.get(alice.did, messageCid); diff --git a/tests/scenarios/end-to-end-tests.spec.ts b/tests/scenarios/end-to-end-tests.spec.ts index c3ca34063..d4caa2c84 100644 --- a/tests/scenarios/end-to-end-tests.spec.ts +++ b/tests/scenarios/end-to-end-tests.spec.ts @@ -114,7 +114,7 @@ export function testEndToEndScenarios(): void { encryptSymmetricKeyWithProtocolContextDerivedKey : true }); const threadRecordReply1 = await dwn.processMessage(alice.did, threadRecord.message, { dataStream: threadRecord.dataStream }); - expect(threadRecordReply1.status.code).to.equal(204); + expect(threadRecordReply1.status.code).to.equal(202); // 2. Alice adds Bob as a participant giving him the [context-derived private key] encrypted using [Bob's participant-level public key] @@ -153,7 +153,7 @@ export function testEndToEndScenarios(): void { }); const participantRecordReply = await dwn.processMessage(alice.did, participantBobRecord.message, { dataStream: participantBobRecord.dataStream }); - expect(participantRecordReply.status.code).to.equal(204); + expect(participantRecordReply.status.code).to.equal(202); // 3. Alice writes a chat message(s) in the thread const messageByAlice = 'Message from Alice'; @@ -170,7 +170,7 @@ export function testEndToEndScenarios(): void { encryptSymmetricKeyWithProtocolContextDerivedKey : true }); const chatMessageReply = await dwn.processMessage(alice.did, chatMessageByAlice.message, { dataStream: chatMessageByAlice.dataStream }); - expect(chatMessageReply.status.code).to.equal(204); + expect(chatMessageReply.status.code).to.equal(202); // Assume the below steps can be done since it is a common DWN usage pattern // 4. Alice sends an invite to Bob's DWN with the [context/thread ID] diff --git a/tests/scenarios/messages-query.spec.ts b/tests/scenarios/messages-query.spec.ts index c880c70cd..5d0acd8af 100644 --- a/tests/scenarios/messages-query.spec.ts +++ b/tests/scenarios/messages-query.spec.ts @@ -62,7 +62,7 @@ export function testMessagesQueryScenarios(): void { // insert data const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); - expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); expect(protocolReply.status.code).to.equal(202, 'ProtocolConfigure'); const messagesQueryRecords = await TestDataGenerator.generateMessagesQuery({ @@ -95,7 +95,7 @@ export function testMessagesQueryScenarios(): void { // insert data const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); - expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); expect(protocolReply.status.code).to.equal(202, 'ProtocolConfigure'); let messagesQueryRecords = await TestDataGenerator.generateMessagesQuery({ @@ -154,7 +154,7 @@ export function testMessagesQueryScenarios(): void { // write 1 const record1 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record1Reply = await dwn.processMessage(alice.did, record1.message, { dataStream: record1.dataStream }); - expect(record1Reply.status.code).to.equal(204, 'RecordsWrite'); + expect(record1Reply.status.code).to.equal(202, 'RecordsWrite'); // other messages const protocol = await TestDataGenerator.generateProtocolsConfigure({ author: alice }); @@ -164,7 +164,7 @@ export function testMessagesQueryScenarios(): void { // write 2 const record2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record2Reply = await dwn.processMessage(alice.did, record2.message, { dataStream: record2.dataStream }); - expect(record2Reply.status.code).to.equal(204, 'RecordsWrite'); + expect(record2Reply.status.code).to.equal(202, 'RecordsWrite'); // delete write 1 const delete1 = await TestDataGenerator.generateRecordsDelete({ author: alice, recordId: record1.message.recordId }); @@ -217,7 +217,7 @@ export function testMessagesQueryScenarios(): void { // insert data const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); - expect(writeReply.status.code).to.equal(204, 'RecordsWrite'); + expect(writeReply.status.code).to.equal(202, 'RecordsWrite'); expect(protocolReply.status.code).to.equal(202, 'ProtocolConfigure'); // query from last day of 2021 @@ -296,12 +296,12 @@ export function testMessagesQueryScenarios(): void { // create a record for proto1 const write1proto1 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto1, ...postProperties }); const write1Response = await dwn.processMessage(alice.did, write1proto1.message, { dataStream: write1proto1.dataStream }); - expect(write1Response.status.code).equals(204); + expect(write1Response.status.code).equals(202); // create a record for proto2 const write1proto2 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto2, ...postProperties }); const write1Proto2Response = await dwn.processMessage(alice.did, write1proto2.message, { dataStream: write1proto2.dataStream }); - expect(write1Proto2Response.status.code).equals(204); + expect(write1Proto2Response.status.code).equals(202); // bob requests permissions for proto 1 const requestProto1 = await PermissionsProtocol.createRequest({ @@ -314,7 +314,7 @@ export function testMessagesQueryScenarios(): void { requestProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto1.permissionRequestBytes) } ); - expect(requestProto1Response.status.code).equals(204); + expect(requestProto1Response.status.code).equals(202); // bob requests permissions for proto 2 const requestProto2 = await PermissionsProtocol.createRequest({ @@ -327,7 +327,7 @@ export function testMessagesQueryScenarios(): void { requestProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto2.permissionRequestBytes) } ); - expect(requestProto2Response.status.code).equals(204); + expect(requestProto2Response.status.code).equals(202); // alice grants bob permissions for proto 1 const grantProto1 = await PermissionsProtocol.createGrant({ @@ -341,7 +341,7 @@ export function testMessagesQueryScenarios(): void { grantProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto1.permissionGrantBytes) } ); - expect(grantProto1Response.status.code).equals(204); + expect(grantProto1Response.status.code).equals(202); // alice grants bob permissions for proto 2 const grantProto2 = await PermissionsProtocol.createGrant({ @@ -355,7 +355,7 @@ export function testMessagesQueryScenarios(): void { grantProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto2.permissionGrantBytes) } ); - expect(grantProto2Response.status.code).equals(204); + expect(grantProto2Response.status.code).equals(202); // filter for proto1 messages let proto1MessagesQuery = await TestDataGenerator.generateMessagesQuery({ @@ -407,7 +407,7 @@ export function testMessagesQueryScenarios(): void { revokeProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto1.permissionRevocationBytes) } ); - expect(revokeProto1Response.status.code).equals(204); + expect(revokeProto1Response.status.code).equals(202); // revoke permissions for proto2 const revokeProto2 = await PermissionsProtocol.createRevocation({ @@ -419,7 +419,7 @@ export function testMessagesQueryScenarios(): void { revokeProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto2.permissionRevocationBytes) } ); - expect(revokeProto2Response.status.code).equals(204); + expect(revokeProto2Response.status.code).equals(202); //query messages beyond the cursor proto1MessagesQuery = await TestDataGenerator.generateMessagesQuery({ diff --git a/tests/scenarios/nested-roles.spec.ts b/tests/scenarios/nested-roles.spec.ts index 962c6d3de..428711f97 100644 --- a/tests/scenarios/nested-roles.spec.ts +++ b/tests/scenarios/nested-roles.spec.ts @@ -101,7 +101,7 @@ export function testNestedRoleScenarios(): void { protocolPath : 'community' }); const communityRecordReply = await dwn.processMessage(alice.did, communityRecord.message, { dataStream: communityRecord.dataStream }); - expect(communityRecordReply.status.code).to.equal(204); + expect(communityRecordReply.status.code).to.equal(202); // 3. Alice can assign Bob as an 'admin' in the community const communityAdminBobRecord = await TestDataGenerator.generateRecordsWrite({ @@ -113,7 +113,7 @@ export function testNestedRoleScenarios(): void { }); const communityAdminBobRecordReply = await dwn.processMessage(alice.did, communityAdminBobRecord.message, { dataStream: communityAdminBobRecord.dataStream }); - expect(communityAdminBobRecordReply.status.code).to.equal(204); + expect(communityAdminBobRecordReply.status.code).to.equal(202); // 4. Bob can invoke his `admin` role to perform actions: // 4a. Bob can read the community record @@ -139,7 +139,7 @@ export function testNestedRoleScenarios(): void { parentContextId : communityRecord.message.contextId }); const channel1RecordReply = await dwn.processMessage(alice.did, channel1Record.message, { dataStream: channel1Record.dataStream }); - expect(channel1RecordReply.status.code).to.equal(204); + expect(channel1RecordReply.status.code).to.equal(202); const channel2Record = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -149,7 +149,7 @@ export function testNestedRoleScenarios(): void { parentContextId : communityRecord.message.contextId }); const channel2RecordReply = await dwn.processMessage(alice.did, channel2Record.message, { dataStream: channel2Record.dataStream }); - expect(channel2RecordReply.status.code).to.equal(204); + expect(channel2RecordReply.status.code).to.equal(202); // 5. Bob as the creator/author of the channels can add participants in the gated-channels // 5a. Bob can add himself and Carol as participants in the gated-channel 1 @@ -162,7 +162,7 @@ export function testNestedRoleScenarios(): void { }); const channel1ParticipantBobRecordReply = await dwn.processMessage(alice.did, channel1ParticipantBobRecord.message, { dataStream: channel1ParticipantBobRecord.dataStream }); - expect(channel1ParticipantBobRecordReply.status.code).to.equal(204); + expect(channel1ParticipantBobRecordReply.status.code).to.equal(202); const channel1ParticipantCarolRecord = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -173,7 +173,7 @@ export function testNestedRoleScenarios(): void { }); const channel1ParticipantCarolRecordReply = await dwn.processMessage(alice.did, channel1ParticipantCarolRecord.message, { dataStream: channel1ParticipantCarolRecord.dataStream }); - expect(channel1ParticipantCarolRecordReply.status.code).to.equal(204); + expect(channel1ParticipantCarolRecordReply.status.code).to.equal(202); // 5b. Bob can add himself and Daniel as participants in the gated-channel 2 const channel2ParticipantBobRecord = await TestDataGenerator.generateRecordsWrite({ @@ -185,7 +185,7 @@ export function testNestedRoleScenarios(): void { }); const channel2ParticipantBobRecordReply = await dwn.processMessage(alice.did, channel2ParticipantBobRecord.message, { dataStream: channel2ParticipantBobRecord.dataStream }); - expect(channel2ParticipantBobRecordReply.status.code).to.equal(204); + expect(channel2ParticipantBobRecordReply.status.code).to.equal(202); const channel2ParticipantDanielRecord = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -196,7 +196,7 @@ export function testNestedRoleScenarios(): void { }); const channel2ParticipantDanielRecordReply = await dwn.processMessage(alice.did, channel2ParticipantDanielRecord.message, { dataStream: channel2ParticipantDanielRecord.dataStream }); - expect(channel2ParticipantDanielRecordReply.status.code).to.equal(204); + expect(channel2ParticipantDanielRecordReply.status.code).to.equal(202); // 6. Carol can read the gated channel 1 record by invoking her child participant role to the gated channel 1 const carolRead = await RecordsRead.create({ @@ -250,7 +250,7 @@ export function testNestedRoleScenarios(): void { }); const participantDanielRecordAttempt2Reply = await dwn.processMessage(alice.did, participantDanielRecordAttempt2.message, { dataStream: participantDanielRecordAttempt2.dataStream }); - expect(participantDanielRecordAttempt2Reply.status.code).to.equal(204); + expect(participantDanielRecordAttempt2Reply.status.code).to.equal(202); // 10. Bob can invoke the participant role to write a chat message in the channel const bobChatMessage = await TestDataGenerator.generateRecordsWrite({ diff --git a/tests/scenarios/subscriptions.spec.ts b/tests/scenarios/subscriptions.spec.ts index 8bc772a31..580e789e9 100644 --- a/tests/scenarios/subscriptions.spec.ts +++ b/tests/scenarios/subscriptions.spec.ts @@ -90,7 +90,7 @@ export function testSubscriptionScenarios(): void { const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const write1MessageCid = await Message.getCid(write1.message); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(204); + expect(write1Reply.status.code).to.equal(202); const protocol1 = await TestDataGenerator.generateProtocolsConfigure({ author: alice }); const protocol1MessageCid = await Message.getCid(protocol1.message); @@ -165,7 +165,7 @@ export function testSubscriptionScenarios(): void { // create one of each message types a RecordsWrite and a ProtocolsConfigure const record = await TestDataGenerator.generateRecordsWrite({ author: alice }); const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); - expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); const protocol = await TestDataGenerator.generateProtocolsConfigure({ author: alice }); const protocolReply = await dwn.processMessage(alice.did, protocol.message); @@ -259,7 +259,7 @@ export function testSubscriptionScenarios(): void { // create and updates the record, this creates two RecordsWrite messages const record = await TestDataGenerator.generateRecordsWrite({ author: alice }); const recordReply = await dwn.processMessage(alice.did, record.message, { dataStream: record.dataStream }); - expect(recordReply.status.code).to.equal(204, 'RecordsWrite'); + expect(recordReply.status.code).to.equal(202, 'RecordsWrite'); const record1MessageCid = await Message.getCid(record.message); const recordUpdate = await TestDataGenerator.generateFromRecordsWrite({ author: alice, existingWrite: record.recordsWrite }); @@ -289,7 +289,7 @@ export function testSubscriptionScenarios(): void { // write a second record const record2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record2Reply = await dwn.processMessage(alice.did, record2.message, { dataStream: record2.dataStream }); - expect(record2Reply.status.code).to.equal(204, 'RecordsWrite'); + expect(record2Reply.status.code).to.equal(202, 'RecordsWrite'); const record2MessageCid = await Message.getCid(record2.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -388,12 +388,12 @@ export function testSubscriptionScenarios(): void { // create a record for proto1 const write1proto1 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto1, ...postProperties }); const write1Response = await dwn.processMessage(alice.did, write1proto1.message, { dataStream: write1proto1.dataStream }); - expect(write1Response.status.code).equals(204); + expect(write1Response.status.code).equals(202); // create a record for proto2 const write1proto2 = await TestDataGenerator.generateRecordsWrite({ author: alice, protocol: proto2, ...postProperties }); const write1Proto2Response = await dwn.processMessage(alice.did, write1proto2.message, { dataStream: write1proto2.dataStream }); - expect(write1Proto2Response.status.code).equals(204); + expect(write1Proto2Response.status.code).equals(202); // bob requests permissions for proto1 const requestProto1 = await PermissionsProtocol.createRequest({ @@ -406,7 +406,7 @@ export function testSubscriptionScenarios(): void { requestProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto1.permissionRequestBytes) } ); - expect(requestProto1Response.status.code).equals(204); + expect(requestProto1Response.status.code).equals(202); // bob requests permissions for proto2 const requestProto2 = await PermissionsProtocol.createRequest({ @@ -419,7 +419,7 @@ export function testSubscriptionScenarios(): void { requestProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(requestProto2.permissionRequestBytes) } ); - expect(requestProto2Response.status.code).equals(204); + expect(requestProto2Response.status.code).equals(202); // alice grants permissions for proto1 const grantProto1 = await PermissionsProtocol.createGrant({ @@ -433,7 +433,7 @@ export function testSubscriptionScenarios(): void { grantProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto1.permissionGrantBytes) } ); - expect(grantProto1Response.status.code).equals(204); + expect(grantProto1Response.status.code).equals(202); // alice grants permissions for proto2 const grantProto2 = await PermissionsProtocol.createGrant({ @@ -447,7 +447,7 @@ export function testSubscriptionScenarios(): void { grantProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(grantProto2.permissionGrantBytes) } ); - expect(grantProto2Response.status.code).equals(204); + expect(grantProto2Response.status.code).equals(202); // poll until the messages are received by the handlers await Poller.pollUntilSuccessOrTimeout(async () => { @@ -490,7 +490,7 @@ export function testSubscriptionScenarios(): void { revokeProto1.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto1.permissionRevocationBytes) } ); - expect(revokeProto1Response.status.code).equals(204); + expect(revokeProto1Response.status.code).equals(202); // revoke permissions for proto2 const revokeProto2 = await PermissionsProtocol.createRevocation({ @@ -502,7 +502,7 @@ export function testSubscriptionScenarios(): void { revokeProto2.recordsWrite.message, { dataStream: DataStream.fromBytes(revokeProto2.permissionRevocationBytes) } ); - expect(revokeProto2Response.status.code).equals(204); + expect(revokeProto2Response.status.code).equals(202); // poll until the messages are received by the handlers await Poller.pollUntilSuccessOrTimeout(async () => { @@ -563,7 +563,7 @@ export function testSubscriptionScenarios(): void { // write a record const record1 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record1Reply = await dwn.processMessage(alice.did, record1.message, { dataStream: record1.dataStream }); - expect(record1Reply.status.code).to.equal(204); + expect(record1Reply.status.code).to.equal(202); const record1MessageCid = await Message.getCid(record1.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -581,12 +581,12 @@ export function testSubscriptionScenarios(): void { // write two more message. const record2 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record2Reply = await dwn.processMessage(alice.did, record2.message, { dataStream: record2.dataStream }); - expect(record2Reply.status.code).to.equal(204); + expect(record2Reply.status.code).to.equal(202); const record2MessageCid = await Message.getCid(record2.message); const record3 = await TestDataGenerator.generateRecordsWrite({ author: alice }); const record3Reply = await dwn.processMessage(alice.did, record3.message, { dataStream: record3.dataStream }); - expect(record3Reply.status.code).to.equal(204); + expect(record3Reply.status.code).to.equal(202); const record3MessageCid = await Message.getCid(record3.message); await Poller.pollUntilSuccessOrTimeout(async () => { @@ -648,17 +648,17 @@ export function testSubscriptionScenarios(): void { // we create a non published record, this will only show up in the control subscription const writeNotPublished = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1' }); const writeNotPublishedReply = await dwn.processMessage(alice.did, writeNotPublished.message, { dataStream: writeNotPublished.dataStream }); - expect(writeNotPublishedReply.status.code).to.equal(204); + expect(writeNotPublishedReply.status.code).to.equal(202); // we create a published record, this will show up in both the control and anonymous subscription const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', published: true }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(204); + expect(write1Reply.status.code).to.equal(202); // we create another published record, this will show up in both the control and anonymous subscription const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', published: true }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(204); + expect(write2Reply.status.code).to.equal(202); await Poller.pollUntilSuccessOrTimeout(async () => { // publishedMessages array should only contain the two published messages @@ -722,16 +722,16 @@ export function testSubscriptionScenarios(): void { // write two messages for bob const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', recipient: bob.did }); const write1Reply = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream }); - expect(write1Reply.status.code).to.equal(204); + expect(write1Reply.status.code).to.equal(202); const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', recipient: bob.did }); const write2Reply = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream }); - expect(write2Reply.status.code).to.equal(204); + expect(write2Reply.status.code).to.equal(202); // write one message for carol const writeForCarol = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'http://schema1', recipient: carol.did }); const writeForCarolReply = await dwn.processMessage(alice.did, writeForCarol.message, { dataStream: writeForCarol.dataStream }); - expect(writeForCarolReply.status.code).to.equal(204); + expect(writeForCarolReply.status.code).to.equal(202); await Poller.pollUntilSuccessOrTimeout(async () => { // bob should have received the two messages intended for him @@ -778,7 +778,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread' }); const threadReply = await dwn.processMessage(alice.did, thread.message, { dataStream: thread.dataStream }); - expect(threadReply.status.code).to.equal(204); + expect(threadReply.status.code).to.equal(202); // subscribe to this thread's messages @@ -831,7 +831,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread/participant' }); const bobParticipantReply = await dwn.processMessage(alice.did, bobParticipant.message, { dataStream: bobParticipant.dataStream }); - expect(bobParticipantReply.status.code).to.equal(204); + expect(bobParticipantReply.status.code).to.equal(202); // add carol as participant const carolParticipant = await TestDataGenerator.generateRecordsWrite({ @@ -842,7 +842,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread/participant' }); const carolParticipantReply = await dwn.processMessage(alice.did, carolParticipant.message, { dataStream: carolParticipant.dataStream }); - expect(carolParticipantReply.status.code).to.equal(204); + expect(carolParticipantReply.status.code).to.equal(202); // add another thread as a control, will not show up in handled message events const additionalThread = await TestDataGenerator.generateRecordsWrite({ @@ -851,7 +851,7 @@ export function testSubscriptionScenarios(): void { protocolPath : 'thread' }); const additionalThreadReply = await dwn.processMessage(alice.did, additionalThread.message, { dataStream: additionalThread.dataStream }); - expect(additionalThreadReply.status.code).to.equal(204); + expect(additionalThreadReply.status.code).to.equal(202); await Poller.pollUntilSuccessOrTimeout(async () => { expect(messages.length).to.equal(2); @@ -871,7 +871,7 @@ export function testSubscriptionScenarios(): void { protocolRole : 'thread/participant', }); const message1Reply = await dwn.processMessage(alice.did, message1.message, { dataStream: message1.dataStream }); - expect(message1Reply.status.code).to.equal(204); + expect(message1Reply.status.code).to.equal(202); const message2 = await TestDataGenerator.generateRecordsWrite({ author : bob, @@ -882,7 +882,7 @@ export function testSubscriptionScenarios(): void { protocolRole : 'thread/participant', }); const message2Reply = await dwn.processMessage(alice.did, message2.message, { dataStream: message2.dataStream }); - expect(message2Reply.status.code).to.equal(204); + expect(message2Reply.status.code).to.equal(202); const message3 = await TestDataGenerator.generateRecordsWrite({ author : carol, @@ -893,7 +893,7 @@ export function testSubscriptionScenarios(): void { protocolRole : 'thread/participant', }); const message3Reply = await dwn.processMessage(alice.did, message3.message, { dataStream: message3.dataStream }); - expect(message3Reply.status.code).to.equal(204); + expect(message3Reply.status.code).to.equal(202); await Poller.pollUntilSuccessOrTimeout(async () => { expect(messages.length).to.equal(5); From 505a0451e358d2b65b39b0a22268069a3189b234 Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 11:23:59 -0400 Subject: [PATCH 7/9] ok for real lets fix --- tests/scenarios/nested-roles.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scenarios/nested-roles.spec.ts b/tests/scenarios/nested-roles.spec.ts index 428711f97..563d39ddb 100644 --- a/tests/scenarios/nested-roles.spec.ts +++ b/tests/scenarios/nested-roles.spec.ts @@ -261,7 +261,7 @@ export function testNestedRoleScenarios(): void { parentContextId : channel1Record.message.contextId }); const bobChatMessageReply = await dwn.processMessage(alice.did, bobChatMessage.message, { dataStream: bobChatMessage.dataStream }); - expect(bobChatMessageReply.status.code).to.equal(204); + expect(bobChatMessageReply.status.code).to.equal(202); // 11. Carol can invoke the participant role to read chat messages in the channel const carolQuery = await RecordsQuery.create({ @@ -286,7 +286,7 @@ export function testNestedRoleScenarios(): void { parentContextId : bobChatMessage.message.contextId }); const carolReactionReply = await dwn.processMessage(alice.did, carolReaction.message, { dataStream: carolReaction.dataStream }); - expect(carolReactionReply.status.code).to.equal(204); + expect(carolReactionReply.status.code).to.equal(202); // 13. Mallory CANNOT invoke the participant role (which she is not given) to read the chat messages in the channel const malloryQuery = await RecordsQuery.create({ From 4cdc9320ff4002cbdb77b9f7c4f1687971641184 Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Wed, 7 Aug 2024 12:10:40 -0400 Subject: [PATCH 8/9] comment --- src/handlers/records-write.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/handlers/records-write.ts b/src/handlers/records-write.ts index bb23288e3..47f8a1c39 100644 --- a/src/handlers/records-write.ts +++ b/src/handlers/records-write.ts @@ -163,6 +163,9 @@ export class RecordsWriteHandler implements MethodHandler { } const messageReply = { + // In order to discern between something that was accepted as a queryable write and something that was accepted + // as an initial state we use separate response codes. See https://github.com/TBD54566975/dwn-sdk-js/issues/695 + // for more details. status: (newMessageIsInitialWrite && dataStream === undefined) ? { code: 204, detail: 'No Content' } : { code: 202, detail: 'Accepted' } From 9599803f9fb20fbb347fdeb5c0db4adc6f190c21 Mon Sep 17 00:00:00 2001 From: Henry Tsai Date: Wed, 7 Aug 2024 11:27:34 -0700 Subject: [PATCH 9/9] Updated misleading tests to match intent clearly --- tests/handlers/records-write.spec.ts | 6 ++++-- tests/utils/test-data-generator.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/handlers/records-write.spec.ts b/tests/handlers/records-write.spec.ts index 30134c3a7..17c6acce1 100644 --- a/tests/handlers/records-write.spec.ts +++ b/tests/handlers/records-write.spec.ts @@ -3009,6 +3009,7 @@ export function testRecordsWriteHandler(): void { // bob learns of metadata (ie. dataCid) of alice's secret data, // attempts to gain unauthorized access by writing to alice's DWN through open protocol referencing the dataCid without supplying the data + // which he is allowed to do, the DWN will treat the operation as an initial-write or a record that has a later and different state. const imageRecordsWrite = await TestDataGenerator.generateRecordsWrite({ author : bob, protocol, @@ -3019,7 +3020,7 @@ export function testRecordsWriteHandler(): void { dataSize, recipient : alice.did }); - const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); + const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message); expect(imageReply.status.code).to.equal(204); // allows write but is not readable or queryable // verify the record is not able to be read @@ -3101,6 +3102,7 @@ export function testRecordsWriteHandler(): void { // bob learns of metadata (ie. dataCid) of alice's secret data, // attempts to gain unauthorized access by writing to alice's DWN through open protocol referencing the dataCid without supplying the data + // which he is allowed to do, the DWN will treat the operation as an initial-write or a record that has a later and different state. const imageRecordsWrite = await TestDataGenerator.generateRecordsWrite({ author : bob, protocol, @@ -3111,7 +3113,7 @@ export function testRecordsWriteHandler(): void { dataSize, recipient : alice.did }); - const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream }); + const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message); expect(imageReply.status.code).to.equal(204); // allows write but is not readable or queryable // verify the record is not able to be read diff --git a/tests/utils/test-data-generator.ts b/tests/utils/test-data-generator.ts index 12b358469..e777eef07 100644 --- a/tests/utils/test-data-generator.ts +++ b/tests/utils/test-data-generator.ts @@ -396,6 +396,7 @@ export class TestDataGenerator { /** * Generates a RecordsWrite message for testing. + * `dataBytes` & `dataStream` returned will be `undefined` as long as `dataCid` or `dataSize` is given. * Implementation currently uses `RecordsWrite.create()`. * @param input.attesters Attesters of the message. Will NOT be generated if not given. * @param input.data Data that belongs to the record. Generated when not given only if `dataCid` and `dataSize` are also not given.