summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2022-04-06 10:18:27 +0200
committerLubomir Rintel <lkundrak@v3.sk>2022-04-19 14:27:22 +0200
commit97857dbacdbe60580938fd8fdb050a298ba6021e (patch)
treeed69aaf257bc41a9b500fb22de2b497242b888ae
parente733357c9159ff7461717b79d5114fc9cca5388a (diff)
downloadNetworkManager-lr/nmcli-offline.tar.gz
client/test: add test for --offline behaviorlr/nmcli-offline
Currently, only "add" and negative cases are tested. Testing "modify" would require an ability to provide input. Perhaps at some later point.
-rw-r--r--Makefile.am1
-rw-r--r--src/tests/client/test-client.check-on-disk/test_offline.expected137
-rwxr-xr-xsrc/tests/client/test-client.py91
3 files changed, 229 insertions, 0 deletions
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,
+ )
+
###############################################################################