-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos/tests/filebrowser: init test module
Signed-off-by: Christoph Heiss <[email protected]>
- Loading branch information
1 parent
3bff8be
commit 3e98a07
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'") | ||
''; | ||
}) |