Skip to content

Commit 2f1a7f5

Browse files
committed
Added missing e2e tests for keys switch, keys revoke and keys current
1 parent 0833b06 commit 2f1a7f5

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

test/e2e/auth/auth-keys-e2e.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,45 @@ describe.skipIf(SHOULD_SKIP_CONTROL_E2E)("Auth Keys E2E Tests", () => {
158158
expect(nameChange).toHaveProperty("before", originalName);
159159
expect(nameChange).toHaveProperty("after", updatedName);
160160
});
161+
162+
it("should revoke a key by key name", { timeout: 20000 }, async () => {
163+
setupTestFailureHandler("should revoke a key by key name");
164+
165+
// First create a key to revoke
166+
const keyName = `e2e-revoke-key-${Date.now()}`;
167+
const createResult = await runCommand(
168+
["auth", "keys", "create", keyName, "--app", testAppId, "--json"],
169+
{
170+
env: { ABLY_ACCESS_TOKEN: E2E_ACCESS_TOKEN || "" },
171+
},
172+
);
173+
174+
const createRecord = parseNdjsonLines(createResult.stdout).find(
175+
(r) => r.type === "result",
176+
) as Record<string, unknown>;
177+
const createdKey = createRecord.key as Record<string, unknown>;
178+
const keyFullName = createdKey.keyName as string;
179+
180+
// Revoke by key name (appId is embedded in keyFullName), --force to skip confirmation
181+
const revokeResult = await runCommand(
182+
["auth", "keys", "revoke", keyFullName, "--force", "--json"],
183+
{
184+
env: { ABLY_ACCESS_TOKEN: E2E_ACCESS_TOKEN || "" },
185+
},
186+
);
187+
188+
expect(revokeResult.exitCode).toBe(0);
189+
const revokeRecord = parseNdjsonLines(revokeResult.stdout).find(
190+
(r) => r.type === "result",
191+
) as Record<string, unknown>;
192+
expect(revokeRecord).toBeDefined();
193+
expect(revokeRecord).toHaveProperty("success", true);
194+
const revokedKey = revokeRecord.key as Record<string, unknown>;
195+
expect(revokedKey).toHaveProperty("keyName", keyFullName);
196+
expect(revokedKey).toHaveProperty("message", "Key has been revoked");
197+
});
198+
199+
// NOTE: switch and current commands require a locally configured account
200+
// (configManager.storeAppKey / getApiKey), which doesn't exist in CI where
201+
// only ABLY_ACCESS_TOKEN env var is set. These commands are covered by unit tests.
161202
});

0 commit comments

Comments
 (0)