2020-04-20 18:27:53 +00:00
|
|
|
let
|
2021-08-15 15:12:23 +00:00
|
|
|
cert = pkgs: pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
|
2021-08-06 20:24:41 +00:00
|
|
|
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
|
2020-04-20 18:27:53 +00:00
|
|
|
mkdir -p $out
|
|
|
|
cp key.pem cert.pem $out
|
|
|
|
'';
|
|
|
|
createUsers = pkgs: pkgs.writeScriptBin "create-prosody-users" ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Creates and set password for the 2 xmpp test users.
|
|
|
|
#
|
|
|
|
# Doing that in a bash script instead of doing that in the test
|
|
|
|
# script allow us to easily provision the users when running that
|
|
|
|
# test interactively.
|
|
|
|
|
|
|
|
prosodyctl register cthon98 example.com nothunter2
|
|
|
|
prosodyctl register azurediamond example.com hunter2
|
|
|
|
'';
|
|
|
|
delUsers = pkgs: pkgs.writeScriptBin "delete-prosody-users" ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Deletes the test users.
|
|
|
|
#
|
|
|
|
# Doing that in a bash script instead of doing that in the test
|
|
|
|
# script allow us to easily provision the users when running that
|
|
|
|
# test interactively.
|
2018-03-21 13:27:20 +00:00
|
|
|
|
2020-04-20 18:27:53 +00:00
|
|
|
prosodyctl deluser cthon98@example.com
|
|
|
|
prosodyctl deluser azurediamond@example.com
|
|
|
|
'';
|
|
|
|
in import ../make-test-python.nix {
|
|
|
|
name = "prosody";
|
2019-06-15 09:41:50 +00:00
|
|
|
nodes = {
|
2020-04-20 18:27:53 +00:00
|
|
|
client = { nodes, pkgs, config, ... }: {
|
|
|
|
security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
|
|
|
|
console.keyMap = "fr-bepo";
|
|
|
|
networking.extraHosts = ''
|
|
|
|
${nodes.server.config.networking.primaryIPAddress} example.com
|
|
|
|
${nodes.server.config.networking.primaryIPAddress} conference.example.com
|
|
|
|
${nodes.server.config.networking.primaryIPAddress} uploads.example.com
|
|
|
|
'';
|
2019-06-15 09:41:50 +00:00
|
|
|
environment.systemPackages = [
|
2022-11-23 10:05:12 +00:00
|
|
|
(pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = "example.com"; })
|
2019-06-15 09:41:50 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
server = { config, pkgs, ... }: {
|
2020-04-20 18:27:53 +00:00
|
|
|
security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
|
|
|
|
console.keyMap = "fr-bepo";
|
2019-06-15 09:41:50 +00:00
|
|
|
networking.extraHosts = ''
|
|
|
|
${config.networking.primaryIPAddress} example.com
|
2020-04-20 18:27:53 +00:00
|
|
|
${config.networking.primaryIPAddress} conference.example.com
|
|
|
|
${config.networking.primaryIPAddress} uploads.example.com
|
2018-09-23 08:46:22 +00:00
|
|
|
'';
|
2019-06-15 09:41:50 +00:00
|
|
|
networking.firewall.enable = false;
|
2020-04-20 18:27:53 +00:00
|
|
|
environment.systemPackages = [
|
|
|
|
(createUsers pkgs)
|
|
|
|
(delUsers pkgs)
|
|
|
|
];
|
2019-06-15 09:41:50 +00:00
|
|
|
services.prosody = {
|
|
|
|
enable = true;
|
2020-04-20 18:27:53 +00:00
|
|
|
ssl.cert = "${cert pkgs}/cert.pem";
|
|
|
|
ssl.key = "${cert pkgs}/key.pem";
|
|
|
|
virtualHosts.example = {
|
2019-06-15 09:41:50 +00:00
|
|
|
domain = "example.com";
|
|
|
|
enabled = true;
|
2020-04-20 18:27:53 +00:00
|
|
|
ssl.cert = "${cert pkgs}/cert.pem";
|
|
|
|
ssl.key = "${cert pkgs}/key.pem";
|
|
|
|
};
|
|
|
|
muc = [
|
|
|
|
{
|
|
|
|
domain = "conference.example.com";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
uploadHttp = {
|
|
|
|
domain = "uploads.example.com";
|
2019-06-15 09:41:50 +00:00
|
|
|
};
|
2019-04-17 21:36:07 +00:00
|
|
|
};
|
2018-03-21 13:27:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-06-15 09:41:50 +00:00
|
|
|
testScript = { nodes, ... }: ''
|
2022-02-18 19:19:31 +00:00
|
|
|
# Check with sqlite storage
|
2022-11-23 10:05:12 +00:00
|
|
|
start_all()
|
2019-11-24 12:04:11 +00:00
|
|
|
server.wait_for_unit("prosody.service")
|
|
|
|
server.succeed('prosodyctl status | grep "Prosody is running"')
|
2018-03-21 13:27:20 +00:00
|
|
|
|
2020-04-20 18:27:53 +00:00
|
|
|
server.succeed("create-prosody-users")
|
2021-02-11 17:46:07 +00:00
|
|
|
client.succeed("send-message")
|
2020-04-20 18:27:53 +00:00
|
|
|
server.succeed("delete-prosody-users")
|
2018-03-21 13:27:20 +00:00
|
|
|
'';
|
|
|
|
}
|