about summary refs log tree commit diff
path: root/nixos/tests/xmpp
diff options
context:
space:
mode:
authorIzorkin <izorkin@elven.pw>2019-06-15 12:41:50 +0300
committerIzorkin <izorkin@elven.pw>2019-08-20 10:24:48 +0300
commite328ea9c11cd4316428db385c43ede2a8b8aa874 (patch)
tree8d0b98768e782d627a25e69433155bc289b4a9d2 /nixos/tests/xmpp
parent691da63cbaf24fd3ef01a32195fa7f88d2546861 (diff)
nixos/tests/prosody: checking work prosody through local network
Diffstat (limited to 'nixos/tests/xmpp')
-rw-r--r--nixos/tests/xmpp/prosody.nix52
1 files changed, 30 insertions, 22 deletions
diff --git a/nixos/tests/xmpp/prosody.nix b/nixos/tests/xmpp/prosody.nix
index 3241cee79c9ae..8331c7b6d3310 100644
--- a/nixos/tests/xmpp/prosody.nix
+++ b/nixos/tests/xmpp/prosody.nix
@@ -1,38 +1,46 @@
 import ../make-test.nix {
   name = "prosody";
 
-  machine = { pkgs, ... }: {
-    services.prosody = {
-      enable = true;
-      # TODO: use a self-signed certificate
-      c2sRequireEncryption = false;
-      extraConfig = ''
-        storage = "sql"
+  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
       '';
-      virtualHosts.test = {
-        domain = "example.com";
-        enabled = true;
+      networking.firewall.enable = false;
+      services.prosody = {
+        enable = true;
+        # TODO: use a self-signed certificate
+        c2sRequireEncryption = false;
+        extraConfig = ''
+          storage = "sql"
+        '';
+        virtualHosts.test = {
+          domain = "example.com";
+          enabled = true;
+        };
       };
     };
-    environment.systemPackages = [
-      (pkgs.callPackage ./xmpp-sendmessage.nix {})
-    ];
   };
 
-  testScript = ''
-    $machine->waitForUnit('prosody.service');
-    $machine->succeed('prosodyctl status') =~ /Prosody is running/;
+  testScript = { nodes, ... }: ''
+    $server->waitForUnit('prosody.service');
+    $server->succeed('prosodyctl status') =~ /Prosody is running/;
 
     # set password to 'nothunter2' (it's asked twice)
-    $machine->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com');
+    $server->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com');
     # set password to 'y'
-    $machine->succeed('yes | prosodyctl adduser azurediamond@example.com');
+    $server->succeed('yes | prosodyctl adduser azurediamond@example.com');
     # correct password to 'hunter2'
-    $machine->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com');
+    $server->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com');
 
-    $machine->succeed("send-message");
+    $client->succeed("send-message");
 
-    $machine->succeed('prosodyctl deluser cthon98@example.com');
-    $machine->succeed('prosodyctl deluser azurediamond@example.com');
+    $server->succeed('prosodyctl deluser cthon98@example.com');
+    $server->succeed('prosodyctl deluser azurediamond@example.com');
   '';
 }