mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 12:33:02 +02:00
test: add_delete_user: Test yescrypt
This commit is contained in:
@@ -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[]
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -15,7 +15,7 @@ import infamy.util as util
|
||||
|
||||
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()
|
||||
@@ -23,8 +23,6 @@ with infamy.Test() as test:
|
||||
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": {
|
||||
@@ -50,6 +48,10 @@ with infamy.Test() as test:
|
||||
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}']")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user