summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorJulien Moutinho <julm+nixpkgs@sourcephile.fr>2020-07-22 10:34:57 +0200
committerJulien Moutinho <julm+nixpkgs@sourcephile.fr>2021-03-08 01:34:32 +0100
commitbe6463cd9d7bbdd6e9cde0660c7bdb98e71befe8 (patch)
tree22445529c87f5c5f9763eb3797df8767fa39f753 /nixos/tests
parent2ec9a72b806b977e4d6a1321a9a7d5ea6a3990f5 (diff)
downloadnixpkgs-be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8.tar
nixpkgs-be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8.tar.gz
nixpkgs-be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8.tar.bz2
nixpkgs-be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8.tar.lz
nixpkgs-be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8.tar.xz
nixpkgs-be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8.tar.zst
nixpkgs-be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8.zip
nixos/croc: init
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/croc.nix51
2 files changed, 52 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index c31a20e5408..c9b817ec069 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -82,6 +82,7 @@ in
   couchdb = handleTest ./couchdb.nix {};
   cri-o = handleTestOn ["x86_64-linux"] ./cri-o.nix {};
   custom-ca = handleTest ./custom-ca.nix {};
+  croc = handleTest ./croc.nix {};
   deluge = handleTest ./deluge.nix {};
   dhparams = handleTest ./dhparams.nix {};
   dnscrypt-proxy2 = handleTestOn ["x86_64-linux"] ./dnscrypt-proxy2.nix {};
diff --git a/nixos/tests/croc.nix b/nixos/tests/croc.nix
new file mode 100644
index 00000000000..c1b6fc7232d
--- /dev/null
+++ b/nixos/tests/croc.nix
@@ -0,0 +1,51 @@
+import ./make-test-python.nix ({ pkgs, ... }:
+let
+  client = { pkgs, ... }: {
+    environment.systemPackages = [ pkgs.croc ];
+  };
+  pass = pkgs.writeText "pass" "PassRelay";
+in {
+  name = "croc";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ hax404 julm ];
+  };
+
+  nodes = {
+    relay = {
+      services.croc = {
+        enable = true;
+        pass = pass;
+        openFirewall = true;
+      };
+    };
+    sender = client;
+    receiver = client;
+  };
+
+  testScript = ''
+    start_all()
+
+    # wait until relay is up
+    relay.wait_for_unit("croc")
+    relay.wait_for_open_port(9009)
+    relay.wait_for_open_port(9010)
+    relay.wait_for_open_port(9011)
+    relay.wait_for_open_port(9012)
+    relay.wait_for_open_port(9013)
+
+    # generate testfiles and send them
+    sender.wait_for_unit("multi-user.target")
+    sender.execute("echo Hello World > testfile01.txt")
+    sender.execute("echo Hello Earth > testfile02.txt")
+    sender.execute(
+        "croc --pass ${pass} --relay relay send --code topSecret testfile01.txt testfile02.txt &"
+    )
+
+    # receive the testfiles and check them
+    receiver.succeed(
+        "croc --pass ${pass} --yes --relay relay topSecret"
+    )
+    assert "Hello World" in receiver.succeed("cat testfile01.txt")
+    assert "Hello Earth" in receiver.succeed("cat testfile02.txt")
+  '';
+})