nixos/tests/tor: a minimal test

For now check that the default client config boots.

Ideas for the future:
- Expand on control via netcat
- Configure a circuit of nodes exercise various configs (e.g., check
  that a client node can access a hidden www service).  Needs setting up
  authoritative directory servers &c.
This commit is contained in:
Joachim Fasting 2018-06-18 19:59:19 +02:00
parent 0456edc275
commit b9c953eb19
No known key found for this signature in database
GPG Key ID: 5C204DF675C90294
2 changed files with 29 additions and 0 deletions

View File

@ -398,6 +398,7 @@ in rec {
tests.switchTest = callTest tests/switch-test.nix {};
tests.taskserver = callTest tests/taskserver.nix {};
tests.tomcat = callTest tests/tomcat.nix {};
tests.tor = callTest tests/tor.nix {};
tests.transmission = callTest tests/transmission.nix {};
tests.udisks2 = callTest tests/udisks2.nix {};
tests.vault = callTest tests/vault.nix {};

28
nixos/tests/tor.nix Normal file
View File

@ -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;
'';
})