gunk-dev/the-valley

web-push-e2e.nix

source535d69c9a69emain's published tip history
3.3 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.
16# The pages say when the policy was last checked, and a pass with
17# nothing changed sends no content but a newly signed authorization,
18# whose later check the pages show, while export.json keeps its
19# bytes. A replayed authorization, a forged one, and a manifest of the
20# first protocol are refused, and valley-web refuses the directory the
21# first store layout took as its state.
22# 2. An upload with a wrong token fails as unauthenticated while
23# valley-web continues serving the previous export.
24# 3. Withdrawing a project's read grant removes the project on the
25# next pass. A --policy-only pass withdraws a project while a
26# content upload is stalled on the receiver's activation lock: the
27# next request to valley-web, not restarted, no longer serves it; the
28# stalled upload, whose export still holds the project, activates
29# later and restores nothing; the receiver deletes the project's
30# repository, and the active export.json keeps its bytes. Removing
31# the stored authorization serves no project. Granting the project
32# again sends its bundle again.
33# 4. Both servers preserve the active export across a restart.
34# 5. Read links: issued only to a principal who may read a project,
35# carried to the edge as bindings, and revoked by the next pass. A
36# revoke does not wait for a pass checking the policy. It waits for
37# a pass paused holding the links lock, and the pass after it signs
38# no binding for the revoked link. A host
39# restore restores the links as they were at the backup, and
40# revoke --all then cuts every link off.
41# 6. When the receiver is stopped, valley-web continues serving, a
42# pass fails because it cannot send its authorization, and the next
43# pass after the receiver restarts signs a new authorization, with a
44# later sequence, that applies the withdrawal.
45#
46# The check runs inside the Nix build sandbox as a single user. The
47# separation between the receiver's user and valley-web's user is
48# checked by module-eval and web-image.
49{
50 pkgs,
51 packages,
52 ...
53}:
54{
55 web-push-e2e = pkgs.runCommand "valley-web-push-e2e" {
56 nativeBuildInputs = [
57 pkgs.git
58 pkgs.cue
59 pkgs.curl
60 pkgs.jq
61 pkgs.util-linux
62 packages.valley-script
63 packages.valley-web-publish
64 packages.valley-web-receive
65 packages.valley-web
66 ];
67 schema = ../../schema/valley.cue;
68 readSchema = ../../schema/read.cue;
69 } (builtins.readFile ./web-push-e2e.sh);
70}