Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dhkem-secp256k1 test to use hpke/core. #218

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci_browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:
cp -rf x/dhkem-x25519/test/runtimes/browsers/pages/* test/runtimes/browsers/pages/dhkem-x25519
mkdir test/runtimes/browsers/pages/dhkem-secp256k1
cp -rf x/dhkem-secp256k1/test/runtimes/browsers/pages/* test/runtimes/browsers/pages/dhkem-secp256k1
deno task minify > test/runtimes/browsers/pages/dhkem-secp256k1/src/hpke.js
- working-directory: ./core
run: |
deno task dnt
deno task minify > ../test/runtimes/browsers/pages/core/src/hpke-core.js
deno task minify > ../test/runtimes/browsers/pages/dhkem-x25519/src/hpke-core.js
deno task minify > ../test/runtimes/browsers/pages/dhkem-secp256k1/src/hpke-core.js
- working-directory: ./x/dhkem-x25519
run: |
deno task dnt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_bun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
npm install -g esbuild
deno task dnt
deno task minify > test/runtimes/hpke.js
deno task minify > x/dhkem-secp256k1/test/runtimes/hpke.js
- uses: antongolub/action-setup-bun@v1
with:
bun-version: ${{ matrix.bun-version }}
Expand All @@ -44,6 +43,7 @@ jobs:
deno task dnt
deno task minify > test/runtimes/hpke-core.js
deno task minify > ../x/dhkem-x25519/test/runtimes/hpke-core.js
deno task minify > ../x/dhkem-secp256k1/test/runtimes/hpke-core.js
- name: Run test for core
working-directory: ./core/test/runtimes/bun
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_cloudflare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
npm install -g esbuild
deno task dnt
deno task minify > test/runtimes/hpke.js
deno task minify > x/dhkem-secp256k1/test/runtimes/hpke.js
- name: Run test
working-directory: ./test/runtimes/cloudflare
run: |
Expand All @@ -37,6 +36,7 @@ jobs:
deno task dnt
deno task minify > test/runtimes/hpke-core.js
deno task minify > ../x/dhkem-x25519/test/runtimes/hpke-core.js
deno task minify > ../x/dhkem-secp256k1/test/runtimes/hpke-core.js
- name: Run test for core
working-directory: ./core/test/runtimes/cloudflare
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ test("basic test", async ({ page }) => {
await page.goto("https://dajiaji.github.io/hpke-js/dhkem-secp256k1");
await page.click("text=run");
await page.waitForTimeout(5000);
await expect(page.locator("id=pass")).toHaveText("9");
await expect(page.locator("id=pass")).toHaveText("6");
await expect(page.locator("id=fail")).toHaveText("0");
});
8 changes: 4 additions & 4 deletions x/dhkem-secp256k1/test/runtimes/browsers/pages/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html>
<head><title>hpke-js test</title></head>
<head><title>@hpke/dhkem-secp256k1 test</title></head>
<body>
<script type="module">
import { KdfId, AeadId, CipherSuite } from './src/hpke.js';
import { KdfId, AeadId, CipherSuite } from './src/hpke-core.js';
import { DhkemSecp256k1HkdfSha256 } from './src/hpke-dhkem-secp256k1.js';

const kdfs = [
Expand All @@ -14,7 +14,7 @@
const aeads = [
AeadId.Aes128Gcm,
AeadId.Aes256Gcm,
AeadId.Chacha20Poly1305,
// AeadId.Chacha20Poly1305,
];

globalThis.run = async () => {
Expand Down Expand Up @@ -62,7 +62,7 @@

</script>

<h1><a href="https://github.com/dajiaji/hpke-js">hpke-js</a> test</h1>
<h1><a href="https://github.com/dajiaji/hpke-js">@hpke/dhkem-secp256k1</a> test</h1>

<div id="operation">
<button type="button" onclick="run()">run</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("Bun", () => {
describe("GET /test", () => {
it("should return ok", async () => {
for (const kdf of ["0x0001", "0x0002", "0x0003"]) {
for (const aead of ["0x0001", "0x0002", "0x0003"]) {
for (const aead of ["0x0001", "0x0002"]) {
const res = await fetch(
`http://localhost:3001/test?kdf=${kdf}&aead=${aead}`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("Cloudflare Workers", () => {
describe("GET /test", () => {
it("should return ok", async () => {
for (const kdf of ["0x0001", "0x0002", "0x0003"]) {
for (const aead of ["0x0001", "0x0002", "0x0003"]) {
for (const aead of ["0x0001", "0x0002"]) {
const res = await fetch(
`http://localhost:8788/test?kdf=${kdf}&aead=${aead}`,
);
Expand Down
6 changes: 3 additions & 3 deletions x/dhkem-secp256k1/test/runtimes/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as hpke from "./hpke.js";
import * as secp256k1 from "./hpke-dhkem-secp256k1.js";
import * as hpke from "./hpke-core.js";
import { DhkemSecp256k1HkdfSha256 } from "./hpke-dhkem-secp256k1.js";

export async function testServer(request) {
const url = new URL(request.url);
Expand All @@ -12,7 +12,7 @@ export async function testServer(request) {
if (kdfStr === null || aeadStr === null) {
return new Response("ng: invalid params");
}
const kem = new secp256k1.DhkemSecp256k1HkdfSha256();
const kem = new DhkemSecp256k1HkdfSha256();
const kdf = Number.parseInt(kdfStr);
const aead = Number.parseInt(aeadStr);
if (Number.isNaN(kdf) || Number.isNaN(aead)) {
Expand Down
Loading