gunk-dev/the-valley

web-push-e2e.nix

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