Skip to content

Commit

Permalink
test(local): add revoke agent key test
Browse files Browse the repository at this point in the history
  • Loading branch information
jost-s committed Oct 1, 2024
1 parent 5b29483 commit 0b25d1c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
44 changes: 44 additions & 0 deletions ts/test/local/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
CellProvisioningStrategy,
CloneId,
EntryHash,
HolochainError,
RevokeAgentKeyResponse,
Signal,
SignalCb,
SignalType,
Expand Down Expand Up @@ -158,6 +160,48 @@ test("Local Conductor - set a DPKI network seed", async (t) => {
await cleanAllConductors();
});

test("Local Conductor - revoke agent key", async (t) => {
const { servicesProcess, signalingServerUrl } = await runLocalServices();
const conductor = await createConductor(signalingServerUrl);
const app = await conductor.installApp({
path: FIXTURE_HAPP_URL.pathname,
});
const adminWs = conductor.adminWs();
const port = await conductor.attachAppInterface();
const issued = await adminWs.issueAppAuthenticationToken({
installed_app_id: app.installed_app_id,
});
const appWs = await conductor.connectAppWs(issued.token, port);
const alice = await enableAndGetAgentApp(adminWs, appWs, app);

// Alice can create an entry before revoking agent key.
const entryContent = "test-content";
const createEntryResponse: EntryHash = await alice.cells[0].callZome({
zome_name: "coordinator",
fn_name: "create",
payload: entryContent,
});
t.ok(createEntryResponse, "created entry successfully");

const response: RevokeAgentKeyResponse = await conductor
.adminWs()
.revokeAgentKey({ app_id: alice.appId, agent_key: alice.agentPubKey });
t.deepEqual(response, [], "revoked key on all cells");

// After revoking her key, Alice should no longer be able to create an entry.
await t.rejects(
alice.cells[0].callZome({
zome_name: "coordinator",
fn_name: "create",
payload: entryContent,
})
);

await conductor.shutDown();
await stopLocalServices(servicesProcess);
await cleanAllConductors();
});

test("Local Conductor - get app info with app ws", async (t) => {
const { servicesProcess, signalingServerUrl } = await runLocalServices();
const conductor = await createConductor(signalingServerUrl);
Expand Down
7 changes: 4 additions & 3 deletions ts/test/trycp/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,16 @@ test("TryCP Conductor - revoke agent key", async (t) => {
const response: RevokeAgentKeyResponse = await conductor
.adminWs()
.revokeAgentKey({ app_id: alice.appId, agent_key: alice.agentPubKey });
t.deepEqual(response, []);
t.deepEqual(response, [], "revoked key on all cells");

// After revoking her key, Alice should no longer be able to create an entry.
t.rejects(
await t.rejects(
alice.cells[0].callZome({
zome_name: "coordinator",
fn_name: "create",
payload: entryContent,
})
}),
"creating an entry is not allowed any more"
);

await stopLocalServices(servicesProcess);
Expand Down

0 comments on commit 0b25d1c

Please sign in to comment.