| 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 lands on /. Then the proxy spoils two answers to a |
| 19 | # switch to another link: a redemption answered 502 with the new |
| 20 | # session's cookie, and one whose answer it drops. Each time the page |
| 21 | # says it cannot tell whether the link was used. The first retry finds |
| 22 | # this link's session at /-/session and lands on / with no second |
| 23 | # sign-out; the second finds no session, signs no one out, and is told |
| 24 | # the link cannot be used. HTTP contracts, isolation, archives, |
| 25 | # revocation, logs and permissions are the unit, binary, module and |
| 26 | # image checks'. |
| 27 | { |
| 28 | pkgs, |
| 29 | lib, |
| 30 | packages, |
| 31 | ... |
| 32 | }: |
| 33 | { |
| 34 | web-reader-browser-e2e = packages.valley-web.unit.overrideAttrs (prev: { |
| 35 | pname = "valley-web-reader-browser-e2e"; |
| 36 | subPackages = [ "cmd/valley-web" ]; |
| 37 | checkFlags = [ "-run=^TestBrowser$" ]; |
| 38 | nativeCheckInputs = prev.nativeCheckInputs ++ [ |
| 39 | pkgs.chromium |
| 40 | pkgs.nss.tools |
| 41 | ]; |
| 42 | # Chromium shapes the pages' text with a font fontconfig finds; with |
| 43 | # none, a text-heavy page can crash its renderer. |
| 44 | FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [ pkgs.dejavu_fonts ]; }; |
| 45 | preCheck = '' |
| 46 | export VALLEY_TEST_TOOLS=required |
| 47 | export VALLEY_WEB=${lib.getExe packages.valley-web} |
| 48 | export VALLEY_WEB_CHROMIUM=${lib.getExe pkgs.chromium} |
| 49 | ''; |
| 50 | postCheck = ""; |
| 51 | }); |
| 52 | } |