1import ./make-test-python.nix ({ pkgs, lib, ... }:
2
3let
4 port = 3142;
5 username = "alice";
6 password = "correcthorsebatterystaple";
7 defaultPort = 8080;
8 defaultUsername = "admin";
9 defaultPassword = "password";
10 adminCredentialsFile = pkgs.writeText "admin-credentials" ''
11 ADMIN_USERNAME=${defaultUsername}
12 ADMIN_PASSWORD=${defaultPassword}
13 '';
14 customAdminCredentialsFile = pkgs.writeText "admin-credentials" ''
15 ADMIN_USERNAME=${username}
16 ADMIN_PASSWORD=${password}
17 '';
18
19in
20{
21 name = "miniflux";
22 meta.maintainers = [ ];
23
24 nodes = {
25 default =
26 { ... }:
27 {
28 services.miniflux = {
29 enable = true;
30 inherit adminCredentialsFile;
31 };
32 };
33
34 withoutSudo =
35 { ... }:
36 {
37 services.miniflux = {
38 enable = true;
39 inherit adminCredentialsFile;
40 };
41 security.sudo.enable = false;
42 };
43
44 customized =
45 { ... }:
46 {
47 services.miniflux = {
48 enable = true;
49 config = {
50 CLEANUP_FREQUENCY = "48";
51 LISTEN_ADDR = "localhost:${toString port}";
52 };
53 adminCredentialsFile = customAdminCredentialsFile;
54 };
55 };
56 };
57 testScript = ''
58 start_all()
59
60 default.wait_for_unit("miniflux.service")
61 default.wait_for_open_port(${toString defaultPort})
62 default.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep OK")
63 default.succeed(
64 "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep '\"is_admin\":true'"
65 )
66
67 withoutSudo.wait_for_unit("miniflux.service")
68 withoutSudo.wait_for_open_port(${toString defaultPort})
69 withoutSudo.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep OK")
70 withoutSudo.succeed(
71 "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep '\"is_admin\":true'"
72 )
73
74 customized.wait_for_unit("miniflux.service")
75 customized.wait_for_open_port(${toString port})
76 customized.succeed("curl --fail 'http://localhost:${toString port}/healthcheck' | grep OK")
77 customized.succeed(
78 "curl 'http://localhost:${toString port}/v1/me' -u '${username}:${password}' -H Content-Type:application/json | grep '\"is_admin\":true'"
79 )
80 '';
81})