Skip to content

Commit

Permalink
test(e2e/setup): ensure given public key added to test wallet (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Dec 5, 2024
1 parent 49b9862 commit 10071a0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/e2e/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { existsSync } from 'fs';
import { test as setup, expect } from './fixtures/base';
import { authFile } from './fixtures/helpers';
import { getJWKS } from '@/shared/helpers';
import type { JWK } from '@interledger/open-payments';

// Authenticate with wallet once in "setup" so we don't have to do it over and
// over for each test file.
Expand Down Expand Up @@ -29,3 +31,23 @@ setup('authenticate', async ({ page }) => {

await page.context().storageState({ path: authFile });
});

setup('validate test wallet has provided keys added', async () => {
const {
TEST_WALLET_ADDRESS_URL,
TEST_WALLET_KEY_ID,
TEST_WALLET_PUBLIC_KEY,
} = process.env;

expect(TEST_WALLET_ADDRESS_URL).toBeDefined();
expect(TEST_WALLET_KEY_ID).toBeDefined();
expect(TEST_WALLET_PUBLIC_KEY).toBeDefined();

const jwks = await getJWKS(TEST_WALLET_ADDRESS_URL);
expect(jwks.keys.length).toBeGreaterThan(0);

const key = jwks.keys.find((key) => key.kid === TEST_WALLET_KEY_ID);
expect(key).toBeDefined();
const { x } = JSON.parse(atob(TEST_WALLET_PUBLIC_KEY)) as JWK;
expect(key).toMatchObject({ kid: TEST_WALLET_KEY_ID, x });
});

0 comments on commit 10071a0

Please sign in to comment.