@enbox/dwn-sdk-js 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/generated/precompiled-validators.js +1262 -3888
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/src/core/constants.js +0 -26
- package/dist/esm/src/core/constants.js.map +1 -1
- package/dist/esm/src/core/encryption-control.js +0 -10
- package/dist/esm/src/core/encryption-control.js.map +1 -1
- package/dist/esm/src/core/replication-apply.js.map +1 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/records-write.js +0 -9
- package/dist/esm/src/interfaces/records-write.js.map +1 -1
- package/dist/esm/src/store/index-level-compound.js.map +1 -1
- package/dist/esm/src/store/level-wrapper.js +6 -2
- package/dist/esm/src/store/level-wrapper.js.map +1 -1
- package/dist/esm/src/utils/encryption.js +2 -7
- package/dist/esm/src/utils/encryption.js.map +1 -1
- package/dist/esm/src/utils/hd-key.js +0 -27
- package/dist/esm/src/utils/hd-key.js.map +1 -1
- package/dist/esm/src/utils/jws.js.map +1 -1
- package/dist/esm/src/utils/protocols.js +23 -51
- package/dist/esm/src/utils/protocols.js.map +1 -1
- package/dist/esm/src/utils/records.js +17 -31
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/tests/core/constants.spec.js +1 -11
- package/dist/esm/tests/core/constants.spec.js.map +1 -1
- package/dist/esm/tests/core/validation-read-closure.spec.js +1 -1
- package/dist/esm/tests/core/validation-read-closure.spec.js.map +1 -1
- package/dist/esm/tests/dwn.spec.js +5 -5
- package/dist/esm/tests/dwn.spec.js.map +1 -1
- package/dist/esm/tests/features/author-delegated-grant.spec.js +16 -16
- package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-delegated-grant.spec.js +7 -7
- package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/permissions.spec.js +8 -8
- package/dist/esm/tests/features/permissions.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +18 -63
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
- package/dist/esm/tests/features/records-prune-cross-protocol.spec.js +5 -5
- package/dist/esm/tests/features/records-prune-cross-protocol.spec.js.map +1 -1
- package/dist/esm/tests/features/records-prune.spec.js +15 -15
- package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
- package/dist/esm/tests/features/records-squash.spec.js +9 -9
- package/dist/esm/tests/features/records-squash.spec.js.map +1 -1
- package/dist/esm/tests/features/records-tags.spec.js +28 -28
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
- package/dist/esm/tests/features/resumable-tasks.spec.js +3 -3
- package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
- package/dist/esm/tests/fuzz/data-stream.fuzz.spec.js +2 -2
- package/dist/esm/tests/fuzz/data-stream.fuzz.spec.js.map +1 -1
- package/dist/esm/tests/fuzz/filter.fuzz.spec.js +1 -1
- package/dist/esm/tests/fuzz/filter.fuzz.spec.js.map +1 -1
- package/dist/esm/tests/fuzz/records-utils.fuzz.spec.js +2 -2
- package/dist/esm/tests/fuzz/records-utils.fuzz.spec.js.map +1 -1
- package/dist/esm/tests/fuzz/resumable-task-store.fuzz.spec.js +4 -4
- package/dist/esm/tests/fuzz/resumable-task-store.fuzz.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +16 -16
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-configure.spec.js +5 -5
- package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-query.spec.js +11 -11
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-delete.spec.js +23 -23
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-query.spec.js +120 -120
- package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +16 -14
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +10 -10
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +41 -41
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-configure.spec.js +9 -9
- package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-write.spec.js +5 -51
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
- package/dist/esm/tests/jose/jws/general.spec.js +4 -4
- package/dist/esm/tests/jose/jws/general.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +2 -2
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/nested-roles.spec.js +1 -1
- package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/subscriptions.spec.js +28 -28
- package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
- package/dist/esm/tests/store/blockstore-mock.spec.js +1 -1
- package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -1
- package/dist/esm/tests/store/data-store-level.spec.js +3 -3
- package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/index-level.spec.js +83 -83
- package/dist/esm/tests/store/index-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store-level.spec.js +2 -2
- package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store.spec.js +30 -30
- package/dist/esm/tests/store/message-store.spec.js.map +1 -1
- package/dist/esm/tests/store-dependent-tests.spec.js +5 -0
- package/dist/esm/tests/store-dependent-tests.spec.js.map +1 -1
- package/dist/esm/tests/utils/data-stream.spec.js +15 -15
- package/dist/esm/tests/utils/data-stream.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption-callbacks.spec.js +18 -30
- package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption-control-test-utils.js +1 -1
- package/dist/esm/tests/utils/encryption-control-test-utils.js.map +1 -1
- package/dist/esm/tests/utils/encryption.spec.js +31 -34
- package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
- package/dist/esm/tests/utils/messages.spec.js +8 -8
- package/dist/esm/tests/utils/messages.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256k1.spec.js +2 -2
- package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256r1.spec.js +1 -1
- package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +76 -24
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +1 -1
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -1
- package/dist/types/generated/precompiled-validators.d.ts +88 -120
- package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
- package/dist/types/src/core/constants.d.ts +0 -13
- package/dist/types/src/core/constants.d.ts.map +1 -1
- package/dist/types/src/core/encryption-control.d.ts +0 -1
- package/dist/types/src/core/encryption-control.d.ts.map +1 -1
- package/dist/types/src/core/replication-apply.d.ts +0 -7
- package/dist/types/src/core/replication-apply.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/messages-subscribe.d.ts +1 -2
- package/dist/types/src/interfaces/messages-subscribe.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write.d.ts +0 -4
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
- package/dist/types/src/store/index-level-compound.d.ts +2 -4
- package/dist/types/src/store/index-level-compound.d.ts.map +1 -1
- package/dist/types/src/store/level-wrapper.d.ts.map +1 -1
- package/dist/types/src/types/protocols-types.d.ts +1 -1
- package/dist/types/src/types/protocols-types.d.ts.map +1 -1
- package/dist/types/src/utils/encryption.d.ts +0 -3
- package/dist/types/src/utils/encryption.d.ts.map +1 -1
- package/dist/types/src/utils/hd-key.d.ts +1 -11
- package/dist/types/src/utils/hd-key.d.ts.map +1 -1
- package/dist/types/src/utils/jws.d.ts +1 -2
- package/dist/types/src/utils/jws.d.ts.map +1 -1
- package/dist/types/src/utils/protocols.d.ts +2 -7
- package/dist/types/src/utils/protocols.d.ts.map +1 -1
- package/dist/types/src/utils/records.d.ts +1 -8
- package/dist/types/src/utils/records.d.ts.map +1 -1
- package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -1
- package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts.map +1 -1
- package/dist/types/tests/utils/test-data-generator.d.ts +17 -1
- package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/constants.ts +0 -30
- package/src/core/encryption-control.ts +1 -17
- package/src/core/replication-apply.ts +0 -8
- package/src/index.ts +0 -1
- package/src/interfaces/messages-subscribe.ts +1 -2
- package/src/interfaces/records-write.ts +0 -13
- package/src/store/index-level-compound.ts +2 -5
- package/src/store/level-wrapper.ts +6 -2
- package/src/types/protocols-types.ts +2 -1
- package/src/utils/encryption.ts +2 -15
- package/src/utils/hd-key.ts +1 -32
- package/src/utils/jws.ts +1 -2
- package/src/utils/protocols.ts +15 -78
- package/src/utils/records.ts +15 -57
- package/dist/esm/tests/validation/json-schemas/encryption/delivery.spec.js +0 -47
- package/dist/esm/tests/validation/json-schemas/encryption/delivery.spec.js.map +0 -1
- package/dist/esm/tests/validation/json-schemas/encryption/grant-key.spec.js +0 -72
- package/dist/esm/tests/validation/json-schemas/encryption/grant-key.spec.js.map +0 -1
- package/dist/types/tests/validation/json-schemas/encryption/delivery.spec.d.ts +0 -2
- package/dist/types/tests/validation/json-schemas/encryption/delivery.spec.d.ts.map +0 -1
- package/dist/types/tests/validation/json-schemas/encryption/grant-key.spec.d.ts +0 -2
- package/dist/types/tests/validation/json-schemas/encryption/grant-key.spec.d.ts.map +0 -1
|
@@ -150,7 +150,7 @@ export function testRecordsQueryHandler() {
|
|
|
150
150
|
expect(writeReply.status.code).toBe(202);
|
|
151
151
|
const query = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { dataFormat } });
|
|
152
152
|
const reply = await dwn.processMessage(alice.did, query.message);
|
|
153
|
-
expect(reply.entries
|
|
153
|
+
expect(reply.entries).toHaveLength(1);
|
|
154
154
|
const entry = reply.entries[0];
|
|
155
155
|
expect(entry.authorization).toEqual(write.message.authorization);
|
|
156
156
|
expect(entry.attestation).toEqual(write.message.attestation);
|
|
@@ -180,7 +180,7 @@ export function testRecordsQueryHandler() {
|
|
|
180
180
|
const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { dataFormat } });
|
|
181
181
|
const reply = await dwn.processMessage(alice.did, messageData.message);
|
|
182
182
|
expect(reply.status.code).toBe(200);
|
|
183
|
-
expect(reply.entries
|
|
183
|
+
expect(reply.entries).toHaveLength(2); // only 2 entries should match the query on protocol
|
|
184
184
|
// testing multi-conditional query, reuse data generated above for bob
|
|
185
185
|
const messageData2 = await TestDataGenerator.generateRecordsQuery({
|
|
186
186
|
author: alice,
|
|
@@ -191,7 +191,7 @@ export function testRecordsQueryHandler() {
|
|
|
191
191
|
});
|
|
192
192
|
const reply2 = await dwn.processMessage(alice.did, messageData2.message);
|
|
193
193
|
expect(reply2.status.code).toBe(200);
|
|
194
|
-
expect(reply2.entries
|
|
194
|
+
expect(reply2.entries).toHaveLength(1); // only 1 entry should match the query
|
|
195
195
|
});
|
|
196
196
|
it('should allow exact-tuple audience control queries without broad enumeration', async () => {
|
|
197
197
|
const alice = await TestDataGenerator.generateDidKeyPersona();
|
|
@@ -700,7 +700,7 @@ export function testRecordsQueryHandler() {
|
|
|
700
700
|
const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { recordId: write.message.recordId } });
|
|
701
701
|
const reply = await dwn.processMessage(alice.did, messageData.message);
|
|
702
702
|
expect(reply.status.code).toBe(200);
|
|
703
|
-
expect(reply.entries
|
|
703
|
+
expect(reply.entries).toHaveLength(1);
|
|
704
704
|
expect(reply.entries[0].encodedData).toBe(Encoder.bytesToBase64Url(data));
|
|
705
705
|
});
|
|
706
706
|
it('should not return `encodedData` if data size is greater then spec threshold', async () => {
|
|
@@ -713,7 +713,7 @@ export function testRecordsQueryHandler() {
|
|
|
713
713
|
const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { recordId: write.message.recordId } });
|
|
714
714
|
const reply = await dwn.processMessage(alice.did, messageData.message);
|
|
715
715
|
expect(reply.status.code).toBe(200);
|
|
716
|
-
expect(reply.entries
|
|
716
|
+
expect(reply.entries).toHaveLength(1);
|
|
717
717
|
expect(reply.entries[0].encodedData).toBeUndefined();
|
|
718
718
|
});
|
|
719
719
|
it('should include `initialWrite` property if RecordsWrite is not initial write', async () => {
|
|
@@ -730,7 +730,7 @@ export function testRecordsQueryHandler() {
|
|
|
730
730
|
const messageData = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { recordId: write.message.recordId } });
|
|
731
731
|
const reply = await dwn.processMessage(alice.did, messageData.message);
|
|
732
732
|
expect(reply.status.code).toBe(200);
|
|
733
|
-
expect(reply.entries
|
|
733
|
+
expect(reply.entries).toHaveLength(1);
|
|
734
734
|
expect(reply.entries[0].initialWrite).toBeDefined();
|
|
735
735
|
expect(reply.entries[0].initialWrite?.recordId).toBe(write.message.recordId);
|
|
736
736
|
});
|
|
@@ -749,7 +749,7 @@ export function testRecordsQueryHandler() {
|
|
|
749
749
|
// testing attester filter
|
|
750
750
|
const recordsQuery1 = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { attester: alice.did } });
|
|
751
751
|
const reply1 = await dwn.processMessage(alice.did, recordsQuery1.message);
|
|
752
|
-
expect(reply1.entries
|
|
752
|
+
expect(reply1.entries).toHaveLength(1);
|
|
753
753
|
const reply1Attester = Jws.getSignerDid(reply1.entries[0].attestation.signatures[0]);
|
|
754
754
|
expect(reply1Attester).toBe(alice.did);
|
|
755
755
|
// testing attester + another filter
|
|
@@ -758,14 +758,14 @@ export function testRecordsQueryHandler() {
|
|
|
758
758
|
filter: { attester: bob.did, schema: recordsWrite2.message.descriptor.schema }
|
|
759
759
|
});
|
|
760
760
|
const reply2 = await dwn.processMessage(alice.did, recordsQuery2.message);
|
|
761
|
-
expect(reply2.entries
|
|
761
|
+
expect(reply2.entries).toHaveLength(1);
|
|
762
762
|
const reply2Attester = Jws.getSignerDid(reply2.entries[0].attestation.signatures[0]);
|
|
763
763
|
expect(reply2Attester).toBe(bob.did);
|
|
764
764
|
// testing attester filter that yields no results
|
|
765
765
|
const carol = await TestDataGenerator.generateDidKeyPersona();
|
|
766
766
|
const recordsQuery3 = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { attester: carol.did } });
|
|
767
767
|
const reply3 = await dwn.processMessage(alice.did, recordsQuery3.message);
|
|
768
|
-
expect(reply3.entries
|
|
768
|
+
expect(reply3.entries).toHaveLength(0);
|
|
769
769
|
});
|
|
770
770
|
it('should be able to query by author', async () => {
|
|
771
771
|
// scenario alice and bob both author records into alice's DWN.
|
|
@@ -809,7 +809,7 @@ export function testRecordsQueryHandler() {
|
|
|
809
809
|
});
|
|
810
810
|
let queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
811
811
|
expect(queryReply.status.code).toBe(200);
|
|
812
|
-
expect(queryReply.entries
|
|
812
|
+
expect(queryReply.entries).toHaveLength(2);
|
|
813
813
|
// filter for bob as author
|
|
814
814
|
recordsQuery = await TestDataGenerator.generateRecordsQuery({
|
|
815
815
|
author: alice,
|
|
@@ -823,7 +823,7 @@ export function testRecordsQueryHandler() {
|
|
|
823
823
|
});
|
|
824
824
|
queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
825
825
|
expect(queryReply.status.code).toBe(200);
|
|
826
|
-
expect(queryReply.entries
|
|
826
|
+
expect(queryReply.entries).toHaveLength(1);
|
|
827
827
|
expect(queryReply.entries[0].recordId).toBe(bobAuthorWrite.message.recordId);
|
|
828
828
|
// empty array for author should return all same as undefined author field
|
|
829
829
|
recordsQuery = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -838,7 +838,7 @@ export function testRecordsQueryHandler() {
|
|
|
838
838
|
});
|
|
839
839
|
queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
840
840
|
expect(queryReply.status.code).toBe(200);
|
|
841
|
-
expect(queryReply.entries
|
|
841
|
+
expect(queryReply.entries).toHaveLength(2);
|
|
842
842
|
// query for both authors explicitly
|
|
843
843
|
recordsQuery = await TestDataGenerator.generateRecordsQuery({
|
|
844
844
|
author: alice,
|
|
@@ -852,7 +852,7 @@ export function testRecordsQueryHandler() {
|
|
|
852
852
|
});
|
|
853
853
|
queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
854
854
|
expect(queryReply.status.code).toBe(200);
|
|
855
|
-
expect(queryReply.entries
|
|
855
|
+
expect(queryReply.entries).toHaveLength(2);
|
|
856
856
|
});
|
|
857
857
|
it('should be able to query by recipient', async () => {
|
|
858
858
|
// scenario alice authors records for bob and carol into alice's DWN.
|
|
@@ -899,7 +899,7 @@ export function testRecordsQueryHandler() {
|
|
|
899
899
|
});
|
|
900
900
|
let queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
901
901
|
expect(queryReply.status.code).toBe(200);
|
|
902
|
-
expect(queryReply.entries
|
|
902
|
+
expect(queryReply.entries).toHaveLength(2);
|
|
903
903
|
// filter for bob as recipient
|
|
904
904
|
recordsQuery = await TestDataGenerator.generateRecordsQuery({
|
|
905
905
|
author: alice,
|
|
@@ -913,7 +913,7 @@ export function testRecordsQueryHandler() {
|
|
|
913
913
|
});
|
|
914
914
|
queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
915
915
|
expect(queryReply.status.code).toBe(200);
|
|
916
|
-
expect(queryReply.entries
|
|
916
|
+
expect(queryReply.entries).toHaveLength(1);
|
|
917
917
|
expect(queryReply.entries[0].recordId).toBe(aliceToBob.message.recordId);
|
|
918
918
|
// filter for carol as recipient
|
|
919
919
|
recordsQuery = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -928,7 +928,7 @@ export function testRecordsQueryHandler() {
|
|
|
928
928
|
});
|
|
929
929
|
queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
930
930
|
expect(queryReply.status.code).toBe(200);
|
|
931
|
-
expect(queryReply.entries
|
|
931
|
+
expect(queryReply.entries).toHaveLength(1);
|
|
932
932
|
expect(queryReply.entries[0].recordId).toBe(aliceToCarol.message.recordId);
|
|
933
933
|
// empty array for recipient should return all same as undefined recipient field
|
|
934
934
|
recordsQuery = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -943,7 +943,7 @@ export function testRecordsQueryHandler() {
|
|
|
943
943
|
});
|
|
944
944
|
queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
945
945
|
expect(queryReply.status.code).toBe(200);
|
|
946
|
-
expect(queryReply.entries
|
|
946
|
+
expect(queryReply.entries).toHaveLength(2);
|
|
947
947
|
// query for both recipients explicitly
|
|
948
948
|
recordsQuery = await TestDataGenerator.generateRecordsQuery({
|
|
949
949
|
author: alice,
|
|
@@ -957,7 +957,7 @@ export function testRecordsQueryHandler() {
|
|
|
957
957
|
});
|
|
958
958
|
queryReply = await dwn.processMessage(alice.did, recordsQuery.message);
|
|
959
959
|
expect(queryReply.status.code).toBe(200);
|
|
960
|
-
expect(queryReply.entries
|
|
960
|
+
expect(queryReply.entries).toHaveLength(2);
|
|
961
961
|
});
|
|
962
962
|
it('should be able to query for published records', async () => {
|
|
963
963
|
const alice = await TestDataGenerator.generateDidKeyPersona();
|
|
@@ -975,19 +975,19 @@ export function testRecordsQueryHandler() {
|
|
|
975
975
|
const publishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: true } });
|
|
976
976
|
let publishedPostReply = await dwn.processMessage(alice.did, publishedPostQuery.message);
|
|
977
977
|
expect(publishedPostReply.status.code).toBe(200);
|
|
978
|
-
expect(publishedPostReply.entries
|
|
978
|
+
expect(publishedPostReply.entries).toHaveLength(1);
|
|
979
979
|
expect(publishedPostReply.entries[0].recordId).toBe(publishedWrite.message.recordId);
|
|
980
980
|
// make an query for published records from non owner
|
|
981
981
|
const notOwnerPostQuery = await TestDataGenerator.generateRecordsQuery({ author: bob, filter: { schema: 'post', published: true } });
|
|
982
982
|
let notOwnerPublishedPostReply = await dwn.processMessage(alice.did, notOwnerPostQuery.message);
|
|
983
983
|
expect(notOwnerPublishedPostReply.status.code).toBe(200);
|
|
984
|
-
expect(notOwnerPublishedPostReply.entries
|
|
984
|
+
expect(notOwnerPublishedPostReply.entries).toHaveLength(1);
|
|
985
985
|
expect(notOwnerPublishedPostReply.entries[0].recordId).toBe(publishedWrite.message.recordId);
|
|
986
986
|
// anonymous query for published records
|
|
987
987
|
const anonymousPostQuery = await RecordsQuery.create({ filter: { schema: 'post', published: true } });
|
|
988
988
|
let anonymousPublishedPostReply = await dwn.processMessage(alice.did, anonymousPostQuery.message);
|
|
989
989
|
expect(anonymousPublishedPostReply.status.code).toBe(200);
|
|
990
|
-
expect(anonymousPublishedPostReply.entries
|
|
990
|
+
expect(anonymousPublishedPostReply.entries).toHaveLength(1);
|
|
991
991
|
expect(anonymousPublishedPostReply.entries[0].recordId).toBe(publishedWrite.message.recordId);
|
|
992
992
|
// publish the unpublished record
|
|
993
993
|
const publishedDraftWrite = await RecordsWrite.createFrom({
|
|
@@ -1000,20 +1000,20 @@ export function testRecordsQueryHandler() {
|
|
|
1000
1000
|
// issue the same query for published records
|
|
1001
1001
|
publishedPostReply = await dwn.processMessage(alice.did, publishedPostQuery.message);
|
|
1002
1002
|
expect(publishedPostReply.status.code).toBe(200);
|
|
1003
|
-
expect(publishedPostReply.entries
|
|
1003
|
+
expect(publishedPostReply.entries).toHaveLength(2);
|
|
1004
1004
|
const returnedRecordIds = publishedPostReply.entries?.map(e => e.recordId);
|
|
1005
1005
|
// ensure that both records now exist in results
|
|
1006
1006
|
expect(returnedRecordIds).toEqual(expect.arrayContaining([publishedWrite.message.recordId, draftWrite.message.recordId]));
|
|
1007
1007
|
// query after publishing from non owner
|
|
1008
1008
|
notOwnerPublishedPostReply = await dwn.processMessage(alice.did, anonymousPostQuery.message);
|
|
1009
1009
|
expect(notOwnerPublishedPostReply.status.code).toBe(200);
|
|
1010
|
-
expect(notOwnerPublishedPostReply.entries
|
|
1010
|
+
expect(notOwnerPublishedPostReply.entries).toHaveLength(2);
|
|
1011
1011
|
const nonOwnerReturnedRecordIds = notOwnerPublishedPostReply.entries?.map(e => e.recordId);
|
|
1012
1012
|
expect(nonOwnerReturnedRecordIds).toEqual(expect.arrayContaining([publishedWrite.message.recordId, draftWrite.message.recordId]));
|
|
1013
1013
|
// anonymous query after publishing
|
|
1014
1014
|
anonymousPublishedPostReply = await dwn.processMessage(alice.did, anonymousPostQuery.message);
|
|
1015
1015
|
expect(anonymousPublishedPostReply.status.code).toBe(200);
|
|
1016
|
-
expect(anonymousPublishedPostReply.entries
|
|
1016
|
+
expect(anonymousPublishedPostReply.entries).toHaveLength(2);
|
|
1017
1017
|
const anonymousReturnedRecordIds = anonymousPublishedPostReply.entries?.map(e => e.recordId);
|
|
1018
1018
|
expect(anonymousReturnedRecordIds).toEqual(expect.arrayContaining([publishedWrite.message.recordId, draftWrite.message.recordId]));
|
|
1019
1019
|
});
|
|
@@ -1032,7 +1032,7 @@ export function testRecordsQueryHandler() {
|
|
|
1032
1032
|
const unpublishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: false } });
|
|
1033
1033
|
let unpublishedPostReply = await dwn.processMessage(alice.did, unpublishedPostQuery.message);
|
|
1034
1034
|
expect(unpublishedPostReply.status.code).toBe(200);
|
|
1035
|
-
expect(unpublishedPostReply.entries
|
|
1035
|
+
expect(unpublishedPostReply.entries).toHaveLength(1);
|
|
1036
1036
|
expect(unpublishedPostReply.entries[0].recordId).toBe(draftWrite.message.recordId);
|
|
1037
1037
|
// publish the unpublished record
|
|
1038
1038
|
const publishedDraftWrite = await RecordsWrite.createFrom({
|
|
@@ -1045,7 +1045,7 @@ export function testRecordsQueryHandler() {
|
|
|
1045
1045
|
// issue the same query for unpublished records
|
|
1046
1046
|
unpublishedPostReply = await dwn.processMessage(alice.did, unpublishedPostQuery.message);
|
|
1047
1047
|
expect(unpublishedPostReply.status.code).toBe(200);
|
|
1048
|
-
expect(unpublishedPostReply.entries
|
|
1048
|
+
expect(unpublishedPostReply.entries).toHaveLength(0);
|
|
1049
1049
|
});
|
|
1050
1050
|
it('should not be able to query for unpublished records if unauthorized', async () => {
|
|
1051
1051
|
const alice = await TestDataGenerator.generateDidKeyPersona();
|
|
@@ -1063,7 +1063,7 @@ export function testRecordsQueryHandler() {
|
|
|
1063
1063
|
const unpublishedNotOwner = await TestDataGenerator.generateRecordsQuery({ author: bob, filter: { schema: 'post', published: false } });
|
|
1064
1064
|
let notOwnerPostReply = await dwn.processMessage(alice.did, unpublishedNotOwner.message);
|
|
1065
1065
|
expect(notOwnerPostReply.status.code).toBe(200);
|
|
1066
|
-
expect(notOwnerPostReply.entries
|
|
1066
|
+
expect(notOwnerPostReply.entries).toHaveLength(0);
|
|
1067
1067
|
// publish the unpublished record
|
|
1068
1068
|
const publishedDraftWrite = await RecordsWrite.createFrom({
|
|
1069
1069
|
recordsWriteMessage: draftWrite.message,
|
|
@@ -1076,16 +1076,16 @@ export function testRecordsQueryHandler() {
|
|
|
1076
1076
|
let publishedNotOwner = await TestDataGenerator.generateRecordsQuery({ author: bob, filter: { schema: 'post' } });
|
|
1077
1077
|
let publishedNotOwnerReply = await dwn.processMessage(alice.did, publishedNotOwner.message);
|
|
1078
1078
|
expect(publishedNotOwnerReply.status.code).toBe(200);
|
|
1079
|
-
expect(publishedNotOwnerReply.entries
|
|
1079
|
+
expect(publishedNotOwnerReply.entries).toHaveLength(2);
|
|
1080
1080
|
// with explicit published true
|
|
1081
1081
|
publishedNotOwner = await TestDataGenerator.generateRecordsQuery({ author: bob, filter: { schema: 'post', published: true } });
|
|
1082
1082
|
publishedNotOwnerReply = await dwn.processMessage(alice.did, publishedNotOwner.message);
|
|
1083
1083
|
expect(publishedNotOwnerReply.status.code).toBe(200);
|
|
1084
|
-
expect(publishedNotOwnerReply.entries
|
|
1084
|
+
expect(publishedNotOwnerReply.entries).toHaveLength(2);
|
|
1085
1085
|
// with explicit published false after publishing should still return nothing
|
|
1086
1086
|
notOwnerPostReply = await dwn.processMessage(alice.did, unpublishedNotOwner.message);
|
|
1087
1087
|
expect(notOwnerPostReply.status.code).toBe(200);
|
|
1088
|
-
expect(notOwnerPostReply.entries
|
|
1088
|
+
expect(notOwnerPostReply.entries).toHaveLength(0);
|
|
1089
1089
|
});
|
|
1090
1090
|
it('should query unpublished records authorized by permissionGrantId', async () => {
|
|
1091
1091
|
const alice = await TestDataGenerator.generatePersona();
|
|
@@ -1169,7 +1169,7 @@ export function testRecordsQueryHandler() {
|
|
|
1169
1169
|
const dataCidQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { dataCid: recordDataCid } });
|
|
1170
1170
|
const dataCidQueryReply = await dwn.processMessage(alice.did, dataCidQuery.message);
|
|
1171
1171
|
expect(dataCidQueryReply.status.code).toBe(200);
|
|
1172
|
-
expect(dataCidQueryReply.entries
|
|
1172
|
+
expect(dataCidQueryReply.entries).toHaveLength(1);
|
|
1173
1173
|
expect(dataCidQueryReply.entries[0].recordId).toBe(writeRecord.message.recordId);
|
|
1174
1174
|
});
|
|
1175
1175
|
it('should be able to query with `dataSize` filter (half-open range)', async () => {
|
|
@@ -1191,7 +1191,7 @@ export function testRecordsQueryHandler() {
|
|
|
1191
1191
|
filter: { dataSize: { gt: 10 } },
|
|
1192
1192
|
});
|
|
1193
1193
|
const reply1 = await dwn.processMessage(alice.did, recordsQuery1.message);
|
|
1194
|
-
expect(reply1.entries
|
|
1194
|
+
expect(reply1.entries).toHaveLength(2);
|
|
1195
1195
|
expect(reply1.entries?.map((entry) => entry.encodedData)).toEqual(expect.arrayContaining([
|
|
1196
1196
|
Encoder.bytesToBase64Url(write2.dataBytes),
|
|
1197
1197
|
Encoder.bytesToBase64Url(write3.dataBytes)
|
|
@@ -1202,7 +1202,7 @@ export function testRecordsQueryHandler() {
|
|
|
1202
1202
|
filter: { dataSize: { lt: 100 } },
|
|
1203
1203
|
});
|
|
1204
1204
|
const reply2 = await dwn.processMessage(alice.did, recordsQuery2.message);
|
|
1205
|
-
expect(reply2.entries
|
|
1205
|
+
expect(reply2.entries).toHaveLength(2);
|
|
1206
1206
|
expect(reply2.entries?.map((entry) => entry.encodedData)).toEqual(expect.arrayContaining([
|
|
1207
1207
|
Encoder.bytesToBase64Url(write1.dataBytes),
|
|
1208
1208
|
Encoder.bytesToBase64Url(write2.dataBytes)
|
|
@@ -1213,7 +1213,7 @@ export function testRecordsQueryHandler() {
|
|
|
1213
1213
|
filter: { dataSize: { gte: 10 } },
|
|
1214
1214
|
});
|
|
1215
1215
|
const reply3 = await dwn.processMessage(alice.did, recordsQuery3.message);
|
|
1216
|
-
expect(reply3.entries
|
|
1216
|
+
expect(reply3.entries).toHaveLength(3);
|
|
1217
1217
|
expect(reply3.entries?.map((entry) => entry.encodedData)).toEqual(expect.arrayContaining([
|
|
1218
1218
|
Encoder.bytesToBase64Url(write1.dataBytes),
|
|
1219
1219
|
Encoder.bytesToBase64Url(write2.dataBytes),
|
|
@@ -1225,7 +1225,7 @@ export function testRecordsQueryHandler() {
|
|
|
1225
1225
|
filter: { dataSize: { lte: 100 } },
|
|
1226
1226
|
});
|
|
1227
1227
|
const reply4 = await dwn.processMessage(alice.did, recordsQuery4.message);
|
|
1228
|
-
expect(reply4.entries
|
|
1228
|
+
expect(reply4.entries).toHaveLength(3);
|
|
1229
1229
|
expect(reply4.entries?.map((entry) => entry.encodedData)).toEqual(expect.arrayContaining([
|
|
1230
1230
|
Encoder.bytesToBase64Url(write1.dataBytes),
|
|
1231
1231
|
Encoder.bytesToBase64Url(write2.dataBytes),
|
|
@@ -1251,7 +1251,7 @@ export function testRecordsQueryHandler() {
|
|
|
1251
1251
|
filter: { dataSize: { gt: 10, lt: 60 } },
|
|
1252
1252
|
});
|
|
1253
1253
|
const reply1 = await dwn.processMessage(alice.did, recordsQuery1.message);
|
|
1254
|
-
expect(reply1.entries
|
|
1254
|
+
expect(reply1.entries).toHaveLength(1);
|
|
1255
1255
|
expect(reply1.entries[0].recordId).toBe(write2.message.recordId);
|
|
1256
1256
|
// testing range using gte & lt
|
|
1257
1257
|
const recordsQuery2 = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -1259,7 +1259,7 @@ export function testRecordsQueryHandler() {
|
|
|
1259
1259
|
filter: { dataSize: { gte: 10, lt: 60 } },
|
|
1260
1260
|
});
|
|
1261
1261
|
const reply2 = await dwn.processMessage(alice.did, recordsQuery2.message);
|
|
1262
|
-
expect(reply2.entries
|
|
1262
|
+
expect(reply2.entries).toHaveLength(2);
|
|
1263
1263
|
const reply2RecordIds = reply2.entries?.map(e => e.recordId);
|
|
1264
1264
|
expect(reply2RecordIds).toEqual(expect.arrayContaining([write1.message.recordId, write2.message.recordId]));
|
|
1265
1265
|
// testing range using gt & lte
|
|
@@ -1268,7 +1268,7 @@ export function testRecordsQueryHandler() {
|
|
|
1268
1268
|
filter: { dataSize: { gt: 50, lte: 100 } },
|
|
1269
1269
|
});
|
|
1270
1270
|
const reply3 = await dwn.processMessage(alice.did, recordsQuery3.message);
|
|
1271
|
-
expect(reply3.entries
|
|
1271
|
+
expect(reply3.entries).toHaveLength(1);
|
|
1272
1272
|
expect(reply3.entries[0].recordId).toBe(write3.message.recordId);
|
|
1273
1273
|
// testing range using gte & lte
|
|
1274
1274
|
const recordsQuery4 = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -1276,7 +1276,7 @@ export function testRecordsQueryHandler() {
|
|
|
1276
1276
|
filter: { dataSize: { gte: 10, lte: 100 } },
|
|
1277
1277
|
});
|
|
1278
1278
|
const reply4 = await dwn.processMessage(alice.did, recordsQuery4.message);
|
|
1279
|
-
expect(reply4.entries
|
|
1279
|
+
expect(reply4.entries).toHaveLength(3);
|
|
1280
1280
|
const reply4RecordIds = reply4.entries?.map(e => e.recordId);
|
|
1281
1281
|
expect(reply4RecordIds).toEqual(expect.arrayContaining([write1.message.recordId, write2.message.recordId, write3.message.recordId]));
|
|
1282
1282
|
});
|
|
@@ -1306,7 +1306,7 @@ export function testRecordsQueryHandler() {
|
|
|
1306
1306
|
dateSort: DateSort.CreatedAscending
|
|
1307
1307
|
});
|
|
1308
1308
|
const reply1 = await dwn.processMessage(alice.did, recordsQuery1.message);
|
|
1309
|
-
expect(reply1.entries
|
|
1309
|
+
expect(reply1.entries).toHaveLength(2);
|
|
1310
1310
|
expect(reply1.entries[0].encodedData).toBe(Encoder.bytesToBase64Url(write2.dataBytes));
|
|
1311
1311
|
expect(reply1.entries[1].encodedData).toBe(Encoder.bytesToBase64Url(write3.dataBytes));
|
|
1312
1312
|
// testing `to` range
|
|
@@ -1317,7 +1317,7 @@ export function testRecordsQueryHandler() {
|
|
|
1317
1317
|
dateSort: DateSort.CreatedAscending
|
|
1318
1318
|
});
|
|
1319
1319
|
const reply2 = await dwn.processMessage(alice.did, recordsQuery2.message);
|
|
1320
|
-
expect(reply2.entries
|
|
1320
|
+
expect(reply2.entries).toHaveLength(2);
|
|
1321
1321
|
expect(reply2.entries[0].encodedData).toBe(Encoder.bytesToBase64Url(write1.dataBytes));
|
|
1322
1322
|
expect(reply2.entries[1].encodedData).toBe(Encoder.bytesToBase64Url(write2.dataBytes));
|
|
1323
1323
|
// testing `from` and `to` range
|
|
@@ -1328,7 +1328,7 @@ export function testRecordsQueryHandler() {
|
|
|
1328
1328
|
dateSort: DateSort.CreatedAscending
|
|
1329
1329
|
});
|
|
1330
1330
|
const reply3 = await dwn.processMessage(alice.did, recordsQuery3.message);
|
|
1331
|
-
expect(reply3.entries
|
|
1331
|
+
expect(reply3.entries).toHaveLength(1);
|
|
1332
1332
|
expect(reply3.entries[0].encodedData).toBe(Encoder.bytesToBase64Url(write3.dataBytes));
|
|
1333
1333
|
// testing edge case where value equals `from` and `to`
|
|
1334
1334
|
const recordsQuery4 = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -1337,7 +1337,7 @@ export function testRecordsQueryHandler() {
|
|
|
1337
1337
|
dateSort: DateSort.CreatedAscending
|
|
1338
1338
|
});
|
|
1339
1339
|
const reply4 = await dwn.processMessage(alice.did, recordsQuery4.message);
|
|
1340
|
-
expect(reply4.entries
|
|
1340
|
+
expect(reply4.entries).toHaveLength(1);
|
|
1341
1341
|
expect(reply4.entries[0].encodedData).toBe(Encoder.bytesToBase64Url(write2.dataBytes));
|
|
1342
1342
|
});
|
|
1343
1343
|
it('should not return records that were published and then unpublished ', async () => {
|
|
@@ -1380,7 +1380,7 @@ export function testRecordsQueryHandler() {
|
|
|
1380
1380
|
dateSort: DateSort.CreatedAscending
|
|
1381
1381
|
});
|
|
1382
1382
|
const reply1 = await dwn.processMessage(alice.did, ownerRangeQuery.message);
|
|
1383
|
-
expect(reply1.entries
|
|
1383
|
+
expect(reply1.entries).toHaveLength(2);
|
|
1384
1384
|
const reply1RecordIds = reply1.entries?.map(e => e.recordId);
|
|
1385
1385
|
expect(reply1RecordIds).toEqual(expect.arrayContaining([write2.message.recordId, write3.message.recordId]));
|
|
1386
1386
|
// confirm published true filter before un-publishing
|
|
@@ -1391,7 +1391,7 @@ export function testRecordsQueryHandler() {
|
|
|
1391
1391
|
});
|
|
1392
1392
|
let ownerPublishedReply = await dwn.processMessage(alice.did, ownerPublishedQuery.message);
|
|
1393
1393
|
expect(ownerPublishedReply.status.code).toBe(200);
|
|
1394
|
-
expect(ownerPublishedReply.entries
|
|
1394
|
+
expect(ownerPublishedReply.entries).toHaveLength(3);
|
|
1395
1395
|
const ownerPublishedIds = ownerPublishedReply.entries?.map(e => e.recordId);
|
|
1396
1396
|
expect(ownerPublishedIds).toEqual(expect.arrayContaining([write1.message.recordId, write2.message.recordId, write3.message.recordId]));
|
|
1397
1397
|
// confirm for anonymous query before un-publishing
|
|
@@ -1401,7 +1401,7 @@ export function testRecordsQueryHandler() {
|
|
|
1401
1401
|
});
|
|
1402
1402
|
let anonymousRangeReply = await dwn.processMessage(alice.did, anonymousRangeQuery.message);
|
|
1403
1403
|
expect(anonymousRangeReply.status.code).toBe(200);
|
|
1404
|
-
expect(anonymousRangeReply.entries
|
|
1404
|
+
expect(anonymousRangeReply.entries).toHaveLength(2);
|
|
1405
1405
|
const anonymousReplyIds = anonymousRangeReply.entries?.map(e => e.recordId);
|
|
1406
1406
|
expect(anonymousReplyIds).toEqual(expect.arrayContaining([write2.message.recordId, write3.message.recordId]));
|
|
1407
1407
|
// confirm anonymous published true filter before un-publishing
|
|
@@ -1411,7 +1411,7 @@ export function testRecordsQueryHandler() {
|
|
|
1411
1411
|
});
|
|
1412
1412
|
let anonymousPublishedReply = await dwn.processMessage(alice.did, anonymousPublishedQuery.message);
|
|
1413
1413
|
expect(anonymousPublishedReply.status.code).toBe(200);
|
|
1414
|
-
expect(anonymousPublishedReply.entries
|
|
1414
|
+
expect(anonymousPublishedReply.entries).toHaveLength(3);
|
|
1415
1415
|
const anonymousPublishedIds = anonymousPublishedReply.entries?.map(e => e.recordId);
|
|
1416
1416
|
expect(anonymousPublishedIds).toEqual(expect.arrayContaining([write1.message.recordId, write2.message.recordId, write3.message.recordId]));
|
|
1417
1417
|
//unpublish records
|
|
@@ -1439,19 +1439,19 @@ export function testRecordsQueryHandler() {
|
|
|
1439
1439
|
// try datePublished range query as an anonymous user after unpublish
|
|
1440
1440
|
anonymousRangeReply = await dwn.processMessage(alice.did, anonymousRangeQuery.message);
|
|
1441
1441
|
expect(anonymousRangeReply.status.code).toBe(200);
|
|
1442
|
-
expect(anonymousRangeReply.entries
|
|
1442
|
+
expect(anonymousRangeReply.entries).toHaveLength(0);
|
|
1443
1443
|
// try published:true filter as an anonymous user after unpublish
|
|
1444
1444
|
anonymousPublishedReply = await dwn.processMessage(alice.did, anonymousPublishedQuery.message);
|
|
1445
1445
|
expect(anonymousPublishedReply.status.code).toBe(200);
|
|
1446
|
-
expect(anonymousPublishedReply.entries
|
|
1446
|
+
expect(anonymousPublishedReply.entries).toHaveLength(0);
|
|
1447
1447
|
// try datePublished range query as owner after unpublish
|
|
1448
1448
|
const ownerRangeReply = await dwn.processMessage(alice.did, ownerRangeQuery.message);
|
|
1449
1449
|
expect(ownerRangeReply.status.code).toBe(200);
|
|
1450
|
-
expect(ownerRangeReply.entries
|
|
1450
|
+
expect(ownerRangeReply.entries).toHaveLength(0);
|
|
1451
1451
|
// try published:true filter as owner after unpublish
|
|
1452
1452
|
ownerPublishedReply = await dwn.processMessage(alice.did, ownerPublishedQuery.message);
|
|
1453
1453
|
expect(ownerPublishedReply.status.code).toBe(200);
|
|
1454
|
-
expect(ownerPublishedReply.entries
|
|
1454
|
+
expect(ownerPublishedReply.entries).toHaveLength(0);
|
|
1455
1455
|
});
|
|
1456
1456
|
it('should be able to range query by `datePublished`', async () => {
|
|
1457
1457
|
// scenario: 3 records authored by alice, published on first of 2021, 2022, and 2023 respectively
|
|
@@ -1486,7 +1486,7 @@ export function testRecordsQueryHandler() {
|
|
|
1486
1486
|
dateSort: DateSort.CreatedAscending
|
|
1487
1487
|
});
|
|
1488
1488
|
const reply1 = await dwn.processMessage(alice.did, recordsQuery1.message);
|
|
1489
|
-
expect(reply1.entries
|
|
1489
|
+
expect(reply1.entries).toHaveLength(2);
|
|
1490
1490
|
const reply1RecordIds = reply1.entries?.map(e => e.recordId);
|
|
1491
1491
|
expect(reply1RecordIds).toEqual(expect.arrayContaining([write2.message.recordId, write3.message.recordId]));
|
|
1492
1492
|
// testing `to` range
|
|
@@ -1497,7 +1497,7 @@ export function testRecordsQueryHandler() {
|
|
|
1497
1497
|
dateSort: DateSort.CreatedAscending
|
|
1498
1498
|
});
|
|
1499
1499
|
const reply2 = await dwn.processMessage(alice.did, recordsQuery2.message);
|
|
1500
|
-
expect(reply2.entries
|
|
1500
|
+
expect(reply2.entries).toHaveLength(2);
|
|
1501
1501
|
const reply2RecordIds = reply2.entries?.map(e => e.recordId);
|
|
1502
1502
|
expect(reply2RecordIds).toEqual(expect.arrayContaining([write1.message.recordId, write2.message.recordId]));
|
|
1503
1503
|
// testing `from` and `to` range
|
|
@@ -1508,7 +1508,7 @@ export function testRecordsQueryHandler() {
|
|
|
1508
1508
|
dateSort: DateSort.CreatedAscending
|
|
1509
1509
|
});
|
|
1510
1510
|
const reply3 = await dwn.processMessage(alice.did, recordsQuery3.message);
|
|
1511
|
-
expect(reply3.entries
|
|
1511
|
+
expect(reply3.entries).toHaveLength(1);
|
|
1512
1512
|
expect(reply3.entries[0].recordId).toBe(write3.message.recordId);
|
|
1513
1513
|
// testing edge case where value equals `from` and `to`
|
|
1514
1514
|
const recordsQuery4 = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -1517,7 +1517,7 @@ export function testRecordsQueryHandler() {
|
|
|
1517
1517
|
dateSort: DateSort.CreatedAscending
|
|
1518
1518
|
});
|
|
1519
1519
|
const reply4 = await dwn.processMessage(alice.did, recordsQuery4.message);
|
|
1520
|
-
expect(reply4.entries
|
|
1520
|
+
expect(reply4.entries).toHaveLength(1);
|
|
1521
1521
|
expect(reply4.entries[0].recordId).toBe(write2.message.recordId);
|
|
1522
1522
|
// check for anonymous range query
|
|
1523
1523
|
const anonymousRecordQuery = await RecordsQuery.create({
|
|
@@ -1526,7 +1526,7 @@ export function testRecordsQueryHandler() {
|
|
|
1526
1526
|
});
|
|
1527
1527
|
const anonymousReply = await dwn.processMessage(alice.did, anonymousRecordQuery.message);
|
|
1528
1528
|
expect(anonymousReply.status.code).toBe(200);
|
|
1529
|
-
expect(anonymousReply.entries
|
|
1529
|
+
expect(anonymousReply.entries).toHaveLength(2);
|
|
1530
1530
|
const anonymousReplyIds = anonymousReply.entries?.map(e => e.recordId);
|
|
1531
1531
|
expect(anonymousReplyIds).toEqual(expect.arrayContaining([write2.message.recordId, write3.message.recordId]));
|
|
1532
1532
|
// check for non owner range query
|
|
@@ -1538,7 +1538,7 @@ export function testRecordsQueryHandler() {
|
|
|
1538
1538
|
});
|
|
1539
1539
|
const nonOwnerReply = await dwn.processMessage(alice.did, nonOwnerRange.message);
|
|
1540
1540
|
expect(nonOwnerReply.status.code).toBe(200);
|
|
1541
|
-
expect(nonOwnerReply.entries
|
|
1541
|
+
expect(nonOwnerReply.entries).toHaveLength(2);
|
|
1542
1542
|
const nonOwnerReplyIds = nonOwnerReply.entries?.map(e => e.recordId);
|
|
1543
1543
|
expect(nonOwnerReplyIds).toEqual(expect.arrayContaining([write2.message.recordId, write3.message.recordId]));
|
|
1544
1544
|
});
|
|
@@ -1611,7 +1611,7 @@ export function testRecordsQueryHandler() {
|
|
|
1611
1611
|
dateSort: DateSort.CreatedAscending
|
|
1612
1612
|
});
|
|
1613
1613
|
const reply1 = await dwn.processMessage(alice.did, recordsQuery1.message);
|
|
1614
|
-
expect(reply1.entries
|
|
1614
|
+
expect(reply1.entries).toHaveLength(2);
|
|
1615
1615
|
const reply1RecordIds = reply1.entries?.map(e => e.recordId);
|
|
1616
1616
|
expect(reply1RecordIds).toEqual(expect.arrayContaining([write2.message.recordId, write3.message.recordId]));
|
|
1617
1617
|
// testing `to` range
|
|
@@ -1622,7 +1622,7 @@ export function testRecordsQueryHandler() {
|
|
|
1622
1622
|
dateSort: DateSort.CreatedAscending
|
|
1623
1623
|
});
|
|
1624
1624
|
const reply2 = await dwn.processMessage(alice.did, recordsQuery2.message);
|
|
1625
|
-
expect(reply2.entries
|
|
1625
|
+
expect(reply2.entries).toHaveLength(2);
|
|
1626
1626
|
const reply2RecordIds = reply2.entries?.map(e => e.recordId);
|
|
1627
1627
|
expect(reply2RecordIds).toEqual(expect.arrayContaining([write1.message.recordId, write2.message.recordId]));
|
|
1628
1628
|
// testing `from` and `to` range
|
|
@@ -1633,7 +1633,7 @@ export function testRecordsQueryHandler() {
|
|
|
1633
1633
|
dateSort: DateSort.CreatedAscending
|
|
1634
1634
|
});
|
|
1635
1635
|
const reply3 = await dwn.processMessage(alice.did, recordsQuery3.message);
|
|
1636
|
-
expect(reply3.entries
|
|
1636
|
+
expect(reply3.entries).toHaveLength(1);
|
|
1637
1637
|
expect(reply3.entries[0].recordId).toBe(write3.message.recordId);
|
|
1638
1638
|
// testing edge case where value equals `from` and `to`
|
|
1639
1639
|
const recordsQuery4 = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -1642,7 +1642,7 @@ export function testRecordsQueryHandler() {
|
|
|
1642
1642
|
dateSort: DateSort.CreatedAscending
|
|
1643
1643
|
});
|
|
1644
1644
|
const reply4 = await dwn.processMessage(alice.did, recordsQuery4.message);
|
|
1645
|
-
expect(reply4.entries
|
|
1645
|
+
expect(reply4.entries).toHaveLength(1);
|
|
1646
1646
|
expect(reply4.entries[0].recordId).toBe(write2.message.recordId);
|
|
1647
1647
|
});
|
|
1648
1648
|
it('should be able use range and exact match queries at the same time', async () => {
|
|
@@ -1682,7 +1682,7 @@ export function testRecordsQueryHandler() {
|
|
|
1682
1682
|
dateSort: DateSort.CreatedAscending
|
|
1683
1683
|
});
|
|
1684
1684
|
const reply = await dwn.processMessage(alice.did, recordsQuery5.message);
|
|
1685
|
-
expect(reply.entries
|
|
1685
|
+
expect(reply.entries).toHaveLength(1);
|
|
1686
1686
|
expect(reply.entries[0].encodedData).toBe(Encoder.bytesToBase64Url(write2.dataBytes));
|
|
1687
1687
|
});
|
|
1688
1688
|
it('should include `authorization` in returned records', async () => {
|
|
@@ -1700,7 +1700,7 @@ export function testRecordsQueryHandler() {
|
|
|
1700
1700
|
});
|
|
1701
1701
|
const queryReply = await dwn.processMessage(alice.did, queryData.message);
|
|
1702
1702
|
expect(queryReply.status.code).toBe(200);
|
|
1703
|
-
expect(queryReply.entries
|
|
1703
|
+
expect(queryReply.entries).toHaveLength(1);
|
|
1704
1704
|
expect(queryReply.entries[0].authorization).toEqual(message.authorization);
|
|
1705
1705
|
});
|
|
1706
1706
|
it('should include `attestation` in returned records', async () => {
|
|
@@ -1716,9 +1716,9 @@ export function testRecordsQueryHandler() {
|
|
|
1716
1716
|
});
|
|
1717
1717
|
const queryReply = await dwn.processMessage(alice.did, queryData.message);
|
|
1718
1718
|
expect(queryReply.status.code).toBe(200);
|
|
1719
|
-
expect(queryReply.entries
|
|
1719
|
+
expect(queryReply.entries).toHaveLength(1);
|
|
1720
1720
|
const recordsWriteMessage = queryReply.entries[0];
|
|
1721
|
-
expect(recordsWriteMessage.attestation?.signatures
|
|
1721
|
+
expect(recordsWriteMessage.attestation?.signatures).toHaveLength(1);
|
|
1722
1722
|
});
|
|
1723
1723
|
it('should omit records that are not published if `dateSort` sorts on `datePublished`', async () => {
|
|
1724
1724
|
// setup: 2 records in DWN: 1 published and 1 unpublished
|
|
@@ -1747,7 +1747,7 @@ export function testRecordsQueryHandler() {
|
|
|
1747
1747
|
filter: { schema }
|
|
1748
1748
|
});
|
|
1749
1749
|
const publishedAscendingQueryReply = await dwn.processMessage(alice.did, publishedAscendingQueryData.message);
|
|
1750
|
-
expect(publishedAscendingQueryReply.entries
|
|
1750
|
+
expect(publishedAscendingQueryReply.entries).toHaveLength(1);
|
|
1751
1751
|
expect(publishedAscendingQueryReply.entries[0].recordId).toBe(publishedWriteData.message.recordId);
|
|
1752
1752
|
// test published date scending sort does not include any records that are not published
|
|
1753
1753
|
const publishedDescendingQueryData = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -1756,7 +1756,7 @@ export function testRecordsQueryHandler() {
|
|
|
1756
1756
|
filter: { schema }
|
|
1757
1757
|
});
|
|
1758
1758
|
const publishedDescendingQueryReply = await dwn.processMessage(alice.did, publishedDescendingQueryData.message);
|
|
1759
|
-
expect(publishedDescendingQueryReply.entries
|
|
1759
|
+
expect(publishedDescendingQueryReply.entries).toHaveLength(1);
|
|
1760
1760
|
expect(publishedDescendingQueryReply.entries[0].recordId).toBe(publishedWriteData.message.recordId);
|
|
1761
1761
|
});
|
|
1762
1762
|
it('should sort records if `dateSort` is specified with and without a cursor', async () => {
|
|
@@ -1788,7 +1788,7 @@ export function testRecordsQueryHandler() {
|
|
|
1788
1788
|
filter: { schema }
|
|
1789
1789
|
});
|
|
1790
1790
|
let createdAscendingQueryReply = await dwn.processMessage(alice.did, createdAscendingQueryData.message);
|
|
1791
|
-
expect(createdAscendingQueryReply.entries
|
|
1791
|
+
expect(createdAscendingQueryReply.entries).toHaveLength(3);
|
|
1792
1792
|
expect(createdAscendingQueryReply.entries?.[0].recordId).toBe(write1Data.message.recordId);
|
|
1793
1793
|
expect(createdAscendingQueryReply.entries?.[1].recordId).toBe(write2Data.message.recordId);
|
|
1794
1794
|
expect(createdAscendingQueryReply.entries?.[2].recordId).toBe(write3Data.message.recordId);
|
|
@@ -1800,7 +1800,7 @@ export function testRecordsQueryHandler() {
|
|
|
1800
1800
|
pagination: { limit: 1 }
|
|
1801
1801
|
});
|
|
1802
1802
|
createdAscendingQueryReply = await dwn.processMessage(alice.did, createdAscendingQueryData.message);
|
|
1803
|
-
expect(createdAscendingQueryReply.entries
|
|
1803
|
+
expect(createdAscendingQueryReply.entries).toHaveLength(1);
|
|
1804
1804
|
// we then use the single record query's cursor to get the rest of the records
|
|
1805
1805
|
createdAscendingQueryData = await TestDataGenerator.generateRecordsQuery({
|
|
1806
1806
|
author: alice,
|
|
@@ -1809,7 +1809,7 @@ export function testRecordsQueryHandler() {
|
|
|
1809
1809
|
pagination: { cursor: createdAscendingQueryReply.cursor }
|
|
1810
1810
|
});
|
|
1811
1811
|
createdAscendingQueryReply = await dwn.processMessage(alice.did, createdAscendingQueryData.message);
|
|
1812
|
-
expect(createdAscendingQueryReply.entries
|
|
1812
|
+
expect(createdAscendingQueryReply.entries).toHaveLength(2);
|
|
1813
1813
|
expect(createdAscendingQueryReply.entries[0].recordId).toBe(write2Data.message.recordId);
|
|
1814
1814
|
expect(createdAscendingQueryReply.entries[1].recordId).toBe(write3Data.message.recordId);
|
|
1815
1815
|
// createdDescending test
|
|
@@ -1819,7 +1819,7 @@ export function testRecordsQueryHandler() {
|
|
|
1819
1819
|
filter: { schema }
|
|
1820
1820
|
});
|
|
1821
1821
|
let createdDescendingQueryReply = await dwn.processMessage(alice.did, createdDescendingQueryData.message);
|
|
1822
|
-
expect(createdDescendingQueryReply.entries
|
|
1822
|
+
expect(createdDescendingQueryReply.entries).toHaveLength(3);
|
|
1823
1823
|
expect(createdDescendingQueryReply.entries?.[0].recordId).toBe(write3Data.message.recordId);
|
|
1824
1824
|
expect(createdDescendingQueryReply.entries?.[1].recordId).toBe(write2Data.message.recordId);
|
|
1825
1825
|
expect(createdDescendingQueryReply.entries?.[2].recordId).toBe(write1Data.message.recordId);
|
|
@@ -1831,7 +1831,7 @@ export function testRecordsQueryHandler() {
|
|
|
1831
1831
|
pagination: { limit: 1 }
|
|
1832
1832
|
});
|
|
1833
1833
|
createdDescendingQueryReply = await dwn.processMessage(alice.did, createdDescendingQueryData.message);
|
|
1834
|
-
expect(createdDescendingQueryReply.entries
|
|
1834
|
+
expect(createdDescendingQueryReply.entries).toHaveLength(1);
|
|
1835
1835
|
// we then use the single record query's cursor to get the rest of the records
|
|
1836
1836
|
createdDescendingQueryData = await TestDataGenerator.generateRecordsQuery({
|
|
1837
1837
|
author: alice,
|
|
@@ -1840,7 +1840,7 @@ export function testRecordsQueryHandler() {
|
|
|
1840
1840
|
pagination: { cursor: createdDescendingQueryReply.cursor }
|
|
1841
1841
|
});
|
|
1842
1842
|
createdDescendingQueryReply = await dwn.processMessage(alice.did, createdDescendingQueryData.message);
|
|
1843
|
-
expect(createdDescendingQueryReply.entries
|
|
1843
|
+
expect(createdDescendingQueryReply.entries).toHaveLength(2);
|
|
1844
1844
|
expect(createdDescendingQueryReply.entries[0].recordId).toBe(write2Data.message.recordId);
|
|
1845
1845
|
expect(createdDescendingQueryReply.entries[1].recordId).toBe(write1Data.message.recordId);
|
|
1846
1846
|
// publishedAscending test
|
|
@@ -1850,7 +1850,7 @@ export function testRecordsQueryHandler() {
|
|
|
1850
1850
|
filter: { schema }
|
|
1851
1851
|
});
|
|
1852
1852
|
let publishedAscendingQueryReply = await dwn.processMessage(alice.did, publishedAscendingQueryData.message);
|
|
1853
|
-
expect(publishedAscendingQueryReply.entries
|
|
1853
|
+
expect(publishedAscendingQueryReply.entries).toHaveLength(3);
|
|
1854
1854
|
expect(publishedAscendingQueryReply.entries?.[0].recordId).toBe(write1Data.message.recordId);
|
|
1855
1855
|
expect(publishedAscendingQueryReply.entries?.[1].recordId).toBe(write2Data.message.recordId);
|
|
1856
1856
|
expect(publishedAscendingQueryReply.entries?.[2].recordId).toBe(write3Data.message.recordId);
|
|
@@ -1862,7 +1862,7 @@ export function testRecordsQueryHandler() {
|
|
|
1862
1862
|
pagination: { limit: 1 }
|
|
1863
1863
|
});
|
|
1864
1864
|
publishedAscendingQueryReply = await dwn.processMessage(alice.did, publishedAscendingQueryData.message);
|
|
1865
|
-
expect(publishedAscendingQueryReply.entries
|
|
1865
|
+
expect(publishedAscendingQueryReply.entries).toHaveLength(1);
|
|
1866
1866
|
publishedAscendingQueryData = await TestDataGenerator.generateRecordsQuery({
|
|
1867
1867
|
author: alice,
|
|
1868
1868
|
dateSort: DateSort.PublishedAscending,
|
|
@@ -1870,7 +1870,7 @@ export function testRecordsQueryHandler() {
|
|
|
1870
1870
|
pagination: { cursor: publishedAscendingQueryReply.cursor }
|
|
1871
1871
|
});
|
|
1872
1872
|
publishedAscendingQueryReply = await dwn.processMessage(alice.did, publishedAscendingQueryData.message);
|
|
1873
|
-
expect(publishedAscendingQueryReply.entries
|
|
1873
|
+
expect(publishedAscendingQueryReply.entries).toHaveLength(2);
|
|
1874
1874
|
expect(publishedAscendingQueryReply.entries[0].recordId).toBe(write2Data.message.recordId);
|
|
1875
1875
|
expect(publishedAscendingQueryReply.entries[1].recordId).toBe(write3Data.message.recordId);
|
|
1876
1876
|
// publishedDescending test
|
|
@@ -1880,7 +1880,7 @@ export function testRecordsQueryHandler() {
|
|
|
1880
1880
|
filter: { schema }
|
|
1881
1881
|
});
|
|
1882
1882
|
let publishedDescendingQueryReply = await dwn.processMessage(alice.did, publishedDescendingQueryData.message);
|
|
1883
|
-
expect(publishedDescendingQueryReply.entries
|
|
1883
|
+
expect(publishedDescendingQueryReply.entries).toHaveLength(3);
|
|
1884
1884
|
expect(publishedDescendingQueryReply.entries?.[0].recordId).toBe(write3Data.message.recordId);
|
|
1885
1885
|
expect(publishedDescendingQueryReply.entries?.[1].recordId).toBe(write2Data.message.recordId);
|
|
1886
1886
|
expect(publishedDescendingQueryReply.entries?.[2].recordId).toBe(write1Data.message.recordId);
|
|
@@ -1891,7 +1891,7 @@ export function testRecordsQueryHandler() {
|
|
|
1891
1891
|
pagination: { limit: 1 }
|
|
1892
1892
|
});
|
|
1893
1893
|
publishedDescendingQueryReply = await dwn.processMessage(alice.did, publishedDescendingQueryData.message);
|
|
1894
|
-
expect(publishedDescendingQueryReply.entries
|
|
1894
|
+
expect(publishedDescendingQueryReply.entries).toHaveLength(1);
|
|
1895
1895
|
publishedDescendingQueryData = await TestDataGenerator.generateRecordsQuery({
|
|
1896
1896
|
author: alice,
|
|
1897
1897
|
dateSort: DateSort.PublishedDescending,
|
|
@@ -1899,7 +1899,7 @@ export function testRecordsQueryHandler() {
|
|
|
1899
1899
|
pagination: { cursor: publishedDescendingQueryReply.cursor }
|
|
1900
1900
|
});
|
|
1901
1901
|
publishedDescendingQueryReply = await dwn.processMessage(alice.did, publishedDescendingQueryData.message);
|
|
1902
|
-
expect(publishedDescendingQueryReply.entries
|
|
1902
|
+
expect(publishedDescendingQueryReply.entries).toHaveLength(2);
|
|
1903
1903
|
expect(publishedDescendingQueryReply.entries[0].recordId).toBe(write2Data.message.recordId);
|
|
1904
1904
|
expect(publishedDescendingQueryReply.entries[1].recordId).toBe(write1Data.message.recordId);
|
|
1905
1905
|
});
|
|
@@ -1927,7 +1927,7 @@ export function testRecordsQueryHandler() {
|
|
|
1927
1927
|
filter: { schema }
|
|
1928
1928
|
});
|
|
1929
1929
|
const updatedAscendingQueryReply = await dwn.processMessage(alice.did, updatedAscendingQueryData.message);
|
|
1930
|
-
expect(updatedAscendingQueryReply.entries
|
|
1930
|
+
expect(updatedAscendingQueryReply.entries).toHaveLength(3);
|
|
1931
1931
|
expect(updatedAscendingQueryReply.entries?.[0].recordId).toBe(write1Data.message.recordId);
|
|
1932
1932
|
expect(updatedAscendingQueryReply.entries?.[1].recordId).toBe(write2Data.message.recordId);
|
|
1933
1933
|
expect(updatedAscendingQueryReply.entries?.[2].recordId).toBe(write3Data.message.recordId);
|
|
@@ -1938,7 +1938,7 @@ export function testRecordsQueryHandler() {
|
|
|
1938
1938
|
filter: { schema }
|
|
1939
1939
|
});
|
|
1940
1940
|
const updatedDescendingQueryReply = await dwn.processMessage(alice.did, updatedDescendingQueryData.message);
|
|
1941
|
-
expect(updatedDescendingQueryReply.entries
|
|
1941
|
+
expect(updatedDescendingQueryReply.entries).toHaveLength(3);
|
|
1942
1942
|
expect(updatedDescendingQueryReply.entries?.[0].recordId).toBe(write3Data.message.recordId);
|
|
1943
1943
|
expect(updatedDescendingQueryReply.entries?.[1].recordId).toBe(write2Data.message.recordId);
|
|
1944
1944
|
expect(updatedDescendingQueryReply.entries?.[2].recordId).toBe(write1Data.message.recordId);
|
|
@@ -2001,7 +2001,7 @@ export function testRecordsQueryHandler() {
|
|
|
2001
2001
|
filter: { schema }
|
|
2002
2002
|
});
|
|
2003
2003
|
const updatedAscReply = await dwn.processMessage(alice.did, updatedAscQuery.message);
|
|
2004
|
-
expect(updatedAscReply.entries
|
|
2004
|
+
expect(updatedAscReply.entries).toHaveLength(3);
|
|
2005
2005
|
expect(updatedAscReply.entries[0].recordId).toBe(write3.message.recordId);
|
|
2006
2006
|
expect(updatedAscReply.entries[1].recordId).toBe(write2.message.recordId);
|
|
2007
2007
|
expect(updatedAscReply.entries[2].recordId).toBe(write1.message.recordId);
|
|
@@ -2012,7 +2012,7 @@ export function testRecordsQueryHandler() {
|
|
|
2012
2012
|
filter: { schema }
|
|
2013
2013
|
});
|
|
2014
2014
|
const updatedDescReply = await dwn.processMessage(alice.did, updatedDescQuery.message);
|
|
2015
|
-
expect(updatedDescReply.entries
|
|
2015
|
+
expect(updatedDescReply.entries).toHaveLength(3);
|
|
2016
2016
|
expect(updatedDescReply.entries[0].recordId).toBe(write1.message.recordId);
|
|
2017
2017
|
expect(updatedDescReply.entries[1].recordId).toBe(write2.message.recordId);
|
|
2018
2018
|
expect(updatedDescReply.entries[2].recordId).toBe(write3.message.recordId);
|
|
@@ -2045,7 +2045,7 @@ export function testRecordsQueryHandler() {
|
|
|
2045
2045
|
const queryReply = await dwn.processMessage(alice.did, queryMessageData.message);
|
|
2046
2046
|
// verify that messages returned are sorted/tiebreak by `messageCid`
|
|
2047
2047
|
expect(queryReply.status.code).toBe(200);
|
|
2048
|
-
expect(queryReply.entries
|
|
2048
|
+
expect(queryReply.entries).toHaveLength(3);
|
|
2049
2049
|
expect((queryReply.entries[0]).recordId).toBe(oldestWrite.message.recordId);
|
|
2050
2050
|
expect((queryReply.entries[1]).recordId).toBe(middleWrite.message.recordId);
|
|
2051
2051
|
expect((queryReply.entries[2]).recordId).toBe(newestWrite.message.recordId);
|
|
@@ -2095,8 +2095,8 @@ export function testRecordsQueryHandler() {
|
|
|
2095
2095
|
break;
|
|
2096
2096
|
}
|
|
2097
2097
|
}
|
|
2098
|
-
expect(results
|
|
2099
|
-
expect(messages.every(({ message }) => results.map(e => e.recordId).includes(message.recordId)));
|
|
2098
|
+
expect(results).toHaveLength(messages.length);
|
|
2099
|
+
expect(messages.every(({ message }) => results.map(e => e.recordId).includes(message.recordId))).toBe(true);
|
|
2100
2100
|
});
|
|
2101
2101
|
it('should paginate all records in descending order', async () => {
|
|
2102
2102
|
const alice = await TestDataGenerator.generateDidKeyPersona();
|
|
@@ -2133,8 +2133,8 @@ export function testRecordsQueryHandler() {
|
|
|
2133
2133
|
break;
|
|
2134
2134
|
}
|
|
2135
2135
|
}
|
|
2136
|
-
expect(results
|
|
2137
|
-
expect(messages.every(({ message }) => results.map(e => e.recordId).includes(message.recordId)));
|
|
2136
|
+
expect(results).toHaveLength(messages.length);
|
|
2137
|
+
expect(messages.every(({ message }) => results.map(e => e.recordId).includes(message.recordId))).toBe(true);
|
|
2138
2138
|
});
|
|
2139
2139
|
it('should allow an anonymous unauthenticated query to return published records', async () => {
|
|
2140
2140
|
// write 2 records into Alice's DB:
|
|
@@ -2157,7 +2157,7 @@ export function testRecordsQueryHandler() {
|
|
|
2157
2157
|
expect(anonymousQueryMessageData.message.authorization).toBeUndefined();
|
|
2158
2158
|
const replyToQuery = await dwn.processMessage(alice.did, anonymousQueryMessageData.message);
|
|
2159
2159
|
expect(replyToQuery.status.code).toBe(200);
|
|
2160
|
-
expect(replyToQuery.entries
|
|
2160
|
+
expect(replyToQuery.entries).toHaveLength(1);
|
|
2161
2161
|
expect(replyToQuery.entries[0].descriptor.schema).toBe('https://schema2');
|
|
2162
2162
|
// explicitly for published records
|
|
2163
2163
|
const anonymousQueryPublished = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -2169,7 +2169,7 @@ export function testRecordsQueryHandler() {
|
|
|
2169
2169
|
// should return the published records
|
|
2170
2170
|
const publishedReply = await dwn.processMessage(alice.did, anonymousQueryPublished.message);
|
|
2171
2171
|
expect(publishedReply.status.code).toBe(200);
|
|
2172
|
-
expect(publishedReply.entries
|
|
2172
|
+
expect(publishedReply.entries).toHaveLength(1);
|
|
2173
2173
|
expect(publishedReply.entries[0].descriptor.schema).toBe('https://schema2');
|
|
2174
2174
|
});
|
|
2175
2175
|
it('should only return published records and unpublished records that are meant for specific recipient(s)', async () => {
|
|
@@ -2348,7 +2348,7 @@ export function testRecordsQueryHandler() {
|
|
|
2348
2348
|
});
|
|
2349
2349
|
const bobQueryMessagesForBobAliceReply = await dwn.processMessage(alice.did, bobQueryMessagesForBobAlice.message);
|
|
2350
2350
|
expect(bobQueryMessagesForBobAliceReply.status.code).toBe(200);
|
|
2351
|
-
expect(bobQueryMessagesForBobAliceReply.entries
|
|
2351
|
+
expect(bobQueryMessagesForBobAliceReply.entries).toHaveLength(7);
|
|
2352
2352
|
// Since Bob is the author if the query, we expect for him to be able to see:
|
|
2353
2353
|
// Private Messages THAT ANYONE sent to Bob
|
|
2354
2354
|
// Private Messages THAT ONLY HE sent to Alice
|
|
@@ -2370,7 +2370,7 @@ export function testRecordsQueryHandler() {
|
|
|
2370
2370
|
});
|
|
2371
2371
|
const carolQueryMessagesForCarolAliceReply = await dwn.processMessage(alice.did, carolQueryMessagesForCarolAlice.message);
|
|
2372
2372
|
expect(carolQueryMessagesForCarolAliceReply.status.code).toBe(200);
|
|
2373
|
-
expect(carolQueryMessagesForCarolAliceReply.entries
|
|
2373
|
+
expect(carolQueryMessagesForCarolAliceReply.entries).toHaveLength(4);
|
|
2374
2374
|
// Since Carol is the author if the query, we expect for her to be able to see:
|
|
2375
2375
|
// Private Messages THAT ANYONE sent to Carol
|
|
2376
2376
|
// Private Messages THAT ONLY SHE sent to Alice
|
|
@@ -2389,7 +2389,7 @@ export function testRecordsQueryHandler() {
|
|
|
2389
2389
|
});
|
|
2390
2390
|
const aliceQueryPublishedReply = await dwn.processMessage(alice.did, aliceQueryPublished.message);
|
|
2391
2391
|
expect(aliceQueryPublishedReply.status.code).toBe(200);
|
|
2392
|
-
expect(aliceQueryPublishedReply.entries
|
|
2392
|
+
expect(aliceQueryPublishedReply.entries).toHaveLength(4);
|
|
2393
2393
|
expect(aliceQueryPublishedReply.entries.map(e => e.recordId)).toEqual(expect.arrayContaining([
|
|
2394
2394
|
alicePublicToBob.message.recordId,
|
|
2395
2395
|
carolPublicToBob.message.recordId,
|
|
@@ -2403,7 +2403,7 @@ export function testRecordsQueryHandler() {
|
|
|
2403
2403
|
});
|
|
2404
2404
|
const carolQueryPrivateReply = await dwn.processMessage(alice.did, carolQueryPrivate.message);
|
|
2405
2405
|
expect(carolQueryPrivateReply.status.code).toBe(200);
|
|
2406
|
-
expect(carolQueryPrivateReply.entries
|
|
2406
|
+
expect(carolQueryPrivateReply.entries).toHaveLength(3);
|
|
2407
2407
|
// Carol can query for private messages she authored to alice, and her own private messages with herself as the recipient
|
|
2408
2408
|
expect(carolQueryPrivateReply.entries.map(e => e.recordId)).toEqual(expect.arrayContaining([
|
|
2409
2409
|
alicePrivateToCarol.message.recordId,
|
|
@@ -2587,7 +2587,7 @@ export function testRecordsQueryHandler() {
|
|
|
2587
2587
|
});
|
|
2588
2588
|
const bobQueryMessagesForBobAliceReply = await dwn.processMessage(alice.did, bobQueryMessagesForBobAlice.message);
|
|
2589
2589
|
expect(bobQueryMessagesForBobAliceReply.status.code).toBe(200);
|
|
2590
|
-
expect(bobQueryMessagesForBobAliceReply.entries
|
|
2590
|
+
expect(bobQueryMessagesForBobAliceReply.entries).toHaveLength(7);
|
|
2591
2591
|
// Since Bob is the author if the query, we expect for him to be able to see:
|
|
2592
2592
|
// Private Messages Bob authored TO ANYONE
|
|
2593
2593
|
// Private Messages Alice authored To Bob
|
|
@@ -2609,7 +2609,7 @@ export function testRecordsQueryHandler() {
|
|
|
2609
2609
|
});
|
|
2610
2610
|
const carolQueryMessagesForCarolAliceReply = await dwn.processMessage(alice.did, carolQueryMessagesForCarolAlice.message);
|
|
2611
2611
|
expect(carolQueryMessagesForCarolAliceReply.status.code).toBe(200);
|
|
2612
|
-
expect(carolQueryMessagesForCarolAliceReply.entries
|
|
2612
|
+
expect(carolQueryMessagesForCarolAliceReply.entries).toHaveLength(4);
|
|
2613
2613
|
// Since Carol is the author if the query, we expect for her to be able to see:
|
|
2614
2614
|
// All messages that Carol sent to anyone, private or public
|
|
2615
2615
|
expect(carolQueryMessagesForCarolAliceReply.entries.map(e => e.recordId)).toEqual(expect.arrayContaining([
|
|
@@ -2625,7 +2625,7 @@ export function testRecordsQueryHandler() {
|
|
|
2625
2625
|
});
|
|
2626
2626
|
const aliceQueryPublishedReply = await dwn.processMessage(alice.did, aliceQueryPublished.message);
|
|
2627
2627
|
expect(aliceQueryPublishedReply.status.code).toBe(200);
|
|
2628
|
-
expect(aliceQueryPublishedReply.entries
|
|
2628
|
+
expect(aliceQueryPublishedReply.entries).toHaveLength(4);
|
|
2629
2629
|
expect(aliceQueryPublishedReply.entries.map(e => e.recordId)).toEqual(expect.arrayContaining([
|
|
2630
2630
|
alicePublicToBob.message.recordId,
|
|
2631
2631
|
alicePublicToCarol.message.recordId,
|
|
@@ -2639,7 +2639,7 @@ export function testRecordsQueryHandler() {
|
|
|
2639
2639
|
});
|
|
2640
2640
|
const carolQueryPrivateReply = await dwn.processMessage(alice.did, carolQueryPrivate.message);
|
|
2641
2641
|
expect(carolQueryPrivateReply.status.code).toBe(200);
|
|
2642
|
-
expect(carolQueryPrivateReply.entries
|
|
2642
|
+
expect(carolQueryPrivateReply.entries).toHaveLength(3);
|
|
2643
2643
|
expect(carolQueryPrivateReply.entries.map(e => e.recordId)).toEqual(expect.arrayContaining([
|
|
2644
2644
|
alicePrivateToCarol.message.recordId,
|
|
2645
2645
|
carolPrivateToAlice.message.recordId,
|
|
@@ -2730,7 +2730,7 @@ export function testRecordsQueryHandler() {
|
|
|
2730
2730
|
const compareRecordId = (a, b) => {
|
|
2731
2731
|
return a.recordId === b.recordId;
|
|
2732
2732
|
};
|
|
2733
|
-
expect(sortedMessages.every((m, i) => compareRecordId(aliceRetrieved.at(i), m)));
|
|
2733
|
+
expect(sortedMessages.every((m, i) => compareRecordId(aliceRetrieved.at(i), m))).toBe(true);
|
|
2734
2734
|
const bobs = (m) => {
|
|
2735
2735
|
return m.descriptor.recipient === bob.did || m.descriptor.published === true || Message.getSigner(m) === bob.did;
|
|
2736
2736
|
};
|
|
@@ -2760,7 +2760,7 @@ export function testRecordsQueryHandler() {
|
|
|
2760
2760
|
expect(results.entries?.length).toBe(10, 'bob page 2');
|
|
2761
2761
|
expect(results.cursor, 'bob page 2 cursor').toBeUndefined();
|
|
2762
2762
|
bobRetrieved.push(...results.entries);
|
|
2763
|
-
expect(bobSorted.every((m, i) => compareRecordId(bobRetrieved.at(i), m)));
|
|
2763
|
+
expect(bobSorted.every((m, i) => compareRecordId(bobRetrieved.at(i), m))).toBe(true);
|
|
2764
2764
|
});
|
|
2765
2765
|
// https://github.com/enboxorg/enbox/issues/170
|
|
2766
2766
|
it('#170 - should treat records with `published` explicitly set to `false` as unpublished', async () => {
|
|
@@ -2779,7 +2779,7 @@ export function testRecordsQueryHandler() {
|
|
|
2779
2779
|
});
|
|
2780
2780
|
const replyToAliceQuery = await dwn.processMessage(alice.did, queryByAlice.message);
|
|
2781
2781
|
expect(replyToAliceQuery.status.code).toBe(200);
|
|
2782
|
-
expect(replyToAliceQuery.entries
|
|
2782
|
+
expect(replyToAliceQuery.entries).toHaveLength(1);
|
|
2783
2783
|
// actual test: bob should not be able to see unpublished record
|
|
2784
2784
|
const queryByBob = await TestDataGenerator.generateRecordsQuery({
|
|
2785
2785
|
author: bob,
|
|
@@ -2787,7 +2787,7 @@ export function testRecordsQueryHandler() {
|
|
|
2787
2787
|
});
|
|
2788
2788
|
const replyToBobQuery = await dwn.processMessage(alice.did, queryByBob.message);
|
|
2789
2789
|
expect(replyToBobQuery.status.code).toBe(200);
|
|
2790
|
-
expect(replyToBobQuery.entries
|
|
2790
|
+
expect(replyToBobQuery.entries).toHaveLength(0);
|
|
2791
2791
|
});
|
|
2792
2792
|
it('should allow DWN owner to use `recipient` as a filter in queries', async () => {
|
|
2793
2793
|
const alice = await TestDataGenerator.generateDidKeyPersona();
|
|
@@ -2817,7 +2817,7 @@ export function testRecordsQueryHandler() {
|
|
|
2817
2817
|
await dwn.processMessage(bob.did, recordsWriteMessage2Data.message, { dataStream: recordsWriteMessage2Data.dataStream });
|
|
2818
2818
|
const reply = await dwn.processMessage(alice.did, aliceQueryMessageData.message);
|
|
2819
2819
|
expect(reply.status.code).toBe(200);
|
|
2820
|
-
expect(reply.entries
|
|
2820
|
+
expect(reply.entries).toHaveLength(1);
|
|
2821
2821
|
});
|
|
2822
2822
|
it('should return 400 if protocol is not normalized', async () => {
|
|
2823
2823
|
const alice = await TestDataGenerator.generateDidKeyPersona();
|
|
@@ -2882,7 +2882,7 @@ export function testRecordsQueryHandler() {
|
|
|
2882
2882
|
const unpublishedPostQuery = await TestDataGenerator.generateRecordsQuery({ author: alice, filter: { schema: 'post', published: false } });
|
|
2883
2883
|
const unpublishedPostReply = await dwn.processMessage(alice.did, unpublishedPostQuery.message);
|
|
2884
2884
|
expect(unpublishedPostReply.status.code).toBe(200);
|
|
2885
|
-
expect(unpublishedPostReply.entries
|
|
2885
|
+
expect(unpublishedPostReply.entries).toHaveLength(1);
|
|
2886
2886
|
expect(unpublishedPostReply.entries[0].recordId).toBe(draftWrite.message.recordId);
|
|
2887
2887
|
// anonymous query for unpublished records
|
|
2888
2888
|
const unpublishedAnonymous = await RecordsQuery.create({ filter: { schema: 'post', published: false } });
|
|
@@ -2959,7 +2959,7 @@ export function testRecordsQueryHandler() {
|
|
|
2959
2959
|
});
|
|
2960
2960
|
const foo1ContextIdQueryReply = await dwn.processMessage(alice.did, foo1ContextIdQuery.message);
|
|
2961
2961
|
expect(foo1ContextIdQueryReply.status.code).toBe(200);
|
|
2962
|
-
expect(foo1ContextIdQueryReply.entries
|
|
2962
|
+
expect(foo1ContextIdQueryReply.entries).toHaveLength(5);
|
|
2963
2963
|
expect(foo1ContextIdQueryReply.entries.map((entry) => entry.recordId)).toEqual(expect.arrayContaining([
|
|
2964
2964
|
foo1.message.recordId,
|
|
2965
2965
|
bar1.message.recordId,
|
|
@@ -2974,7 +2974,7 @@ export function testRecordsQueryHandler() {
|
|
|
2974
2974
|
});
|
|
2975
2975
|
const bar1ContextIdQueryReply = await dwn.processMessage(alice.did, bar1ContextIdQuery.message);
|
|
2976
2976
|
expect(bar1ContextIdQueryReply.status.code).toBe(200);
|
|
2977
|
-
expect(bar1ContextIdQueryReply.entries
|
|
2977
|
+
expect(bar1ContextIdQueryReply.entries).toHaveLength(3);
|
|
2978
2978
|
expect(bar1ContextIdQueryReply.entries.map((entry) => entry.recordId)).toEqual(expect.arrayContaining([
|
|
2979
2979
|
bar1.message.recordId,
|
|
2980
2980
|
baz1.message.recordId,
|
|
@@ -2987,7 +2987,7 @@ export function testRecordsQueryHandler() {
|
|
|
2987
2987
|
});
|
|
2988
2988
|
const baz1ContextIdQueryReply = await dwn.processMessage(alice.did, baz1ContextIdQuery.message);
|
|
2989
2989
|
expect(baz1ContextIdQueryReply.status.code).toBe(200);
|
|
2990
|
-
expect(baz1ContextIdQueryReply.entries
|
|
2990
|
+
expect(baz1ContextIdQueryReply.entries).toHaveLength(1);
|
|
2991
2991
|
expect(baz1ContextIdQueryReply.entries.map((entry) => entry.recordId)).toEqual(expect.arrayContaining([baz1.message.recordId]));
|
|
2992
2992
|
});
|
|
2993
2993
|
it('does not try protocol authorization if protocolRole is not invoked', async () => {
|
|
@@ -3046,7 +3046,7 @@ export function testRecordsQueryHandler() {
|
|
|
3046
3046
|
});
|
|
3047
3047
|
const chatQueryReply = await dwn.processMessage(alice.did, chatQuery.message);
|
|
3048
3048
|
expect(chatQueryReply.status.code).toBe(200);
|
|
3049
|
-
expect(chatQueryReply.entries
|
|
3049
|
+
expect(chatQueryReply.entries).toHaveLength(1);
|
|
3050
3050
|
expect(chatQueryReply.entries[0].recordId).toBe(chatRecordForBob.message.recordId);
|
|
3051
3051
|
// bob queries without invoking any protocolRole and filters for unpublished records
|
|
3052
3052
|
const unpublishedChatQuery = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -3058,7 +3058,7 @@ export function testRecordsQueryHandler() {
|
|
|
3058
3058
|
});
|
|
3059
3059
|
const unpublishedChatReply = await dwn.processMessage(alice.did, unpublishedChatQuery.message);
|
|
3060
3060
|
expect(unpublishedChatReply.status.code).toBe(200);
|
|
3061
|
-
expect(unpublishedChatReply.entries
|
|
3061
|
+
expect(unpublishedChatReply.entries).toHaveLength(1);
|
|
3062
3062
|
expect(unpublishedChatReply.entries[0].recordId).toBe(chatRecordForBob.message.recordId);
|
|
3063
3063
|
});
|
|
3064
3064
|
it('allows root-level role authorized queries', async () => {
|
|
@@ -3109,7 +3109,7 @@ export function testRecordsQueryHandler() {
|
|
|
3109
3109
|
});
|
|
3110
3110
|
const chatQueryReply = await dwn.processMessage(alice.did, chatQuery.message);
|
|
3111
3111
|
expect(chatQueryReply.status.code).toBe(200);
|
|
3112
|
-
expect(chatQueryReply.entries
|
|
3112
|
+
expect(chatQueryReply.entries).toHaveLength(3);
|
|
3113
3113
|
expect(chatQueryReply.entries.map((record) => record.recordId)).toEqual(expect.arrayContaining(chatRecordIds));
|
|
3114
3114
|
// Bob invokes his friendRole along with an explicit filter for unpublished records
|
|
3115
3115
|
const unpublishedChatQuery = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -3123,7 +3123,7 @@ export function testRecordsQueryHandler() {
|
|
|
3123
3123
|
});
|
|
3124
3124
|
const unpublishedChatReply = await dwn.processMessage(alice.did, unpublishedChatQuery.message);
|
|
3125
3125
|
expect(unpublishedChatReply.status.code).toBe(200);
|
|
3126
|
-
expect(unpublishedChatReply.entries
|
|
3126
|
+
expect(unpublishedChatReply.entries).toHaveLength(3);
|
|
3127
3127
|
expect(unpublishedChatReply.entries.map((record) => record.recordId)).toEqual(expect.arrayContaining(chatRecordIds));
|
|
3128
3128
|
});
|
|
3129
3129
|
it('can authorize queries using a context role.', async () => {
|
|
@@ -3184,7 +3184,7 @@ export function testRecordsQueryHandler() {
|
|
|
3184
3184
|
});
|
|
3185
3185
|
const chatQueryReply = await dwn.processMessage(alice.did, chatQuery.message);
|
|
3186
3186
|
expect(chatQueryReply.status.code).toBe(200);
|
|
3187
|
-
expect(chatQueryReply.entries
|
|
3187
|
+
expect(chatQueryReply.entries).toHaveLength(3);
|
|
3188
3188
|
expect(chatQueryReply.entries.map((record) => record.recordId)).toEqual(expect.arrayContaining(chatRecordIds));
|
|
3189
3189
|
});
|
|
3190
3190
|
it('does not execute protocol queries where protocolPath is missing from the filter', async () => {
|
|
@@ -3478,7 +3478,7 @@ export function testRecordsQueryHandler() {
|
|
|
3478
3478
|
});
|
|
3479
3479
|
const bobQueryReply = await dwn.processMessage(alice.did, bobQuery.message);
|
|
3480
3480
|
expect(bobQueryReply.status.code).toBe(200);
|
|
3481
|
-
expect(bobQueryReply.entries
|
|
3481
|
+
expect(bobQueryReply.entries).toHaveLength(2);
|
|
3482
3482
|
expect(bobQueryReply.entries.map((e) => e.recordId)).toEqual(expect.arrayContaining(bobRecordIds));
|
|
3483
3483
|
// Carol queries — should see exactly her 1 message
|
|
3484
3484
|
const carolQuery = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -3490,7 +3490,7 @@ export function testRecordsQueryHandler() {
|
|
|
3490
3490
|
});
|
|
3491
3491
|
const carolQueryReply = await dwn.processMessage(alice.did, carolQuery.message);
|
|
3492
3492
|
expect(carolQueryReply.status.code).toBe(200);
|
|
3493
|
-
expect(carolQueryReply.entries
|
|
3493
|
+
expect(carolQueryReply.entries).toHaveLength(1);
|
|
3494
3494
|
expect(carolQueryReply.entries[0].recordId).toBe(carolMsg.message.recordId);
|
|
3495
3495
|
});
|
|
3496
3496
|
it('author can query their own records via who-based rule', async () => {
|
|
@@ -3527,7 +3527,7 @@ export function testRecordsQueryHandler() {
|
|
|
3527
3527
|
});
|
|
3528
3528
|
const bobQueryReply = await dwn.processMessage(alice.did, bobQuery.message);
|
|
3529
3529
|
expect(bobQueryReply.status.code).toBe(200);
|
|
3530
|
-
expect(bobQueryReply.entries
|
|
3530
|
+
expect(bobQueryReply.entries).toHaveLength(1);
|
|
3531
3531
|
expect(bobQueryReply.entries[0].recordId).toBe(bobMsg.message.recordId);
|
|
3532
3532
|
// Carol queries — should see nothing (she is neither author nor recipient)
|
|
3533
3533
|
const carolQuery = await TestDataGenerator.generateRecordsQuery({
|
|
@@ -3539,7 +3539,7 @@ export function testRecordsQueryHandler() {
|
|
|
3539
3539
|
});
|
|
3540
3540
|
const carolQueryReply = await dwn.processMessage(alice.did, carolQuery.message);
|
|
3541
3541
|
expect(carolQueryReply.status.code).toBe(200);
|
|
3542
|
-
expect(carolQueryReply.entries
|
|
3542
|
+
expect(carolQueryReply.entries).toHaveLength(0);
|
|
3543
3543
|
});
|
|
3544
3544
|
it('unauthorized party cannot see any unpublished records via query', async () => {
|
|
3545
3545
|
// scenario: Alice writes unpublished messages. Dave (not author, not recipient)
|
|
@@ -3577,7 +3577,7 @@ export function testRecordsQueryHandler() {
|
|
|
3577
3577
|
});
|
|
3578
3578
|
const daveQueryReply = await dwn.processMessage(alice.did, daveQuery.message);
|
|
3579
3579
|
expect(daveQueryReply.status.code).toBe(200);
|
|
3580
|
-
expect(daveQueryReply.entries
|
|
3580
|
+
expect(daveQueryReply.entries).toHaveLength(0);
|
|
3581
3581
|
// Dave queries with explicit unpublished filter — still sees nothing
|
|
3582
3582
|
const daveUnpubQuery = await TestDataGenerator.generateRecordsQuery({
|
|
3583
3583
|
author: dave,
|
|
@@ -3589,7 +3589,7 @@ export function testRecordsQueryHandler() {
|
|
|
3589
3589
|
});
|
|
3590
3590
|
const daveUnpubReply = await dwn.processMessage(alice.did, daveUnpubQuery.message);
|
|
3591
3591
|
expect(daveUnpubReply.status.code).toBe(200);
|
|
3592
|
-
expect(daveUnpubReply.entries
|
|
3592
|
+
expect(daveUnpubReply.entries).toHaveLength(0);
|
|
3593
3593
|
});
|
|
3594
3594
|
it('who-based query rules do not grant role-like broad access', async () => {
|
|
3595
3595
|
// scenario: Protocol has who-based query rules. A non-participant tries to invoke
|
|
@@ -3673,7 +3673,7 @@ export function testRecordsQueryHandler() {
|
|
|
3673
3673
|
});
|
|
3674
3674
|
const bobRoleQueryReply = await dwn.processMessage(alice.did, bobRoleQuery.message);
|
|
3675
3675
|
expect(bobRoleQueryReply.status.code).toBe(200);
|
|
3676
|
-
expect(bobRoleQueryReply.entries
|
|
3676
|
+
expect(bobRoleQueryReply.entries).toHaveLength(3);
|
|
3677
3677
|
// Dave (who is NOT a participant) tries to invoke the role — should be rejected
|
|
3678
3678
|
const daveRoleQuery = await TestDataGenerator.generateRecordsQuery({
|
|
3679
3679
|
author: dave,
|
|
@@ -3698,7 +3698,7 @@ export function testRecordsQueryHandler() {
|
|
|
3698
3698
|
});
|
|
3699
3699
|
const daveNoRoleQueryReply = await dwn.processMessage(alice.did, daveNoRoleQuery.message);
|
|
3700
3700
|
expect(daveNoRoleQueryReply.status.code).toBe(200);
|
|
3701
|
-
expect(daveNoRoleQueryReply.entries
|
|
3701
|
+
expect(daveNoRoleQueryReply.entries).toHaveLength(0);
|
|
3702
3702
|
});
|
|
3703
3703
|
});
|
|
3704
3704
|
});
|