From 00b103d3d2d6b5ad8834fba79adfcda32e77cd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Tue, 8 Oct 2024 15:26:13 +0200 Subject: [PATCH] tests: Update some typos in test steps Also add missing ipv4_autoconf test from specification --- test/case/ietf_interfaces/Readme.adoc | 2 ++ .../iface_phys_address/Readme.adoc | 3 ++- .../iface_phys_address/test.py | 4 ++-- .../ietf_interfaces/ipv4_address/Readme.adoc | 3 ++- .../case/ietf_interfaces/ipv4_address/test.py | 5 +++-- .../ietf_interfaces/ipv4_autoconf/Readme.adoc | 9 ++++---- .../ietf_interfaces/ipv4_autoconf/test.py | 10 +++++---- .../ietf_system/add_delete_user/Readme.adoc | 5 ++++- test/case/ietf_system/add_delete_user/test.py | 8 +++---- test/case/ietf_system/hostname/Readme.adoc | 14 ++++++++++-- test/case/ietf_system/hostname/test.py | 19 ++++++++++------ test/case/ietf_system/timezone/Readme.adoc | 2 +- test/case/ietf_system/timezone/test.py | 2 +- .../timezone_utc_offset/Readme.adoc | 2 +- .../ietf_system/timezone_utc_offset/test.py | 2 +- test/case/ietf_system/upgrade/Readme.adoc | 3 ++- test/case/ietf_system/upgrade/test.py | 4 ++-- test/case/ietf_system/user_admin/Readme.adoc | 13 +++++++++-- test/case/ietf_system/user_admin/test.py | 22 +++++++++---------- 19 files changed, 84 insertions(+), 48 deletions(-) diff --git a/test/case/ietf_interfaces/Readme.adoc b/test/case/ietf_interfaces/Readme.adoc index 890aa53e..28307548 100644 --- a/test/case/ietf_interfaces/Readme.adoc +++ b/test/case/ietf_interfaces/Readme.adoc @@ -9,6 +9,8 @@ include::ipv4_address/Readme.adoc[] include::ipv6_address/Readme.adoc[] +include::ipv4_autoconf/Readme.adoc[] + include::iface_phys_address/Readme.adoc[] include::routing_basic/Readme.adoc[] diff --git a/test/case/ietf_interfaces/iface_phys_address/Readme.adoc b/test/case/ietf_interfaces/iface_phys_address/Readme.adoc index 072f9d02..bc06b476 100644 --- a/test/case/ietf_interfaces/iface_phys_address/Readme.adoc +++ b/test/case/ietf_interfaces/iface_phys_address/Readme.adoc @@ -18,7 +18,8 @@ endif::topdoc[] . Initialize . Set custom MAC address to '02:01:00:c0:ff:ee' on target:mgmt . Verify target:mgmt has MAC address '02:01:00:c0:ff:ee' -. Verify that target:mgmt has its origil MAC address again +. Remove custom MAC address '02:01:00:c0:ff:ee' +. Verify that target:mgmt has the original MAC address again <<< diff --git a/test/case/ietf_interfaces/iface_phys_address/test.py b/test/case/ietf_interfaces/iface_phys_address/test.py index 55182e87..1a4554e8 100755 --- a/test/case/ietf_interfaces/iface_phys_address/test.py +++ b/test/case/ietf_interfaces/iface_phys_address/test.py @@ -36,11 +36,11 @@ with infamy.Test() as test: print(f"Target iface {tport} current mac: {mac}") assert mac == cmac - with test.step(f"Remove custom MAC address '02:01:00:c0:ff:ee'"): + with test.step("Remove custom MAC address '02:01:00:c0:ff:ee'"): xpath=iface.get_iface_xpath(tport, "phys-address") target.delete_xpath(xpath) - with test.step("Verify that target:mgmt has its origil MAC address again"): + with test.step("Verify that target:mgmt has the original MAC address again"): until(lambda: iface.get_phys_address(target, tport) == pmac) test.succeed() diff --git a/test/case/ietf_interfaces/ipv4_address/Readme.adoc b/test/case/ietf_interfaces/ipv4_address/Readme.adoc index 498e6f36..53481355 100644 --- a/test/case/ietf_interfaces/ipv4_address/Readme.adoc +++ b/test/case/ietf_interfaces/ipv4_address/Readme.adoc @@ -15,9 +15,10 @@ image::topology.png[Interface with IPv4 topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Connect to target +. Set up topology and attach to target DUT . Configure IPv4 address 10.10.10.20/24 on target:mgmt . Verify '10.10.10.20/24' exist on target:mgmt +. Remove all IPv4 addresses from target:mgmt . Verify target:mgmt no longer has the address 10.10.10.20 diff --git a/test/case/ietf_interfaces/ipv4_address/test.py b/test/case/ietf_interfaces/ipv4_address/test.py index f10790b6..6a06ef7d 100755 --- a/test/case/ietf_interfaces/ipv4_address/test.py +++ b/test/case/ietf_interfaces/ipv4_address/test.py @@ -15,7 +15,7 @@ new_ip_address = "10.10.10.20" new_prefix_length = 24 with infamy.Test() as test: - with test.step("Connect to target"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() target = env.attach("target", "mgmt") _, interface_name = env.ltop.xlate("target", "mgmt") @@ -42,8 +42,9 @@ with infamy.Test() as test: with test.step("Verify '10.10.10.20/24' exist on target:mgmt"): until(lambda: iface.address_exist(target, interface_name, new_ip_address, proto='static')) - with test.step(f"Remove all IPv4 addresses from target:mgmt"): + with test.step("Remove all IPv4 addresses from target:mgmt"): target.delete_xpath(f"/ietf-interfaces:interfaces/interface[name='{interface_name}']/ietf-ip:ipv4") + with test.step("Verify target:mgmt no longer has the address 10.10.10.20"): until(lambda: iface.address_exist(target, interface_name, new_ip_address) == False) diff --git a/test/case/ietf_interfaces/ipv4_autoconf/Readme.adoc b/test/case/ietf_interfaces/ipv4_autoconf/Readme.adoc index 1d66d60c..e6ced04e 100644 --- a/test/case/ietf_interfaces/ipv4_autoconf/Readme.adoc +++ b/test/case/ietf_interfaces/ipv4_autoconf/Readme.adoc @@ -17,12 +17,13 @@ image::topology.png[IPv4 link-local topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Initialize -. Configure an interface with IPv4 ZeroConf IP -. Verify link local address exist on target:mgmt +. Set up topology and attach to target DUT +. Configure interface target:mgmt with IPv4 ZeroConf IP +. Verify link-local address exist on target:mgmt . Configure target:mgmt with a specific IPv4 ZeroConf IP -. Verify target:mgmt has link local address 169.254.42.42 +. Verify target:mgmt has link-local address 169.254.42.42 . Remove IPv4 link-local addresses from target:mgmt +. Verify link-local addresses has been removed from target:mgmt <<< diff --git a/test/case/ietf_interfaces/ipv4_autoconf/test.py b/test/case/ietf_interfaces/ipv4_autoconf/test.py index 1130b237..99aa59a3 100755 --- a/test/case/ietf_interfaces/ipv4_autoconf/test.py +++ b/test/case/ietf_interfaces/ipv4_autoconf/test.py @@ -45,11 +45,11 @@ def no_linklocal(target, iface): with infamy.Test() as test: - with test.step("Initialize"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() target = env.attach("target", "mgmt") - with test.step("Configure an interface with IPv4 ZeroConf IP"): + with test.step("Configure interface target:mgmt with IPv4 ZeroConf IP"): _, tport = env.ltop.xlate("target", "data") target.put_config_dict("ietf-interfaces", { @@ -68,7 +68,7 @@ with infamy.Test() as test: } }) - with test.step("Verify link local address exist on target:mgmt"): + with test.step("Verify link-local address exist on target:mgmt"): until(lambda: has_linklocal(target, tport), attempts=30) with test.step("Configure target:mgmt with a specific IPv4 ZeroConf IP"): @@ -91,7 +91,7 @@ with infamy.Test() as test: } }) - with test.step("Verify target:mgmt has link local address 169.254.42.42"): + with test.step("Verify target:mgmt has link-local address 169.254.42.42"): until(lambda: has_linklocal(target, tport, request="169.254.42.42"), attempts=30) @@ -99,6 +99,8 @@ with infamy.Test() as test: xpath = f"/ietf-interfaces:interfaces/interface[name='{tport}']" \ "/ietf-ip:ipv4/infix-ip:autoconf" target.delete_xpath(xpath) + + with test.step("Verify link-local addresses has been removed from target:mgmt"): until(lambda: no_linklocal(target, tport), attempts=30) test.succeed() diff --git a/test/case/ietf_system/add_delete_user/Readme.adoc b/test/case/ietf_system/add_delete_user/Readme.adoc index f1100bb0..7bf0c178 100644 --- a/test/case/ietf_system/add_delete_user/Readme.adoc +++ b/test/case/ietf_system/add_delete_user/Readme.adoc @@ -15,8 +15,11 @@ image::topology.png[Add/delete user topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Connect to device +. Set up topology and attach to target DUT . Add new user 'newuser01' with password 'newuser01password' +. Verify user 'newuser01' exist in operational +. Delete user 'newuser01' +. Verify erasure of user 'newuser01' . Verify that 'newuser01' is removed from /etc/passwd diff --git a/test/case/ietf_system/add_delete_user/test.py b/test/case/ietf_system/add_delete_user/test.py index 92c8261f..4e08e4be 100755 --- a/test/case/ietf_system/add_delete_user/test.py +++ b/test/case/ietf_system/add_delete_user/test.py @@ -17,7 +17,7 @@ username = "newuser01" password = "newuser01password" with infamy.Test() as test: - with test.step("Connect to device"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() target = env.attach("target", "mgmt") tgtssh = env.attach("target", "mgmt", "ssh") @@ -39,7 +39,7 @@ with infamy.Test() as test: } }) - with test.step(f"Verify user 'newuser01' exist in operational"): + with test.step("Verify user 'newuser01' exist in operational"): running = target.get_config_dict("/ietf-system:system") users = running["system"]["authentication"]["user"] user_found = False @@ -50,10 +50,10 @@ with infamy.Test() as test: break assert user_found, f"User 'newuser01' not found" - with test.step(f"Delete user 'newuser01'"): + with test.step("Delete user 'newuser01'"): target.delete_xpath(f"/ietf-system:system/authentication/user[name='{username}']") - with test.step(f"Verify erasure of user 'newuser01'"): + with test.step("Verify erasure of user 'newuser01'"): running = target.get_config_dict("/ietf-system:system") users = running["system"]["authentication"]["user"] for user in users: diff --git a/test/case/ietf_system/hostname/Readme.adoc b/test/case/ietf_system/hostname/Readme.adoc index 0cb217ef..f3117d7a 100644 --- a/test/case/ietf_system/hostname/Readme.adoc +++ b/test/case/ietf_system/hostname/Readme.adoc @@ -1,6 +1,12 @@ === Set hostname ==== Description -Verify that it is possible to change hostname. +Verify that it is possible to change hostname both normal +and using format %h-%m. + +The format exapnds to -, +where MAC is the last three bytes of the base MAC address. + +e.g. ix-01-01-01. ==== Topology ifdef::topdoc[] @@ -15,8 +21,12 @@ image::topology.png[Set hostname topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Connect to device +. Set up topology and attach to target DUT . Set hostname to 'h0stn4m3' +. Verify new hostname 'h0stn4m3' +. Set hostname to to '%h-%m' +. Verify hostname is %h-%m in running configuration +. Verify hostname format in operational, according to format <<< diff --git a/test/case/ietf_system/hostname/test.py b/test/case/ietf_system/hostname/test.py index 9d1cfd78..fc18a27c 100755 --- a/test/case/ietf_system/hostname/test.py +++ b/test/case/ietf_system/hostname/test.py @@ -2,7 +2,13 @@ """ Set hostname -Verify that it is possible to change hostname. +Verify that it is possible to change hostname both normal +and using format %h-%m. + +The format exapnds to -, +where MAC is the last three bytes of the base MAC address. + +e.g. ix-01-01-01. """ import random import string @@ -10,7 +16,7 @@ import re import infamy with infamy.Test() as test: - with test.step("Connect to device"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() target = env.attach("target", "mgmt") tgtssh = env.attach("target", "mgmt", "ssh") @@ -24,27 +30,26 @@ with infamy.Test() as test: } }) - with test.step(f"Verify new hostname 'h0stn4m3'"): + with test.step("Verify new hostname 'h0stn4m3'"): running = target.get_config_dict("/ietf-system:system") assert running["system"]["hostname"] == new - with test.step(f"Set hostname format: %h-%m"): + with test.step("Set hostname to to '%h-%m'"): target.put_config_dict("ietf-system", { "system": { "hostname": fmt, } }) - with test.step(f"Verify hostname format in running: %h-%m"): + with test.step("Verify hostname is %h-%m in running configuration"): running = target.get_config_dict("/ietf-system:system") if running["system"]["hostname"] != fmt: test.fail() + with test.step("Verify hostname format in operational, according to format"): cmd = tgtssh.runsh("sed -n s/^DEFAULT_HOSTNAME=//p /etc/os-release") default = cmd.stdout.rstrip() - with test.step(f"Verify hostname format in operational, according to format"): - oper = target.get_data("/ietf-system:system") name = oper["system"]["hostname"] pattern = rf'^{default}-([0-9a-fA-F]{{2}}-){{2}}[0-9a-fA-F]{{2}}$' diff --git a/test/case/ietf_system/timezone/Readme.adoc b/test/case/ietf_system/timezone/Readme.adoc index 9c4fa2e9..42f3c934 100644 --- a/test/case/ietf_system/timezone/Readme.adoc +++ b/test/case/ietf_system/timezone/Readme.adoc @@ -15,7 +15,7 @@ image::topology.png[Set timezone topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Connect to device +. Set up topology and attach to target DUT . Set timezone to Australia/Perth . Verify current time offset is +08:00 diff --git a/test/case/ietf_system/timezone/test.py b/test/case/ietf_system/timezone/test.py index adb40969..519a1289 100755 --- a/test/case/ietf_system/timezone/test.py +++ b/test/case/ietf_system/timezone/test.py @@ -9,7 +9,7 @@ import time import infamy import lxml with infamy.Test() as test: - with test.step("Connect to device"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() target = env.attach("target", "mgmt") diff --git a/test/case/ietf_system/timezone_utc_offset/Readme.adoc b/test/case/ietf_system/timezone_utc_offset/Readme.adoc index 6195e628..16bc8eef 100644 --- a/test/case/ietf_system/timezone_utc_offset/Readme.adoc +++ b/test/case/ietf_system/timezone_utc_offset/Readme.adoc @@ -15,7 +15,7 @@ image::topology.png[Set timezone with UTC offset topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Connect to device +. Set up topology and attach to target DUT . Set timezone UTC offset to +12 . Verify current time offset is +12:00 diff --git a/test/case/ietf_system/timezone_utc_offset/test.py b/test/case/ietf_system/timezone_utc_offset/test.py index 59d3c452..05237406 100755 --- a/test/case/ietf_system/timezone_utc_offset/test.py +++ b/test/case/ietf_system/timezone_utc_offset/test.py @@ -8,7 +8,7 @@ import infamy import lxml with infamy.Test() as test: - with test.step("Connect to device"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() target = env.attach("target", "mgmt") diff --git a/test/case/ietf_system/upgrade/Readme.adoc b/test/case/ietf_system/upgrade/Readme.adoc index 35c5b012..4d760512 100644 --- a/test/case/ietf_system/upgrade/Readme.adoc +++ b/test/case/ietf_system/upgrade/Readme.adoc @@ -15,7 +15,8 @@ image::topology.png[Upgrade topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Connect to device +. Set up topology and attach to target DUT +. Start installation of selected package . Wait for upgrade to finish diff --git a/test/case/ietf_system/upgrade/test.py b/test/case/ietf_system/upgrade/test.py index 8b40dd1a..7a455394 100755 --- a/test/case/ietf_system/upgrade/test.py +++ b/test/case/ietf_system/upgrade/test.py @@ -47,7 +47,7 @@ class FileServer(http.server.HTTPServer): self.__tp.shutdown() with infamy.Test() as test: - with test.step("Connect to device"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() if not env.args.package: print("No package supplied") @@ -68,7 +68,7 @@ with infamy.Test() as test: with FileServer(("::", SRVPORT), BUNDLEDIR): - with test.step(f"Start installation of selected package"): + with test.step("Start installation of selected package"): print(f"Installing {os.path.basename(env.args.package)}") target.call_dict("infix-system", { "install-bundle": { diff --git a/test/case/ietf_system/user_admin/Readme.adoc b/test/case/ietf_system/user_admin/Readme.adoc index c8057810..9e488a45 100644 --- a/test/case/ietf_system/user_admin/Readme.adoc +++ b/test/case/ietf_system/user_admin/Readme.adoc @@ -16,8 +16,17 @@ image::topology.png[Add admin user topology] endif::testgroup[] endif::topdoc[] ==== Test sequence -. Connect to device -. Add new user +. Set up topology and attach to target DUT +. Add new user 'jacky' with no NACM access +. Verify regular user jacky exists +. Verify user jacky is not in wheel group +. Verify user jacky password is set correctly +. Add user jacky to admin group in NACM +. Verify user jacky is now in wheel group +. Verify user jacky shell now is Bash +. Change user jacky to $factory$ password ... +. Verify user jacky exists and has new password +. Verify user jacky can log in with SSH <<< diff --git a/test/case/ietf_system/user_admin/test.py b/test/case/ietf_system/user_admin/test.py index 6d2b5742..1ffb0294 100755 --- a/test/case/ietf_system/user_admin/test.py +++ b/test/case/ietf_system/user_admin/test.py @@ -12,14 +12,14 @@ import infamy.util as util from passlib.hash import sha256_crypt with infamy.Test() as test: - with test.step("Connect to device"): + with test.step("Set up topology and attach to target DUT"): env = infamy.Env() target = env.attach("target", "mgmt") tgtssh = env.attach("target", "mgmt", "ssh") factory = env.get_password("target") address = target.get_mgmt_ip() - with test.step("Add new user"): + with test.step("Add new user 'jacky' with no NACM access"): USER = "jacky" PASS = "$1$3aR7Bq2u$G9kV.8AALtKkCnaAXFyu6/" @@ -39,21 +39,21 @@ with infamy.Test() as test: running = target.get_config_dict("/ietf-system:system") users = running["system"]["authentication"]["user"] - with test.step(f"Verify regular user jacky exists"): + with test.step("Verify regular user jacky exists"): jacky = next((user for user in users if user['name'] == USER), None) if not any(user['name'] == USER for user in users): test.fail() - with test.step(f"Verify user jacky is not in wheel group"): + with test.step("Verify user jacky is not in wheel group"): wheel = tgtssh.runsh("grep wheel /etc/group").stdout if USER in wheel: test.fail() - with test.step(f"Verify user jacky password is set correctly"): + with test.step("Verify user jacky password is set correctly"): if not tgtssh.runsh(f"sudo grep ':{PASS}:' /etc/shadow"): test.fail() - with test.step(f"Add user jacky to admin group"): + with test.step("Add user jacky to admin group in NACM"): # Don't presume 'admin' user exists, only group nacm = target.get_config_dict("/ietf-netconf-acm:nacm") for group in nacm["nacm"]["groups"]["group"]: @@ -62,16 +62,16 @@ with infamy.Test() as test: group["user-name"].append(USER) target.put_config_dict("ietf-netconf-acm", nacm) - with test.step(f"Verify user jacky is now in wheel group"): + with test.step("Verify user jacky is now in wheel group"): if not tgtssh.runsh(f"grep wheel /etc/group | grep '{USER}'"): test.fail() - with test.step(f"Verify user jacky shell now is Bash"): + with test.step("Verify user jacky shell now is Bash"): user = tgtssh.runsh(f"grep {USER} /etc/passwd").stdout if "bash" not in user: test.fail() - with test.step(f"Change user jacky to $factory$ password ..."): + with test.step("Change user jacky to $factory$ password ..."): running = target.get_config_dict("/ietf-system:system") users = running["system"]["authentication"]["user"] @@ -81,7 +81,7 @@ with infamy.Test() as test: break target.put_config_dict("ietf-system", running) - with test.step(f"Verify user jacky exists and has new password"): + with test.step("Verify user jacky exists and has new password"): operational = target.get_data("/ietf-system:system/authentication") users = operational["system"]["authentication"]["user"] @@ -98,7 +98,7 @@ with infamy.Test() as test: if found['password'] == PASS: test.fail() - with test.step(f"Verify user jacky can log in with SSH"): + with test.step("Verify user jacky can log in with SSH"): testssh=ssh.Device("target", ssh.Location(address, USER, factory)) util.until(lambda: testssh.runsh("ls").returncode == 0) test.succeed()