Skip to content

Commit

Permalink
nixos/tests/filebrowser: init test module
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Heiss <[email protected]>
  • Loading branch information
christoph-heiss committed Apr 20, 2024
1 parent 3bff8be commit 3e98a07
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ in {
fenics = handleTest ./fenics.nix {};
ferm = handleTest ./ferm.nix {};
ferretdb = handleTest ./ferretdb.nix {};
filebrowser = handleTest ./filebrowser.nix { };
filesystems-overlayfs = runTest ./filesystems-overlayfs.nix;
firefly-iii = handleTest ./firefly-iii.nix {};
firefox = handleTest ./firefox.nix { firefoxPackage = pkgs.firefox; };
Expand Down
46 changes: 46 additions & 0 deletions nixos/tests/filebrowser.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import ./make-test-python.nix ({ pkgs, lib, ... }:
let
tls-cert = pkgs.runCommand "selfSignedCerts" {
buildInputs = [ pkgs.openssl ];
} ''
mkdir -p $out
openssl req -x509 \
-subj '/CN=localhost/' -days 365 \
-addext 'subjectAltName = DNS:localhost' \
-keyout "$out/cert.key" -newkey ed25519 \
-out "$out/cert.pem" -noenc
'';
in {
name = "filebrowser";
meta.maintainers = with lib.maintainers; [ christoph-heiss ];

nodes = {
http = {
services.filebrowser = {
enable = true;
};
};
https = {
security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
services.filebrowser = {
enable = true;
tlsCertificate = "${tls-cert}/cert.pem";
tlsCertificateKey = "${tls-cert}/cert.key";
};
};
};

testScript = ''
start_all()
with subtest("check if http works"):
http.wait_for_unit("filebrowser.service")
http.wait_for_open_port(8080)
http.succeed("curl -sSf http://localhost:8080 | grep '<!doctype html>'")
with subtest("check if https works"):
https.wait_for_unit("filebrowser.service")
https.wait_for_open_port(8080)
https.succeed("curl -sSf https://localhost:8080 | grep '<!doctype html>'")
'';
})

0 comments on commit 3e98a07

Please sign in to comment.