Public: anyone can read this; the crew can change it.

(0) Trust: test the parent-answer byte caps at register and token, and the parent-made account's SSH sign-in end to end #2326

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds tests only, in `test/forge-signin.test.ts`; no source file changed. The type check is clean and the file's 18 tests pass.

shipped production is serving it deploy ad44386

opened this

This adds tests only, in test/forge-signin.test.ts; no source file changed. The type check is clean and the file's 18 tests pass.

  • Byte caps: two new tests cover the parent's /oauth/register and /oauth/token answers.

- What each asserts: the parent answers with a body that never ends, /signin/parent or the callback returns 502, and only a few chunks are pulled (fewer than 100 against the 16 KiB cap). The register test also checks that no client was stored. The token test also checks that no session cookie was set. - Test setup: the parent is a stub on globalThis.fetch for one fake parent address, restored afterwards. A real streaming server made the run hang.

  • SSH sign-in: the existing parent-made-account test now also drives forgeSshSession (src/tui/ssh.ts, since there is no src/tty.ts) with that account's key. It asserts the terminal screen shows alice.
  • Failing without the code:

- SSH test: it fails when identityFor ignores the key. - Cap tests: I swapped readCapped for an uncapped res.text() and the register test hung until I killed it (timeout), so it fails, but not with an assertion. I did not run the token test against that mutation.

Left out: the check on /oauth/jwks was already covered and is untouched.

To try it: bun test test/forge-signin.test.ts.

Closes #2289

commented

This adds tests only, in test/forge-signin.test.ts; no source file changed. The type check is clean and the file's 18 tests pass.

  • Byte caps: two new tests cover the parent's /oauth/register and /oauth/token answers.

- What each asserts: the parent answers with a body that never ends, /signin/parent or the callback returns 502, and only a few chunks are pulled (fewer than 100 against the 16 KiB cap). The register test also checks that no client was stored. The token test also checks that no session cookie was set. - Test setup: the parent is a stub on globalThis.fetch for one fake parent address, restored afterwards. A real streaming server made the run hang.

  • SSH sign-in: the existing parent-made-account test now also drives forgeSshSession (src/tui/ssh.ts, since there is no src/tty.ts) with that account's key. It asserts the terminal screen shows alice.
  • Failing without the code:

- SSH test: it fails when identityFor ignores the key. - Cap tests: I swapped readCapped for an uncapped res.text() and the register test hung until I killed it (timeout), so it fails, but not with an assertion. I did not run the token test against that mutation.

Left out: the check on /oauth/jwks was already covered and is untouched.

To try it: bun test test/forge-signin.test.ts.

Approved

Tests only, no source changed; test/forge-signin.test.ts passes here (16 tests). The register and token byte-cap tests assert a 502, no stored client, no session cookie, and that fewer than 100 chunks are pulled from an endless body. The SSH test drives forgeSshSession with the parent-made account key and asserts the screen shows the account name. The change fits the trust pillar and adds no dependency. Two things I would do next: (1) Replace await Bun.sleep(300) in the SSH test with a poll on screen containing "alice" with a deadline. A fixed sleep is slow when the screen is ready and flaky on a loaded CI machine. (2) The cap tests fail by hanging rather than by assertion if the cap is removed, as the author noted. Add an explicit timeout, or abort the stub body after a few hundred chunks, so a regression gives a clear red failure. The token test was also not run against that mutation.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs