2020-03-30 12:30:05 +01:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }: {
|
|
|
|
name = "magic-wormhole-mailbox-server";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2020-03-30 12:30:05 +01:00
|
|
|
maintainers = [ mmahut ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
server = { ... }: {
|
|
|
|
networking.firewall.allowedTCPPorts = [ 4000 ];
|
|
|
|
services.magic-wormhole-mailbox-server.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
client_alice = { ... }: {
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
environment.systemPackages = [ pkgs.magic-wormhole ];
|
|
|
|
};
|
|
|
|
|
|
|
|
client_bob = { ... }: {
|
|
|
|
environment.systemPackages = [ pkgs.magic-wormhole ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
|
|
|
|
# Start the wormhole relay server
|
|
|
|
server.wait_for_unit("magic-wormhole-mailbox-server.service")
|
|
|
|
server.wait_for_open_port(4000)
|
|
|
|
|
|
|
|
# Create a secret file and send it to Bob
|
|
|
|
client_alice.succeed("echo mysecret > secretfile")
|
2021-11-05 00:43:22 +00:00
|
|
|
client_alice.succeed("wormhole --relay-url=ws://server:4000/v1 send -0 secretfile >&2 &")
|
2020-03-30 12:30:05 +01:00
|
|
|
|
|
|
|
# Retrieve a secret file from Alice and check its content
|
|
|
|
client_bob.succeed("wormhole --relay-url=ws://server:4000/v1 receive -0 --accept-file")
|
|
|
|
client_bob.succeed("grep mysecret secretfile")
|
|
|
|
'';
|
|
|
|
})
|