diff --git a/Makefile.am b/Makefile.am index 72f224fc20..b2c7e9a746 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5318,6 +5318,7 @@ EXTRA_DIST += \ src/tests/client/test-client.check-on-disk/test_002.expected \ src/tests/client/test-client.check-on-disk/test_003.expected \ src/tests/client/test-client.check-on-disk/test_004.expected \ + src/tests/client/test-client.check-on-disk/test_offline.expected \ \ src/tests/client/meson.build \ $(NULL) diff --git a/src/tests/client/test-client.check-on-disk/test_offline.expected b/src/tests/client/test-client.check-on-disk/test_offline.expected new file mode 100644 index 0000000000..1e95bfc4e6 --- /dev/null +++ b/src/tests/client/test-client.check-on-disk/test_offline.expected @@ -0,0 +1,137 @@ +size: 258 +location: src/tests/client/test-client.py:test_offline()/1 +cmd: $NMCLI g +lang: C +returncode: 1 +stderr: 136 bytes +>>> +Error: Could not create NMClient object: Key/Value pair 0, ?invalid?, in address element ?very:invalid? does not contain an equal sign. + +<<< +size: 319 +location: src/tests/client/test-client.py:test_offline()/2 +cmd: $NMCLI --offline c add type ethernet +lang: C +returncode: 0 +stdout: 169 bytes +>>> +[connection] +id=ethernet +uuid=UUID-WAS-HERE-BUT-IS-NO-MORE-SADLY +type=ethernet + +[ethernet] + +[ipv4] +method=auto + +[ipv6] +addr-gen-mode=stable-privacy +method=auto + +[proxy] + +<<< +size: 183 +location: src/tests/client/test-client.py:test_offline()/3 +cmd: $NMCLI --offline c show +lang: C +returncode: 2 +stderr: 47 bytes +>>> +Error: command doesn't support --offline mode. + +<<< +size: 178 +location: src/tests/client/test-client.py:test_offline()/4 +cmd: $NMCLI --offline g +lang: C +returncode: 2 +stderr: 47 bytes +>>> +Error: command doesn't support --offline mode. + +<<< +size: 176 +location: src/tests/client/test-client.py:test_offline()/5 +cmd: $NMCLI --offline +lang: C +returncode: 2 +stderr: 47 bytes +>>> +Error: command doesn't support --offline mode. + +<<< +size: 443 +location: src/tests/client/test-client.py:test_offline()/6 +cmd: $NMCLI --offline c add type wifi ssid lala 802-1x.eap pwd 802-1x.identity foo 802-1x.password bar +lang: C +returncode: 0 +stdout: 232 bytes +>>> +[connection] +id=wifi +uuid=UUID-WAS-HERE-BUT-IS-NO-MORE-SADLY +type=wifi + +[wifi] +mode=infrastructure +ssid=lala + +[802-1x] +eap=pwd; +identity=foo +password=bar + +[ipv4] +method=auto + +[ipv6] +addr-gen-mode=stable-privacy +method=auto + +[proxy] + +<<< +size: 481 +location: src/tests/client/test-client.py:test_offline()/7 +cmd: $NMCLI --offline c add type wifi ssid lala 802-1x.eap pwd 802-1x.identity foo 802-1x.password bar 802-1x.password-flags agent-owned +lang: C +returncode: 0 +stdout: 236 bytes +>>> +[connection] +id=wifi +uuid=UUID-WAS-HERE-BUT-IS-NO-MORE-SADLY +type=wifi + +[wifi] +mode=infrastructure +ssid=lala + +[802-1x] +eap=pwd; +identity=foo +password-flags=1 + +[ipv4] +method=auto + +[ipv6] +addr-gen-mode=stable-privacy +method=auto + +[proxy] + +<<< +size: 199 +location: src/tests/client/test-client.py:test_offline()/8 +cmd: $NMCLI --complete-args --offline conn modify ipv6.ad +lang: C +returncode: 0 +stdout: 34 bytes +>>> +ipv6.addresses +ipv6.addr-gen-mode + +<<< diff --git a/src/tests/client/test-client.py b/src/tests/client/test-client.py index 37800a39d6..2e0387a9ff 100755 --- a/src/tests/client/test-client.py +++ b/src/tests/client/test-client.py @@ -1695,6 +1695,97 @@ class TestNmcli(NmTestBase): replace_cmd=replace_uuids, ) + @nm_test_no_dbus + def test_offline(self): + + # Make sure we're not using D-Bus + no_dbus_env = { + "DBUS_SYSTEM_BUS_ADDRESS": "very:invalid", + "DBUS_SESSION_BUS_ADDRESS": "very:invalid", + } + + # This check just makes sure the above works and the + # "nmcli g" command indeed fails talking to D-Bus + self.call_nmcli( + ["g"], + extra_env=no_dbus_env, + ) + + replace_uuids = [ + ( + re.compile(b"uuid=.*"), + "uuid=UUID-WAS-HERE-BUT-IS-NO-MORE-SADLY", + ) + ] + + self.call_nmcli( + ["--offline", "c", "add", "type", "ethernet"], + extra_env=no_dbus_env, + replace_stdout=replace_uuids, + ) + + self.call_nmcli( + ["--offline", "c", "show"], + extra_env=no_dbus_env, + ) + + self.call_nmcli( + ["--offline", "g"], + extra_env=no_dbus_env, + ) + + self.call_nmcli( + ["--offline"], + extra_env=no_dbus_env, + ) + + self.call_nmcli( + [ + "--offline", + "c", + "add", + "type", + "wifi", + "ssid", + "lala", + "802-1x.eap", + "pwd", + "802-1x.identity", + "foo", + "802-1x.password", + "bar", + ], + extra_env=no_dbus_env, + replace_stdout=replace_uuids, + ) + + self.call_nmcli( + [ + "--offline", + "c", + "add", + "type", + "wifi", + "ssid", + "lala", + "802-1x.eap", + "pwd", + "802-1x.identity", + "foo", + "802-1x.password", + "bar", + "802-1x.password-flags", + "agent-owned", + ], + extra_env=no_dbus_env, + replace_stdout=replace_uuids, + ) + + self.call_nmcli( + ["--complete-args", "--offline", "conn", "modify", "ipv6.ad"], + extra_env=no_dbus_env, + ) + ###############################################################################