From 90b5a26aa0256d2ccab4a798721875c2d1b11c5a Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Sun, 1 Oct 2023 17:56:37 -0700 Subject: [PATCH] nixos/soju: add tests For now, just try creating a user with sojuctl. Actually connecting an irc client is pretty annoying. --- nixos/tests/all-tests.nix | 1 + nixos/tests/soju.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 nixos/tests/soju.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 92389fdad55aa36..0626d17cb828560 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -728,6 +728,7 @@ in { snipe-it = runTest ./web-apps/snipe-it.nix; soapui = handleTest ./soapui.nix {}; sogo = handleTest ./sogo.nix {}; + soju = handleTest ./soju.nix {}; solanum = handleTest ./solanum.nix {}; sonarr = handleTest ./sonarr.nix {}; sourcehut = handleTest ./sourcehut.nix {}; diff --git a/nixos/tests/soju.nix b/nixos/tests/soju.nix new file mode 100644 index 000000000000000..8a432ccebd98640 --- /dev/null +++ b/nixos/tests/soju.nix @@ -0,0 +1,35 @@ +import ./make-test-python.nix ({ pkgs, ... }: +let + domain = "soju.localdomain"; + user = "testuser"; + pass = "hunter2"; + + tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } '' + openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 36500 \ + -subj '/CN=${domain}' -extensions v3_req \ + -addext 'subjectAltName = DNS:*.${domain}' + install -D -t $out key.pem cert.pem + ''; +in +{ + name = "soju"; + + nodes.machine = { ... }: { + services.soju = { + enable = true; + adminSocket.enable = true; + hostName = domain; + tlsCertificate = "${tls-cert}/cert.pem"; + tlsCertificateKey = "${tls-cert}/key.pem"; + }; + }; + + testScript = '' + start_all() + + machine.wait_for_unit("soju") + machine.wait_for_file("/run/soju/admin") + + machine.succeed("sojuctl user create -username ${user} -password ${pass}") + ''; +})