diff options
author | Julien Moutinho <julm+nixpkgs@sourcephile.fr> | 2020-07-22 10:34:57 +0200 |
---|---|---|
committer | Julien Moutinho <julm+nixpkgs@sourcephile.fr> | 2021-03-08 01:34:32 +0100 |
commit | be6463cd9d7bbdd6e9cde0660c7bdb98e71befe8 (patch) | |
tree | 22445529c87f5c5f9763eb3797df8767fa39f753 /nixos/tests/croc.nix | |
parent | 2ec9a72b806b977e4d6a1321a9a7d5ea6a3990f5 (diff) |
nixos/croc: init
Diffstat (limited to 'nixos/tests/croc.nix')
-rw-r--r-- | nixos/tests/croc.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/nixos/tests/croc.nix b/nixos/tests/croc.nix new file mode 100644 index 000000000000..c1b6fc7232d7 --- /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") + ''; +}) |