1import ./make-test-python.nix (
2 { lib, ... }:
3
4 {
5 name = "pocket-id";
6 meta.maintainers = with lib.maintainers; [
7 gepbird
8 ymstnt
9 ];
10
11 nodes = {
12 machine =
13 { ... }:
14 {
15 services.pocket-id = {
16 enable = true;
17 settings = {
18 PORT = 10001;
19 INTERNAL_BACKEND_URL = "http://localhost:10002";
20 BACKEND_PORT = 10002;
21 };
22 };
23 };
24 };
25
26 testScript =
27 { nodes, ... }:
28 let
29 inherit (nodes.machine.services.pocket-id) settings;
30 inherit (builtins) toString;
31 in
32 ''
33 machine.wait_for_unit("pocket-id-backend.service")
34 machine.wait_for_open_port(${toString settings.BACKEND_PORT})
35 machine.wait_for_unit("pocket-id-frontend.service")
36 machine.wait_for_open_port(${toString settings.PORT})
37
38 backend_status = machine.succeed("curl -L -o /tmp/backend-output -w '%{http_code}' http://localhost:${toString settings.BACKEND_PORT}/api/users/me")
39 assert backend_status == "401"
40 machine.succeed("grep 'You are not signed in' /tmp/backend-output")
41
42 frontend_status = machine.succeed("curl -L -o /tmp/frontend-output -w '%{http_code}' http://localhost:${toString settings.PORT}")
43 assert frontend_status == "200"
44 machine.succeed("grep 'Sign in to Pocket ID' /tmp/frontend-output")
45 '';
46 }
47)