gunk-dev/the-valley

web-push-e2e.nix

sourcedfb348e147ebmain's published tip history
3.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#
50# The check runs inside the Nix build sandbox as a single user. The
51# separation between the receiver's user and valley-web's user is
52# checked by module-eval and web-image.
53{
54 pkgs,
55 packages,
56 ...
57}:
58{
59 web-push-e2e = pkgs.runCommand "valley-web-push-e2e" {
60 nativeBuildInputs = [
61 pkgs.git
62 pkgs.cue
63 pkgs.curl
64 pkgs.jq
65 pkgs.util-linux
66 packages.valley-script
67 packages.valley-web-publish
68 packages.valley-web-receive
69 packages.valley-web
70 ];
71 schema = ../../schema/valley.cue;
72 readSchema = ../../schema/read.cue;
73 } (builtins.readFile ./web-push-e2e.sh);
74}