2020-04-20 21:27:53 +03:00
|
|
|
let
|
2021-08-15 18:12:23 +03:00
|
|
|
cert = pkgs: pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
|
2021-08-06 23:24:41 +03: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 21:27:53 +03: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 16:27:20 +03:00
|
|
|
|
2020-04-20 21:27:53 +03:00
|
|
|
prosodyctl deluser cthon98@example.com
|
|
|
|
prosodyctl deluser azurediamond@example.com
|
|
|
|
'';
|
|
|
|
in import ../make-test-python.nix {
|
|
|
|
name = "prosody";
|
2019-06-15 12:41:50 +03:00
|
|
|
nodes = {
|
2020-04-20 21:27:53 +03: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 12:41:50 +03:00
|
|
|
environment.systemPackages = [
|
2022-11-23 13:05:12 +03:00
|
|
|
(pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = "example.com"; })
|
2019-06-15 12:41:50 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
server = { config, pkgs, ... }: {
|
2020-04-20 21:27:53 +03:00
|
|
|
security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
|
|
|
|
console.keyMap = "fr-bepo";
|
2019-06-15 12:41:50 +03:00
|
|
|
networking.extraHosts = ''
|
|
|
|
${config.networking.primaryIPAddress} example.com
|
2020-04-20 21:27:53 +03:00
|
|
|
${config.networking.primaryIPAddress} conference.example.com
|
|
|
|
${config.networking.primaryIPAddress} uploads.example.com
|
2018-09-23 11:46:22 +03:00
|
|
|
'';
|
2019-06-15 12:41:50 +03:00
|
|
|
networking.firewall.enable = false;
|
2020-04-20 21:27:53 +03:00
|
|
|
environment.systemPackages = [
|
|
|
|
(createUsers pkgs)
|
|
|
|
(delUsers pkgs)
|
|
|
|
];
|
2019-06-15 12:41:50 +03:00
|
|
|
services.prosody = {
|
|
|
|
enable = true;
|
2020-04-20 21:27:53 +03:00
|
|
|
ssl.cert = "${cert pkgs}/cert.pem";
|
|
|
|
ssl.key = "${cert pkgs}/key.pem";
|
|
|
|
virtualHosts.example = {
|
2019-06-15 12:41:50 +03:00
|
|
|
domain = "example.com";
|
|
|
|
enabled = true;
|
2020-04-20 21:27:53 +03: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 12:41:50 +03:00
|
|
|
};
|
2019-04-18 00:36:07 +03:00
|
|
|
};
|
2018-03-21 16:27:20 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-06-15 12:41:50 +03:00
|
|
|
testScript = { nodes, ... }: ''
|
2022-02-18 22:19:31 +03:00
|
|
|
# Check with sqlite storage
|
2022-11-23 13:05:12 +03:00
|
|
|
start_all()
|
2019-11-24 15:04:11 +03:00
|
|
|
server.wait_for_unit("prosody.service")
|
|
|
|
server.succeed('prosodyctl status | grep "Prosody is running"')
|
2018-03-21 16:27:20 +03:00
|
|
|
|
2020-04-20 21:27:53 +03:00
|
|
|
server.succeed("create-prosody-users")
|
2021-02-11 20:46:07 +03:00
|
|
|
client.succeed("send-message")
|
2020-04-20 21:27:53 +03:00
|
|
|
server.succeed("delete-prosody-users")
|
2018-03-21 16:27:20 +03:00
|
|
|
'';
|
|
|
|
}
|