-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #3
- Loading branch information
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Validate Public Key Data | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'webapp/data/pubkey.json' | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v3 | ||
with: | ||
version: 8.15.5 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'pnpm' | ||
|
||
- name: Install package deps | ||
run: pnpm install | ||
working-directory: ./package | ||
|
||
- name: Build package | ||
run: pnpm build | ||
working-directory: ./package | ||
|
||
- name: Install webapp deps | ||
run: pnpm install | ||
working-directory: ./webapp | ||
|
||
- name: Check | ||
run: pnpm test:pubkey | ||
working-directory: ./webapp |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ packages: | |
- 'package' | ||
- 'webapp' | ||
- 'worker' | ||
- 'checker' |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { importKey } from '@saitamau-maximum/auth/internal' | ||
import { expect, it } from 'vitest' | ||
|
||
import data from '../data/pubkey.json' | ||
|
||
it('has the correct schema', () => { | ||
expect(data).toBeTypeOf('object') | ||
expect(Array.isArray(data)).toBe(true) | ||
for (const item of data) { | ||
expect(item).toBeTypeOf('object') | ||
expect(item).toHaveProperty('name') | ||
expect(item).toHaveProperty('pubkey') | ||
expect(item.name).toBeTypeOf('string') | ||
expect(item.pubkey).toBeTypeOf('string') | ||
} | ||
}) | ||
|
||
it('has the correct pubkey', async () => { | ||
for (const item of data) { | ||
expect( | ||
await importKey(item.pubkey, 'publicKey') | ||
.then(() => true) | ||
.catch(() => false), | ||
).toBeTruthy() | ||
expect( | ||
await importKey(item.pubkey, 'privateKey') | ||
.then(() => true) | ||
.catch(() => false), | ||
).toBeFalsy() | ||
expect( | ||
await importKey(item.pubkey, 'symmetric') | ||
.then(() => true) | ||
.catch(() => false), | ||
).toBeFalsy() | ||
const key = await importKey(item.pubkey, 'publicKey') | ||
expect(key.algorithm.name).toBe('ECDSA') | ||
expect(key.usages).toContain('verify') | ||
} | ||
}) |