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 {
34 name = "prosody-mysql";
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 = nodes.server.config.networking.primaryIPAddress; })
48 server = { config, pkgs, ... }: {
51 prosody = super.prosody.override {
52 withExtraLuaPackages = p: [ p.luadbi-mysql ];
56 security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
57 console.keyMap = "fr-bepo";
58 networking.extraHosts = ''
59 ${config.networking.primaryIPAddress} example.com
60 ${config.networking.primaryIPAddress} conference.example.com
61 ${config.networking.primaryIPAddress} uploads.example.com
63 networking.firewall.enable = false;
64 environment.systemPackages = [
70 ssl.cert = "${cert pkgs}/cert.pem";
71 ssl.key = "${cert pkgs}/key.pem";
72 virtualHosts.example = {
73 domain = "example.com";
75 ssl.cert = "${cert pkgs}/cert.pem";
76 ssl.key = "${cert pkgs}/key.pem";
80 domain = "conference.example.com";
84 domain = "uploads.example.com";
94 password = "password123";
99 mysql = { config, pkgs, ... }: {
100 networking.firewall.enable = false;
103 initialScript = pkgs.writeText "mysql_init.sql" ''
104 CREATE DATABASE prosody;
105 CREATE USER 'prosody'@'server' IDENTIFIED BY 'password123';
106 GRANT ALL PRIVILEGES ON prosody.* TO 'prosody'@'server';
109 package = pkgs.mariadb;
114 testScript = { nodes, ... }: ''
115 # Check with mysql storage
116 mysql.wait_for_unit("mysql.service")
117 server.wait_for_unit("prosody.service")
118 server.succeed('prosodyctl status | grep "Prosody is running"')
120 server.succeed("create-prosody-users")
121 client.succeed("send-message")
122 server.succeed("delete-prosody-users")