Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatawalletSynchronizedEvent is not anymore emitted in the connector #347

Merged
merged 8 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
270 changes: 199 additions & 71 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@js-soft/docdb-access-mongo": "1.1.9",
"@js-soft/node-logger": "1.2.0",
"@js-soft/ts-utils": "^2.3.3",
"@nmshd/runtime": "6.20.0",
"@nmshd/runtime": "6.23.0",
"@nmshd/typescript-ioc": "^3.2.4",
"@nmshd/typescript-rest": "^3.0.5",
"agentkeepalive": "4.6.0",
Expand Down Expand Up @@ -113,8 +113,8 @@
"@js-soft/eslint-config-ts": "1.6.13",
"@js-soft/license-check": "1.0.9",
"@nmshd/connector-sdk": "*",
"@nmshd/content": "6.20.0",
"@nmshd/core-types": "6.20.0",
"@nmshd/content": "6.23.0",
"@nmshd/core-types": "6.23.0",
"@nmshd/typescript-rest-swagger": "^1.4.1",
"@types/amqplib": "^0.10.6",
"@types/compression": "^1.7.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"build:schemas:watch": "npx nodemon -e ts -w 'src/types' --exec 'npm run build:schemas'"
},
"dependencies": {
"@nmshd/content": "6.20.0",
"@nmshd/content": "6.23.0",
"axios": "^1.7.9",
"form-data": "^4.0.1",
"qs": "^6.13.1"
"qs": "^6.14.0"
},
"devDependencies": {
"@types/qs": "^6.9.17",
"@types/qs": "^6.9.18",
"ts-json-schema-generator": "^2.3.0"
},
"publishConfig": {
Expand Down
5 changes: 4 additions & 1 deletion test/attributes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getTimeout } from "./lib/setTimeout";
import {
connectAndEmptyCollection,
createRepositoryAttribute,
deleteAllAttributes,
establishRelationship,
executeFullCreateAndShareRelationshipAttributeFlow,
executeFullCreateAndShareRepositoryAttributeFlow,
Expand All @@ -31,7 +32,9 @@ beforeAll(async () => {
}, getTimeout(30000));
afterAll(() => launcher.stop());

beforeEach(() => {
beforeEach(async () => {
await deleteAllAttributes(client1, client1Address);
await deleteAllAttributes(client2, client2Address);
client1._eventBus?.reset();
client2._eventBus?.reset();
});
Expand Down
29 changes: 10 additions & 19 deletions test/identityMetadata.test.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,58 @@
import { Random, RandomCharacterRange } from "@nmshd/transport";
import { ConnectorClientWithMetadata, Launcher } from "./lib/Launcher";
import { ValidationSchema } from "./lib/validation";

const launcher = new Launcher();
let client1: ConnectorClientWithMetadata;
let client1Address: string;

beforeAll(async () => {
[client1] = await launcher.launch(1);
client1Address = (await client1.account.getIdentityInfo()).result.address;
}, 30000);

afterAll(() => launcher.stop());

describe("IdentityMetadata", () => {
test.each([
{
reference: "did:e:localhost:dids:1234567890abcdef123456",
key: undefined,
value: "value"
},
{
reference: "did:e:localhost:dids:1234567890abcdef123456",
key: undefined,
value: { a: "json" }
},
{
reference: "did:e:localhost:dids:1234567890abcdef123456",
key: "key",
value: "value"
}
])("should upsert an IdentityMetadata with key '$key' and value '$value'", async (data) => {
const result = await client1.identityMetadata.upsertIdentityMetadata(data);
const result = await client1.identityMetadata.upsertIdentityMetadata({ ...data, reference: client1Address });
expect(result).toBeSuccessful(ValidationSchema.IdentityMetadata);

const identityMetadata = result.result;
expect(identityMetadata.reference.toString()).toStrictEqual(data.reference);
expect(identityMetadata.reference.toString()).toStrictEqual(client1Address);
expect(identityMetadata.key).toStrictEqual(data.key);
expect(identityMetadata.value).toStrictEqual(data.value);
});

test("should get an IdentityMetadata", async () => {
const reference = await generateReference();
await client1.identityMetadata.upsertIdentityMetadata({ reference: reference, value: "value" });
await client1.identityMetadata.upsertIdentityMetadata({ reference: client1Address, value: "value" });

const result = await client1.identityMetadata.getIdentityMetadata(reference);
const result = await client1.identityMetadata.getIdentityMetadata(client1Address);
expect(result).toBeSuccessful(ValidationSchema.IdentityMetadata);

const identityMetadata = result.result;
expect(identityMetadata.value).toBe("value");
});

test("should delete an IdentityMetadata", async () => {
const reference = await generateReference();
await client1.identityMetadata.upsertIdentityMetadata({ reference: reference, value: "value" });
await client1.identityMetadata.upsertIdentityMetadata({ reference: client1Address, value: "value" });

const result = await client1.identityMetadata.deleteIdentityMetadata(reference);
const result = await client1.identityMetadata.deleteIdentityMetadata(client1Address);
expect(result).toBeSuccessfulVoidResult();

const getResult = await client1.identityMetadata.getIdentityMetadata(reference);
expect(getResult).toBeAnError("IdentityMetadata not found. Make sure the ID exists and the record is not expired.", "error.runtime.recordNotFound");
const getResult = await client1.identityMetadata.getIdentityMetadata(client1Address);
expect(getResult).toBeAnError("There is no stored IdentityMetadata for the specified combination of reference and key.", "error.runtime.identityMetadata.notFound");
});
});

async function generateReference(): Promise<string> {
const identityPart = await Random.string(22, `${RandomCharacterRange.Digit}abcdef`);
return `did:e:localhost:dids:${identityPart}`;
}
2 changes: 1 addition & 1 deletion test/iqlquery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ beforeAll(async () => {
owner: client1Address,
value: {
"@type": "GivenName",
value: "AGivenName"
value: "ASecondGivenName"
},
tags: ["language:de", "content:edu.de.higher"]
}
Expand Down
33 changes: 33 additions & 0 deletions test/lib/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,36 @@ export async function waitForEvent<TEvent>(
clearTimeout(timeoutId);
});
}

export async function deleteAllAttributes(client: ConnectorClient, clientAddress: string): Promise<void> {
const attributesResponse = await client.attributes.getAttributes({});
expect(attributesResponse).toBeSuccessful(ValidationSchema.ConnectorAttributes);

for (const attribute of attributesResponse.result) {
if (!attribute.shareInfo) {
const result = await client.attributes.deleteRepositoryAttribute(attribute.id);
expect(result).toBeSuccessfulVoidResult();
continue;
}

if (attribute.content.owner === clientAddress) {
const result = await client.attributes.deleteOwnSharedAttributeAndNotifyPeer(attribute.id);
expect(result).toBeSuccessful(ValidationSchema.DeleteOwnSharedAttributeAndNotifyPeerResponse);
continue;
}

if (attribute.content.owner !== clientAddress && !attribute.shareInfo.thirdPartyAddress) {
const result = await client.attributes.deletePeerSharedAttributeAndNotifyOwner(attribute.id);
expect(result).toBeSuccessful(ValidationSchema.DeletePeerSharedAttributeAndNotifyOwnerResponse);
continue;
}

if (attribute.shareInfo.thirdPartyAddress) {
const result = await client.attributes.deleteThirdPartyRelationshipAttributeAndNotifyPeer(attribute.id);
expect(result).toBeSuccessful(ValidationSchema.DeleteThirdPartyRelationshipAttributeAndNotifyPeerResponse);
continue;
}
britsta marked this conversation as resolved.
Show resolved Hide resolved

throw new Error("No delete method called");
}
}
5 changes: 4 additions & 1 deletion test/lib/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export enum ValidationSchema {
ConnectorAttribute = "ConnectorAttribute",
ConnectorAttributes = "ConnectorAttributes",
ConnectorAttributeTagCollection = "ConnectorAttributeTagCollection",
SucceedAttributeResponse = "SucceedAttributeResponse"
SucceedAttributeResponse = "SucceedAttributeResponse",
DeleteThirdPartyRelationshipAttributeAndNotifyPeerResponse = "DeleteThirdPartyRelationshipAttributeAndNotifyPeerResponse",
DeleteOwnSharedAttributeAndNotifyPeerResponse = "DeleteOwnSharedAttributeAndNotifyPeerResponse",
DeletePeerSharedAttributeAndNotifyOwnerResponse = "DeletePeerSharedAttributeAndNotifyOwnerResponse"
}

export function validateSchema(schemaName: ValidationSchema, obj: any): void {
Expand Down
Loading