test: system: Make tests more robust

This commit is contained in:
Mattias Walström
2026-06-27 08:39:47 +02:00
parent 0deff2515c
commit ce4dd2d3e3
3 changed files with 40 additions and 18 deletions
+12 -3
View File
@@ -8,6 +8,17 @@ import random, string
import time
import infamy
import lxml
from infamy.util import until
def get_timezone_name():
try:
tz=target.get_data("/ietf-system:system/clock/timezone-name")
name=tz.get("system", {}).get("clock",{}).get("timezone-name", "")
return name
except:
return None
with infamy.Test() as test:
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
@@ -23,8 +34,6 @@ with infamy.Test() as test:
}})
with test.step("Verify timezone is Australia/Perth"):
tz=target.get_data("/ietf-system:system/clock/timezone-name")
name=tz.get("system", {}).get("clock",{}).get("timezone-name", "")
assert(name == "Australia/Perth")
until(lambda: get_timezone_name() == "Australia/Perth")
test.succeed()
+11 -3
View File
@@ -7,6 +7,16 @@ Verify that it is possible to set timezone using UTC offset
import infamy
import lxml
from infamy.util import until
def get_timezone_offset():
try:
tz=target.get_data("/ietf-system:system/clock/timezone-utc-offset")
offset=tz.get("system", {}).get("clock",{}).get("timezone-utc-offset", 0)
return offset
except:
return None
with infamy.Test() as test:
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
@@ -22,8 +32,6 @@ with infamy.Test() as test:
}})
with test.step("Verify current timezone is UTC+12:00"):
tz=target.get_data("/ietf-system:system/clock/timezone-utc-offset")
offset=tz.get("system", {}).get("clock",{}).get("timezone-utc-offset", 0)
assert(offset == 12)
until(lambda: get_timezone_offset() == 12)
test.succeed()
+17 -12
View File
@@ -11,6 +11,16 @@ import infamy.ssh as ssh
import infamy.util as util
from passlib.hash import sha256_crypt
def get_user(name):
try:
operational = target.get_data("/ietf-system:system/authentication")
users = operational["system"]["authentication"]["user"]
for user in users:
if user['name'] == name:
return user
except:
return None
with infamy.Test() as test:
with test.step("Set up topology and attach to target DUT"):
env = infamy.Env()
@@ -84,20 +94,15 @@ with infamy.Test() as test:
target.put_config_dicts({"ietf-system": running})
with test.step("Verify user jacky exists and has new password"):
operational = target.get_data("/ietf-system:system/authentication")
users = operational["system"]["authentication"]["user"]
def password_changed():
user = get_user(USER)
if user and user['password'] != PASS:
return user
return None
found = None
for user in users:
if user['name'] == USER:
found = user
break
user = util.until(password_changed)
if found is None:
test.fail()
if found['password'] == "$factory$":
test.fail()
if found['password'] == PASS:
if user is None:
test.fail()
with test.step("Verify user jacky can log in with SSH"):