2 End-to-end test for Akkoma.
4 Based in part on nixos/tests/pleroma.
8 import ./make-test-python.nix ({ pkgs, package ? pkgs.akkoma, confined ? false, ... }:
10 userPassword = "4LKOrGo8SgbPm1a6NclVU5Wb";
12 provisionUser = pkgs.writers.writeBashBin "provisionUser" ''
13 set -eu -o errtrace -o pipefail
15 pleroma_ctl user new jamy jamy@nixos.test --password '${userPassword}' --moderator --admin -y
18 tlsCert = pkgs.runCommand "selfSignedCerts" {
19 nativeBuildInputs = with pkgs; [ openssl ];
23 -subj '/CN=akkoma.nixos.test/' -days 49710 \
24 -addext 'subjectAltName = DNS:akkoma.nixos.test' \
25 -keyout "$out/key.pem" -newkey ed25519 \
26 -out "$out/cert.pem" -noenc
29 sendToot = pkgs.writers.writeBashBin "sendToot" ''
30 set -eu -o errtrace -o pipefail
32 export REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt"
34 ${pkgs.toot}/bin/toot login_cli -i "akkoma.nixos.test" -e "jamy@nixos.test" -p '${userPassword}'
35 ${pkgs.toot}/bin/toot post "hello world Jamy here"
36 ${pkgs.toot}/bin/toot timeline -1 | grep -F -q "hello world Jamy here"
39 echo "y" | ${pkgs.toot}/bin/toot upload <(dd if=/dev/zero bs=1024 count=1024 status=none) \
40 | grep -F -q "https://akkoma.nixos.test:443/media"
43 checkFe = pkgs.writers.writeBashBin "checkFe" ''
44 set -eu -o errtrace -o pipefail
46 paths=( / /static/{config,styles}.json /pleroma/admin/ )
48 for path in "''${paths[@]}"; do
50 <(${pkgs.curl}/bin/curl -f -S -s -o /dev/null -w '%{response_code}' "https://akkoma.nixos.test$path") \
56 ${nodes.akkoma.networking.primaryIPAddress} akkoma.nixos.test
57 ${nodes.client.networking.primaryIPAddress} client.nixos.test
63 client = { nodes, pkgs, config, ... }: {
64 security.pki.certificateFiles = [ "${tlsCert}/cert.pem" ];
65 networking.extraHosts = hosts nodes;
68 akkoma = { nodes, pkgs, config, ... }: {
69 networking.extraHosts = hosts nodes;
70 networking.firewall.allowedTCPPorts = [ 443 ];
71 environment.systemPackages = with pkgs; [ provisionUser ];
72 systemd.services.akkoma.confinement.enable = confined;
80 name = "NixOS test Akkoma server";
81 description = "NixOS test Akkoma server";
82 email = "akkoma@nixos.test";
83 notify_email = "akkoma@nixos.test";
84 registration_open = true;
91 "Pleroma.Web.Endpoint" = {
92 url.host = "akkoma.nixos.test";
95 base_url = "https://akkoma.nixos.test:443/media/";
102 sslCertificate = "${tlsCert}/cert.pem";
103 sslCertificateKey = "${tlsCert}/key.pem";
107 services.nginx.enable = true;
108 services.postgresql.enable = true;
112 testScript = { nodes, ... }: ''
114 akkoma.wait_for_unit('akkoma-initdb.service')
115 akkoma.systemctl('restart akkoma-initdb.service') # test repeated initialisation
116 akkoma.wait_for_unit('akkoma.service')
117 akkoma.wait_for_file('/run/akkoma/socket');
118 akkoma.succeed('${provisionUser}/bin/provisionUser')
119 akkoma.wait_for_unit('nginx.service')
120 client.succeed('${sendToot}/bin/sendToot')
121 client.succeed('${checkFe}/bin/checkFe')