Skip to content

Commit

Permalink
test: add_delete_user: Test yescrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiaswal committed Oct 9, 2024
1 parent 8809141 commit ae4dca0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion test/case/ietf_system/add_delete_user/Readme.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
=== Add/delete user
==== Description
Verify that it is possible to add/delete a user.
Verify that it is possible to add/delete a user. The user password is hashed
with yescrypt.

==== Topology
ifdef::topdoc[]
Expand All @@ -18,6 +19,7 @@ endif::topdoc[]
. Set up topology and attach to target DUT
. Add new user 'newuser01' with password 'newuser01password'
. Verify user 'newuser01' exist in operational
. Verify user 'newuser01' can login with SSH
. Delete user 'newuser01'
. Verify erasure of user 'newuser01'
. Verify that 'newuser01' is removed from /etc/passwd
Expand Down
12 changes: 7 additions & 5 deletions test/case/ietf_system/add_delete_user/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"""
Add/delete user
Verify that it is possible to add/delete a user.
Verify that it is possible to add/delete a user. The user password is hashed
with yescrypt.
"""
import infamy
import copy
from passlib.hash import sha256_crypt
import random
import string
import re
Expand All @@ -15,16 +15,14 @@

username = "newuser01"
password = "newuser01password"

hashed_password = "$y$j9T$SALT$gx4K1wugXsm3JDLwYZtnbr37FGGvljotXwIBGOxaGf2"
with infamy.Test() as test:
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")

with test.step("Add new user 'newuser01' with password 'newuser01password'"):
hashed_password = sha256_crypt.using(rounds=5000).hash(password)

target.put_config_dict("ietf-system", {
"system": {
"authentication": {
Expand All @@ -50,6 +48,10 @@
break
assert user_found, f"User 'newuser01' not found"

with test.step("Verify user 'newuser01' can login with SSH"):
newssh = env.attach("target", "mgmt", "ssh", None, username, password)
util.until(lambda: newssh.run("ls").returncode == 0, attempts=200)

with test.step("Delete user 'newuser01'"):
target.delete_xpath(f"/ietf-system:system/authentication/user[name='{username}']")

Expand Down

0 comments on commit ae4dca0

Please sign in to comment.