summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2016-09-30 21:24:18 +0200
committerEelco Dolstra <edolstra@gmail.com>2016-09-30 21:24:18 +0200
commit328c2f00819d01933e6cb0aad1c5052d2fab86ea (patch)
treec1e9b49c715867f346ffcff18a03458ed9da3035
parente993506d4c3d580495087c85c901d54908e445a0 (diff)
downloadnixpkgs-328c2f00819d01933e6cb0aad1c5052d2fab86ea.tar
nixpkgs-328c2f00819d01933e6cb0aad1c5052d2fab86ea.tar.gz
nixpkgs-328c2f00819d01933e6cb0aad1c5052d2fab86ea.tar.bz2
nixpkgs-328c2f00819d01933e6cb0aad1c5052d2fab86ea.tar.lz
nixpkgs-328c2f00819d01933e6cb0aad1c5052d2fab86ea.tar.xz
nixpkgs-328c2f00819d01933e6cb0aad1c5052d2fab86ea.tar.zst
nixpkgs-328c2f00819d01933e6cb0aad1c5052d2fab86ea.zip
Add a simple test for Samba
-rw-r--r--nixos/release.nix1
-rw-r--r--nixos/tests/samba.nix48
2 files changed, 49 insertions, 0 deletions
diff --git a/nixos/release.nix b/nixos/release.nix
index 7fcff78f6b9..bff17da607f 100644
--- a/nixos/release.nix
+++ b/nixos/release.nix
@@ -284,6 +284,7 @@ in rec {
   tests.quagga = callTest tests/quagga.nix {};
   tests.quake3 = callTest tests/quake3.nix {};
   tests.runInMachine = callTest tests/run-in-machine.nix {};
+  tests.samba = callTest tests/samba.nix {};
   tests.sddm = callTest tests/sddm.nix {};
   tests.simple = callTest tests/simple.nix {};
   tests.smokeping = callTest tests/smokeping.nix {};
diff --git a/nixos/tests/samba.nix b/nixos/tests/samba.nix
new file mode 100644
index 00000000000..d6658ef0400
--- /dev/null
+++ b/nixos/tests/samba.nix
@@ -0,0 +1,48 @@
+import ./make-test.nix ({ pkgs, ... }:
+
+{
+  name = "samba";
+
+  meta.maintainers = [ pkgs.lib.maintainers.eelco ];
+
+  nodes =
+    { client =
+        { config, pkgs, ... }:
+        { fileSystems = pkgs.lib.mkVMOverride
+            { "/public" = {
+                fsType = "cifs";
+                device = "//server/public";
+                options = [ "guest" ];
+              };
+            };
+        };
+
+      server =
+        { config, pkgs, ... }:
+        { services.samba.enable = true;
+          services.samba.shares.public =
+            { path = "/public";
+              "read only" = true;
+              browseable = "yes";
+              "guest ok" = "yes";
+              comment = "Public samba share.";
+            };
+          networking.firewall.allowedTCPPorts = [ 139 445 ];
+          networking.firewall.allowedUDPPorts = [ 137 138 ];
+        };
+    };
+
+  # client# [    4.542997] mount[777]: sh: systemd-ask-password: command not found
+
+  testScript =
+    ''
+      $server->start;
+      $server->waitForUnit("samba-smbd");
+      $server->waitForUnit("samba-nmbd");
+      $server->succeed("mkdir -p /public; echo bar > /public/foo");
+
+      $client->start;
+      $client->waitForUnit("network.target");
+      $client->succeed("[[ \$(cat /public/foo) = bar ]]");
+    '';
+})