summary refs log tree commit diff
path: root/nixos/tests/tor.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/tests/tor.nix')
-rw-r--r--nixos/tests/tor.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/nixos/tests/tor.nix b/nixos/tests/tor.nix
new file mode 100644
index 00000000000..24d46a03897
--- /dev/null
+++ b/nixos/tests/tor.nix
@@ -0,0 +1,28 @@
+import ./make-test.nix ({ lib, ... }: with lib;
+
+rec {
+  name = "tor";
+  meta.maintainers = with maintainers; [ joachifm ];
+
+  common =
+    { config, ... }:
+    { boot.kernelParams = [ "audit=0" "apparmor=0" "quiet" ];
+      networking.firewall.enable = false;
+      networking.useDHCP = false;
+    };
+
+  nodes.client =
+    { config, pkgs, ... }:
+    { imports = [ common ];
+      environment.systemPackages = with pkgs; [ netcat ];
+      services.tor.enable = true;
+      services.tor.client.enable = true;
+      services.tor.controlPort = 9051;
+    };
+
+  testScript = ''
+    $client->waitForUnit("tor.service");
+    $client->waitForOpenPort(9051);
+    $client->succeed("echo GETINFO version | nc 127.0.0.1 9051") =~ /514 Authentication required./ or die;
+  '';
+})