gunk-dev/the-valley

web-reader-browser-e2e.nix

source60ad80d5a5a5main's published tip history
2.5 KiB
1# The reader page in a real browser, in the Nix build sandbox and no VM:
2# the packaged valley-web behind a TLS proxy, and headless Chromium,
3# driven over its automation pipe (TestBrowser, in
4# web/cmd/valley-web/browser_test.go). Chromium runs with its own sandbox
5# and three flags: --headless=new, a temporary --user-data-dir, and
6# --remote-debugging-pipe. It trusts the proxy's certificate through a
7# test CA that certutil adds to the profile's certificate database; no
8# flag turns off a certificate check or any of the browser's security.
9# fontconfig gives it the DejaVu fonts to shape the pages' text with.
10# One browser runs, in about 2 GiB of memory; the closure holds Chromium,
11# so the check is slow though it boots no machine.
12#
13# It holds the browser engine alone: loading the reader page takes the
14# link out of the address bar and sends no redemption; the page's policy
15# runs its script and lets it fetch this origin, and blocks a script put
16# in the page; one click redeems the link once, the browser keeps the
17# __Host- cookie, Secure, HttpOnly and SameSite=Lax, out of the page's
18# reach, and the page follows /, which lands the reader, whose view holds
19# app alone, on app's tree. Then the proxy spoils two answers to a
20# switch to another link: a redemption answered 502 with the new
21# session's cookie, and one whose answer it drops. Each time the page
22# says it cannot tell whether the link was used. The first retry finds
23# this link's session at /-/session and lands on app's tree with no
24# second sign-out; the second finds no session, signs no one out, and is
25# told the link cannot be used. HTTP contracts, isolation, archives,
26# revocation, logs and permissions are the unit, binary, module and
27# image checks'.
28{
29 pkgs,
30 lib,
31 packages,
32 ...
33}:
34{
35 web-reader-browser-e2e = packages.valley-web.unit.overrideAttrs (prev: {
36 pname = "valley-web-reader-browser-e2e";
37 subPackages = [ "cmd/valley-web" ];
38 checkFlags = [ "-run=^TestBrowser$" ];
39 nativeCheckInputs = prev.nativeCheckInputs ++ [
40 pkgs.chromium
41 pkgs.nss.tools
42 ];
43 # Chromium shapes the pages' text with a font fontconfig finds; with
44 # none, a text-heavy page can crash its renderer.
45 FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [ pkgs.dejavu_fonts ]; };
46 preCheck = ''
47 export VALLEY_TEST_TOOLS=required
48 export VALLEY_WEB=${lib.getExe packages.valley-web}
49 export VALLEY_WEB_CHROMIUM=${lib.getExe pkgs.chromium}
50 '';
51 postCheck = "";
52 });
53}