-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DatawalletSynchronizedEvent is not anymore emitted in the connector (#…
…347) * chore: update runtime and tests * chore: improve delete method error * chore: fix expect for attribute deletion * chore: fix identity metadata tests * Update test/lib/testUtils.ts Co-authored-by: Julian König <[email protected]> * chore: deletion of all attributes * fix: use delete third party for all third party attributes --------- Co-authored-by: Julian König <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9b0ab06
commit abc25ed
Showing
8 changed files
with
257 additions
and
99 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters