summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorIzorkin <izorkin@elven.pw>2019-06-15 12:58:00 +0300
committerIzorkin <izorkin@elven.pw>2019-08-20 10:24:49 +0300
commitbb4816d41c2aa43723529ef7bcf081f845c86180 (patch)
tree4dfa3f92669f28a621ca73cbcda6cb11a06b4a56 /nixos
parente328ea9c11cd4316428db385c43ede2a8b8aa874 (diff)
downloadnixpkgs-bb4816d41c2aa43723529ef7bcf081f845c86180.tar
nixpkgs-bb4816d41c2aa43723529ef7bcf081f845c86180.tar.gz
nixpkgs-bb4816d41c2aa43723529ef7bcf081f845c86180.tar.bz2
nixpkgs-bb4816d41c2aa43723529ef7bcf081f845c86180.tar.lz
nixpkgs-bb4816d41c2aa43723529ef7bcf081f845c86180.tar.xz
nixpkgs-bb4816d41c2aa43723529ef7bcf081f845c86180.tar.zst
nixpkgs-bb4816d41c2aa43723529ef7bcf081f845c86180.zip
nixos/tests/prosodyMysql: add check work prosody with MySQL database
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/xmpp/prosody-mysql.nix69
2 files changed, 70 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index c00cf30e91e..1391a537f32 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -210,6 +210,7 @@ in
   prometheus2 = handleTest ./prometheus-2.nix {};
   prometheus-exporters = handleTest ./prometheus-exporters.nix {};
   prosody = handleTest ./xmpp/prosody.nix {};
+  prosodyMysql = handleTest ./xmpp/prosody-mysql.nix {};
   proxy = handleTest ./proxy.nix {};
   quagga = handleTest ./quagga.nix {};
   quake3 = handleTest ./quake3.nix {};
diff --git a/nixos/tests/xmpp/prosody-mysql.nix b/nixos/tests/xmpp/prosody-mysql.nix
new file mode 100644
index 00000000000..5e9dba2abe5
--- /dev/null
+++ b/nixos/tests/xmpp/prosody-mysql.nix
@@ -0,0 +1,69 @@
+import ../make-test.nix {
+  name = "prosody-mysql";
+
+  nodes = {
+    client = { nodes, pkgs, ... }: {
+      environment.systemPackages = [
+        (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = nodes.server.config.networking.primaryIPAddress; })
+      ];
+    };
+    server = { config, pkgs, ... }: {
+      networking.extraHosts = ''
+        ${config.networking.primaryIPAddress} example.com
+      '';
+      networking.firewall.enable = false;
+      services.prosody = {
+        enable = true;
+        # TODO: use a self-signed certificate
+        c2sRequireEncryption = false;
+        extraConfig = ''
+          storage = "sql"
+          sql = {
+            driver = "MySQL";
+            database = "prosody";
+            host = "mysql";
+            port = 3306;
+            username = "prosody";
+            password = "password123";
+          };
+        '';
+        virtualHosts.test = {
+          domain = "example.com";
+          enabled = true;
+        };
+      };
+    };
+    mysql = { config, pkgs, ... }: {
+      networking.firewall.enable = false;
+      services.mysql = {
+        enable = true;
+        initialScript = pkgs.writeText "mysql_init.sql" ''
+          CREATE DATABASE prosody;
+          CREATE USER 'prosody'@'server' IDENTIFIED BY 'password123';
+          GRANT ALL PRIVILEGES ON prosody.* TO 'prosody'@'server';
+          FLUSH PRIVILEGES;
+        '';
+        package = pkgs.mariadb;
+      };
+    };
+  };
+
+  testScript = { nodes, ... }: ''
+    $mysql->waitForUnit('mysql.service');
+    $server->waitForUnit('prosody.service');
+    $server->succeed('prosodyctl status') =~ /Prosody is running/;
+
+    # set password to 'nothunter2' (it's asked twice)
+    $server->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com');
+    # set password to 'y'
+    $server->succeed('yes | prosodyctl adduser azurediamond@example.com');
+    # correct password to 'hunter2'
+    $server->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com');
+
+    $client->succeed("send-message");
+
+    $server->succeed('prosodyctl deluser cthon98@example.com');
+    $server->succeed('prosodyctl deluser azurediamond@example.com');
+  '';
+}
+