diff --git a/tests/e2e/auth.setup.ts b/tests/e2e/auth.setup.ts index 8f75ed17..0f4c2e18 100644 --- a/tests/e2e/auth.setup.ts +++ b/tests/e2e/auth.setup.ts @@ -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. @@ -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 }); +});