2019-11-09 19:35:50 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
2018-12-21 18:36:58 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
port = 3142;
|
|
|
|
username = "alice";
|
|
|
|
password = "correcthorsebatterystaple";
|
|
|
|
defaultPort = 8080;
|
|
|
|
defaultUsername = "admin";
|
|
|
|
defaultPassword = "password";
|
2022-01-02 12:00:00 +00:00
|
|
|
adminCredentialsFile = pkgs.writeText "admin-credentials" ''
|
|
|
|
ADMIN_USERNAME=${defaultUsername}
|
|
|
|
ADMIN_PASSWORD=${defaultPassword}
|
|
|
|
'';
|
|
|
|
customAdminCredentialsFile = pkgs.writeText "admin-credentials" ''
|
|
|
|
ADMIN_USERNAME=${username}
|
|
|
|
ADMIN_PASSWORD=${password}
|
|
|
|
'';
|
|
|
|
|
2018-12-21 18:36:58 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
name = "miniflux";
|
2023-04-30 15:26:17 +01:00
|
|
|
meta.maintainers = [ ];
|
2018-12-21 18:36:58 +00:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
default =
|
|
|
|
{ ... }:
|
|
|
|
{
|
2023-07-08 01:18:34 +01:00
|
|
|
security.apparmor.enable = true;
|
2022-01-02 12:00:00 +00:00
|
|
|
services.miniflux = {
|
|
|
|
enable = true;
|
|
|
|
inherit adminCredentialsFile;
|
|
|
|
};
|
2018-12-21 18:36:58 +00:00
|
|
|
};
|
|
|
|
|
2021-01-28 18:09:31 +00:00
|
|
|
withoutSudo =
|
|
|
|
{ ... }:
|
|
|
|
{
|
2023-07-08 01:18:34 +01:00
|
|
|
security.apparmor.enable = true;
|
2022-01-02 12:00:00 +00:00
|
|
|
services.miniflux = {
|
|
|
|
enable = true;
|
|
|
|
inherit adminCredentialsFile;
|
|
|
|
};
|
2021-01-28 18:09:31 +00:00
|
|
|
security.sudo.enable = false;
|
|
|
|
};
|
|
|
|
|
2018-12-21 18:36:58 +00:00
|
|
|
customized =
|
|
|
|
{ ... }:
|
|
|
|
{
|
2023-07-08 01:18:34 +01:00
|
|
|
security.apparmor.enable = true;
|
2018-12-21 18:36:58 +00:00
|
|
|
services.miniflux = {
|
|
|
|
enable = true;
|
|
|
|
config = {
|
|
|
|
CLEANUP_FREQUENCY = "48";
|
|
|
|
LISTEN_ADDR = "localhost:${toString port}";
|
|
|
|
};
|
2022-01-02 12:00:00 +00:00
|
|
|
adminCredentialsFile = customAdminCredentialsFile;
|
2018-12-21 18:36:58 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
testScript = ''
|
2019-11-09 19:35:50 +00:00
|
|
|
start_all()
|
2018-12-21 18:36:58 +00:00
|
|
|
|
2019-11-09 19:35:50 +00:00
|
|
|
default.wait_for_unit("miniflux.service")
|
|
|
|
default.wait_for_open_port(${toString defaultPort})
|
2021-06-05 14:50:58 +01:00
|
|
|
default.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep OK")
|
2019-11-09 19:35:50 +00:00
|
|
|
default.succeed(
|
2021-06-05 14:50:58 +01:00
|
|
|
"curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep '\"is_admin\":true'"
|
2019-11-09 19:35:50 +00:00
|
|
|
)
|
2023-07-08 01:18:34 +01:00
|
|
|
default.fail('journalctl -b --no-pager --grep "^audit: .*apparmor=\\"DENIED\\""')
|
2018-12-21 18:36:58 +00:00
|
|
|
|
2021-01-28 18:09:31 +00:00
|
|
|
withoutSudo.wait_for_unit("miniflux.service")
|
|
|
|
withoutSudo.wait_for_open_port(${toString defaultPort})
|
2021-06-05 14:50:58 +01:00
|
|
|
withoutSudo.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep OK")
|
2021-01-28 18:09:31 +00:00
|
|
|
withoutSudo.succeed(
|
2021-06-05 14:50:58 +01:00
|
|
|
"curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep '\"is_admin\":true'"
|
2021-01-28 18:09:31 +00:00
|
|
|
)
|
2023-07-08 01:18:34 +01:00
|
|
|
withoutSudo.fail('journalctl -b --no-pager --grep "^audit: .*apparmor=\\"DENIED\\""')
|
2021-01-28 18:09:31 +00:00
|
|
|
|
2019-11-09 19:35:50 +00:00
|
|
|
customized.wait_for_unit("miniflux.service")
|
|
|
|
customized.wait_for_open_port(${toString port})
|
2021-06-05 14:50:58 +01:00
|
|
|
customized.succeed("curl --fail 'http://localhost:${toString port}/healthcheck' | grep OK")
|
2019-11-09 19:35:50 +00:00
|
|
|
customized.succeed(
|
2021-06-05 14:50:58 +01:00
|
|
|
"curl 'http://localhost:${toString port}/v1/me' -u '${username}:${password}' -H Content-Type:application/json | grep '\"is_admin\":true'"
|
2019-11-09 19:35:50 +00:00
|
|
|
)
|
2023-07-08 01:18:34 +01:00
|
|
|
customized.fail('journalctl -b --no-pager --grep "^audit: .*apparmor=\\"DENIED\\""')
|
2018-12-21 18:36:58 +00:00
|
|
|
'';
|
|
|
|
})
|