Skip to content

Commit

Permalink
nixos/soju: add tests
Browse files Browse the repository at this point in the history
For now, just try creating a user with sojuctl. Actually connecting an
irc client is pretty annoying.
  • Loading branch information
Benjamin-L committed Oct 5, 2023
1 parent d79c7f2 commit 961ec39
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Expand Up @@ -729,6 +729,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 {};
Expand Down
36 changes: 36 additions & 0 deletions nixos/tests/soju.nix
@@ -0,0 +1,36 @@
import ./make-test-python.nix ({ pkgs, lib, ... }:
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";
meta.maintainers = with lib.maintainers; [ Benjamin-L ];

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}")
'';
})

0 comments on commit 961ec39

Please sign in to comment.