gunk-dev/the-valley

web-push-e2e.nix

source782170038f7fmain's published tip history
4.7 KiB
1# End-to-end check for the web push path using the packaged binaries:
2# valley-web-publish, valley-web-receive, and valley-web as built and
3# wrapped by nix/packages.nix (with their pinned tools and schemas),
4# the packaged valley CLI (valley-script, unstamped so commits alone do
5# not trigger a rebuild), and git.
6#
7# The test creates a valley instance that grants anyone read access to
8# two projects in one group. It verifies that:
9# 1. valley-web-publish sends an authorization and uploads both
10# projects to valley-web-receive, which makes the store's descriptor
11# and its v2 payload directory, and valley-web serves them at their
12# group URLs and redirects a short alias and a former name with 308.
13# A project's Markdown README renders with an id on its heading and
14# its relative link rewritten to the target's page at the same
15# commit. Every response, a page, a redirect, an archive and a 404,
16# for GET and HEAD, is Cache-Control: private, no-store with Vary:
17# Cookie and no ETag, is never answered 304, and carries its route's
18# policy: the knots page's admits its script by its hash, every
19# other route's admits no script, and none lets a script connect.
20# The pages say when the policy was last checked, and a pass with
21# nothing changed sends no content but a newly signed authorization,
22# whose later check the pages show, while export.json keeps its
23# bytes. A replayed authorization, a forged one, and a manifest of the
24# first protocol are refused, and valley-web refuses the directory the
25# first store layout took as its state.
26# 2. An upload with a wrong token fails as unauthenticated while
27# valley-web continues serving the previous export.
28# 3. Withdrawing a project's read grant removes the project on the
29# next pass. A --policy-only pass withdraws a project while a
30# content upload is stalled on the receiver's activation lock: the
31# next request to valley-web, not restarted, no longer serves it; the
32# stalled upload, whose export still holds the project, activates
33# later and restores nothing; the receiver deletes the project's
34# repository, and the active export.json keeps its bytes. Removing
35# the stored authorization serves no project. Granting the project
36# again sends its bundle again.
37# 4. Both servers preserve the active export across a restart.
38# 5. Read links: issued only to a principal who may read a project,
39# carried to the edge as bindings, and revoked by the next pass. A
40# revoke does not wait for a pass checking the policy. It waits for
41# a pass paused holding the links lock, and the pass after it signs
42# no binding for the revoked link. A host
43# restore restores the links as they were at the backup, and
44# revoke --all then cuts every link off.
45# 6. When the receiver is stopped, valley-web continues serving, a
46# pass fails because it cannot send its authorization, and the next
47# pass after the receiver restarts signs a new authorization, with a
48# later sequence, that applies the withdrawal.
49# 7. Readers sign in at the origin valley-web is given, with its browser
50# state in a directory the test makes for it. valley-web started
51# before the receiver made its store exits, and one started under
52# an authorization that binds no link makes an empty state. A link
53# the host issues redeems once, into a session renewed on a
54# redirect, a 404, a page and an archive, whose bytes match
55# anyone's download; of eight concurrent redemptions of one link one
56# wins; the session survives both servers' restarts, ends at logout,
57# and ends at the pass that delivers its link's revocation; a second
58# valley-web over the same browser state refuses to start. A lost
59# state is not made again while a link is bound, with redemption and
60# cookies answered 503 and anyone served, until every link is
61# revoked and a pass delivers that; an unreadable state is kept as it
62# is until the operator removes it. No log, no browser state and no
63# host state holds a link's secret or a session's token.
64#
65# The check runs inside the Nix build sandbox as a single user. The
66# separation between the receiver's user and valley-web's user is
67# checked by module-eval and web-image.
68{
69 pkgs,
70 packages,
71 ...
72}:
73{
74 web-push-e2e = pkgs.runCommand "valley-web-push-e2e" {
75 nativeBuildInputs = [
76 pkgs.git
77 pkgs.cue
78 pkgs.curl
79 pkgs.jq
80 pkgs.util-linux
81 packages.valley-script
82 packages.valley-web-publish
83 packages.valley-web-receive
84 packages.valley-web
85 ];
86 schema = ../../schema/valley.cue;
87 readSchema = ../../schema/read.cue;
88 } (builtins.readFile ./web-push-e2e.sh);
89}