python312Packages.homematicip: 1.1.2 -> 1.1.3 (#356780)
[NixPkgs.git] / nixos / tests / turn-rs.nix
blob750a141c224a3bc216ed682969ea924609c40897
1 import ./make-test-python.nix (
2   { pkgs, ... }:
3   {
4     name = "turn-rs";
6     nodes = {
7       server = {
8         virtualisation.vlans = [ 1 ];
10         networking = {
11           useNetworkd = true;
12           useDHCP = false;
13           firewall.enable = false;
14         };
16         systemd.network.networks."01-eth1" = {
17           name = "eth1";
18           networkConfig.Address = "10.0.0.1/24";
19         };
21         services.turn-rs = {
22           enable = true;
23           secretFile = pkgs.writeText "secret" ''
24             USER_1_CREDS="foobar"
25           '';
26           settings = {
27             turn = {
28               realm = "localhost";
29               interfaces = [
30                 {
31                   transport = "udp";
32                   bind = "127.0.0.1:3478";
33                   external = "127.0.0.1:3478";
34                 }
35                 {
36                   transport = "tcp";
37                   bind = "127.0.0.1:3478";
38                   external = "127.0.0.1:3478";
39                 }
40               ];
41             };
43             auth.static_credentials.user1 = "$USER_1_CREDS";
44           };
45         };
46       };
47     };
49     testScript = # python
50       ''
51         import json
53         start_all()
54         server.wait_for_unit('turn-rs.service')
55         server.wait_for_open_port(3000, "127.0.0.1")
57         info = server.succeed('curl http://localhost:3000/info')
58         jsonInfo = json.loads(info)
59         assert len(jsonInfo['interfaces']) == 2, f'Interfaces doesn\'t contain two entries:\n{json.dumps(jsonInfo, indent=2)}'
61         config = server.succeed('cat /run/turn-rs/config.toml')
62         assert 'foobar' in config, f'Secrets are not properly injected:\n{config}'
63       '';
64   }