mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
htpasswd: raise error on del if user is not exist
This commit is contained in:
@@ -49,8 +49,10 @@ def _htpasswd_fixture(request) -> Generator[KvmdHtpasswdFile, None, None]: # ty
|
||||
for user in request.param:
|
||||
htpasswd.set_password(user, _make_passwd(user))
|
||||
htpasswd.save()
|
||||
yield htpasswd
|
||||
os.remove(path)
|
||||
try:
|
||||
yield htpasswd
|
||||
finally:
|
||||
os.remove(path)
|
||||
|
||||
|
||||
def _run_htpasswd(cmd: list[str], htpasswd_path: str, int_type: str="htpasswd") -> None:
|
||||
@@ -154,8 +156,10 @@ def test_ok__del(htpasswd: KvmdHtpasswdFile) -> None:
|
||||
|
||||
if old_users:
|
||||
assert htpasswd.check_password("admin", _make_passwd("admin"))
|
||||
_run_htpasswd(["del", "admin"], htpasswd.path)
|
||||
|
||||
_run_htpasswd(["del", "admin"], htpasswd.path)
|
||||
with pytest.raises(SystemExit, match="The user 'admin' is not exist"):
|
||||
_run_htpasswd(["del", "admin"], htpasswd.path)
|
||||
|
||||
htpasswd.load(force=True)
|
||||
assert not htpasswd.check_password("admin", _make_passwd("admin"))
|
||||
|
||||
Reference in New Issue
Block a user