diff options
author | Arif Ali <arif.ali@canonical.com> | 2024-04-22 09:02:46 +0100 |
---|---|---|
committer | Jake Hunsaker <jacob.r.hunsaker@gmail.com> | 2024-05-01 14:09:21 -0400 |
commit | 0a876d47196bf9738b4d14509b593583f59c7e3a (patch) | |
tree | d3393349cdc86633e8a79c566ed2a24579d3dead /tests/report_tests/plugin_tests/networking | |
parent | 782889258497025e84a28cd14834ce1d9a6dbfbd (diff) | |
download | sos-0a876d47196bf9738b4d14509b593583f59c7e3a.tar.gz |
[tests] Add some tests for netplan and juju
Signed-off-by: Arif Ali <arif.ali@canonical.com>
Diffstat (limited to 'tests/report_tests/plugin_tests/networking')
-rw-r--r-- | tests/report_tests/plugin_tests/networking/90-NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02.yaml | 25 | ||||
-rw-r--r-- | tests/report_tests/plugin_tests/networking/networking.py | 61 |
2 files changed, 86 insertions, 0 deletions
diff --git a/tests/report_tests/plugin_tests/networking/90-NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02.yaml b/tests/report_tests/plugin_tests/networking/90-NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02.yaml new file mode 100644 index 00000000..c3f9c148 --- /dev/null +++ b/tests/report_tests/plugin_tests/networking/90-NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02.yaml @@ -0,0 +1,25 @@ +network: + version: 2 + wifis: + NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02: + renderer: NetworkManager + match: + name: "wlp166s0" + dhcp4: true + access-points: + "arif-home": + auth: + key-management: "psk" + password: "awifipasswordforauth" + networkmanager: + uuid: "d377ae8e-fff5-11ee-bd96-07ef2a5f9e02" + name: "wifi-guest" + passthrough: + connection.timestamp: "1694069964" + ipv6.addr-gen-mode: "default" + ipv6.method: "disabled" + ipv6.ip6-privacy: "-1" + proxy._: "" + networkmanager: + uuid: "d377ae8e-fff5-11ee-bd96-07ef2a5f9e02" + name: "wifi-guest" diff --git a/tests/report_tests/plugin_tests/networking/networking.py b/tests/report_tests/plugin_tests/networking/networking.py new file mode 100644 index 00000000..77afe6d5 --- /dev/null +++ b/tests/report_tests/plugin_tests/networking/networking.py @@ -0,0 +1,61 @@ +# This file is part of the sos project: https://github.com/sosreport/sos +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# version 2 of the GNU General Public License. +# +# See the LICENSE file in the source distribution for further information. + +import os + +from sos_tests import StageOneReportTest, StageTwoReportTest, ubuntu_only + + +class NetworkingPluginTest(StageOneReportTest): + """ + Basic tests to ensure proper collection from the networking plugins + + :avocado: tags=stageone + """ + + sos_cmd = '-o networking' + + def test_common_files_collected(self): + self.assertFileCollected('/etc/resolv.conf') + self.assertFileCollected('/etc/hosts') + + def test_ip_addr_symlink_created(self): + self.assertFileCollected('ip_addr') + + def test_forbidden_globs_skipped(self): + self.assertFileGlobNotInArchive('/proc/net/rpc/*/channel') + self.assertFileGlobNotInArchive('/proc/net/rpc/*/flush') + + def test_netdevs_properly_iterated(self): + for dev in os.listdir('/sys/class/net'): + # some file(s) in the dir might not be real netdevs, see e.g. + # https://lwn.net/Articles/142330/ + if not dev.startswith('bonding_'): + self.assertFileGlobInArchive( + "sos_commands/networking/ethtool_*_%s" % dev + ) + + +class NetplanScrubTest(StageTwoReportTest): + """ + ensure that netplan configuration is collected and then the wifi password + is scrubbed correctly + + :avocado: tags=stagetwo + """ + + sos_cmd = '-o networking' + + files = [('90-NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02.yaml', + '/etc/netplan/90-NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02.yaml')] + + @ubuntu_only + def test_netplan_wifi_password_scrubbed(self): + self.assertFileNotHasContent( + '/etc/netplan/90-NM-d377ae8e-fff5-11ee-bd96-07ef2a5f9e02.yaml', + 'awifipasswordforauth') |