diff options
author | pennae <82953136+pennae@users.noreply.github.com> | 2022-05-23 10:53:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 10:53:08 +0000 |
commit | 023e25264cb8022f93ecdff5f28c4a8762cb34ec (patch) | |
tree | 76d5ee4b005686f5e7bbae5f4e97167800ea25bf /nixos/tests | |
parent | e9bdd5fa74bcbae7d0b587bc4c12d2353fd92611 (diff) | |
parent | c1115d37ffd4f947dd110c1bfc8f1593eaa07928 (diff) |
Merge pull request #172983 from pennae/mosquitto-bind-interface
nixos/mosquitto: add bind_interface listener option, fix assertion messages
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/mosquitto.nix | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/nixos/tests/mosquitto.nix b/nixos/tests/mosquitto.nix index 36cc8e3e3d9bd..d516d3373d9f6 100644 --- a/nixos/tests/mosquitto.nix +++ b/nixos/tests/mosquitto.nix @@ -4,6 +4,7 @@ let port = 1888; tlsPort = 1889; anonPort = 1890; + bindTestPort = 1891; password = "VERY_secret"; hashedPassword = "$7$101$/WJc4Mp+I+uYE9sR$o7z9rD1EYXHPwEP5GqQj6A7k4W1yVbePlb8TqNcuOLV9WNCiDgwHOB0JHC1WCtdkssqTBduBNUnUGd6kmZvDSw=="; topic = "test/foo"; @@ -125,6 +126,10 @@ in { }; }; } + { + settings.bind_interface = "eth0"; + port = bindTestPort; + } ]; }; }; @@ -134,6 +139,8 @@ in { }; testScript = '' + import json + def mosquitto_cmd(binary, user, topic, port): return ( "mosquitto_{} " @@ -162,6 +169,27 @@ in { start_all() server.wait_for_unit("mosquitto.service") + with subtest("bind_interface"): + addrs = dict() + for iface in json.loads(server.succeed("ip -json address show")): + for addr in iface['addr_info']: + # don't want to deal with multihoming here + assert addr['local'] not in addrs + addrs[addr['local']] = (iface['ifname'], addr['family']) + + # mosquitto grabs *one* random address per type for bind_interface + (has4, has6) = (False, False) + for line in server.succeed("ss -HlptnO sport = ${toString bindTestPort}").splitlines(): + items = line.split() + if "mosquitto" not in items[5]: continue + listener = items[3].rsplit(':', maxsplit=1)[0].strip('[]') + assert listener in addrs + assert addrs[listener][0] == "eth0" + has4 |= addrs[listener][1] == 'inet' + has6 |= addrs[listener][1] == 'inet6' + assert has4 + assert has6 + with subtest("check passwords"): client1.succeed(publish("-m test", "password_store")) client1.succeed(publish("-m test", "password_file")) |