2 cert = pkgs: pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
3 openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=example.com/CN=uploads.example.com/CN=conference.example.com' -days 36500
5 cp key.pem cert.pem $out
7 createUsers = pkgs: pkgs.writeScriptBin "create-prosody-users" ''
8 #!${pkgs.bash}/bin/bash
11 # Creates and set password for the 2 xmpp test users.
13 # Doing that in a bash script instead of doing that in the test
14 # script allow us to easily provision the users when running that
17 prosodyctl register cthon98 example.com nothunter2
18 prosodyctl register azurediamond example.com hunter2
20 delUsers = pkgs: pkgs.writeScriptBin "delete-prosody-users" ''
21 #!${pkgs.bash}/bin/bash
24 # Deletes the test users.
26 # Doing that in a bash script instead of doing that in the test
27 # script allow us to easily provision the users when running that
30 prosodyctl deluser cthon98@example.com
31 prosodyctl deluser azurediamond@example.com
33 in import ../make-test-python.nix {
36 client = { nodes, pkgs, config, ... }: {
37 security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
38 console.keyMap = "fr-bepo";
39 networking.extraHosts = ''
40 ${nodes.server.config.networking.primaryIPAddress} example.com
41 ${nodes.server.config.networking.primaryIPAddress} conference.example.com
42 ${nodes.server.config.networking.primaryIPAddress} uploads.example.com
44 environment.systemPackages = [
45 (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = "example.com"; })
48 server = { config, pkgs, ... }: {
49 security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
50 console.keyMap = "fr-bepo";
51 networking.extraHosts = ''
52 ${config.networking.primaryIPAddress} example.com
53 ${config.networking.primaryIPAddress} conference.example.com
54 ${config.networking.primaryIPAddress} uploads.example.com
56 networking.firewall.enable = false;
57 environment.systemPackages = [
63 ssl.cert = "${cert pkgs}/cert.pem";
64 ssl.key = "${cert pkgs}/key.pem";
65 virtualHosts.example = {
66 domain = "example.com";
68 ssl.cert = "${cert pkgs}/cert.pem";
69 ssl.key = "${cert pkgs}/key.pem";
73 domain = "conference.example.com";
77 domain = "uploads.example.com";
83 testScript = { nodes, ... }: ''
84 # Check with sqlite storage
86 server.wait_for_unit("prosody.service")
87 server.succeed('prosodyctl status | grep "Prosody is running"')
89 server.succeed("create-prosody-users")
90 client.succeed("send-message")
91 server.succeed("delete-prosody-users")