From cd505baf8b776bb42ec38e50dd6fe06971197a96 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Fri, 20 Oct 2023 10:20:13 -0700 Subject: [PATCH] Fix test --- ...s.py => test_account_password_policies.py} | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) rename tests/api2/{test__account_password_policies.py => test_account_password_policies.py} (75%) diff --git a/tests/api2/test__account_password_policies.py b/tests/api2/test_account_password_policies.py similarity index 75% rename from tests/api2/test__account_password_policies.py rename to tests/api2/test_account_password_policies.py index d5bf84ddbc7f0..84d878fac41c8 100644 --- a/tests/api2/test__account_password_policies.py +++ b/tests/api2/test_account_password_policies.py @@ -1,19 +1,10 @@ -import errno -import json -import logging - import pytest import secrets import string -import websocket -from contextlib import contextmanager -from middlewared.client import ClientException from middlewared.service_exception import ValidationErrors from middlewared.test.integration.assets.account import user -from middlewared.test.integration.assets.pool import dataset -from middlewared.test.integration.utils import call, client, ssh, websocket_url -from middlewared.test.integration.utils.shell import assert_shell_works +from middlewared.test.integration.utils import call, client, ssh USER = 'password_reset_user' @@ -24,11 +15,12 @@ Security configuration for this user account requires a password that does not match any of the last 10 passwords. """ -@pytest.fixture(scope=module) + +@pytest.fixture(scope='module') def grant_users_password_reset_privilege(request): priv = call('privilege.create', { 'name': 'PASSWORD_RESET', - 'local_groups': [545] + 'local_groups': [545], 'allowlist': [{ 'method': '*', 'resource': 'user.password_reset' @@ -40,16 +32,16 @@ def grant_users_password_reset_privilege(request): call('privilege.delete', priv['id']) -test_password_reset(grant_users_password_reset_privilege): - with user( - 'username': USER, +def test_password_reset(grant_users_password_reset_privilege): + with user({ + 'username': USER, 'full_name': USER, 'home': '/var/empty', 'shell': '/usr/bin/bash', 'password_aging_enabled': True, 'ssh_password_enabled': True, 'password': PASSWD1 - ) as u: + }): ssh('pwd', user=USER, password=PASSWD1) # `user.password_reset` should be allowed @@ -63,4 +55,4 @@ def grant_users_password_reset_privilege(request): with client(auth=(USER, PASSWD2)) as c: c.call('user.reset_password', PASSWD2, PASSWD1) - assert PASSWORD_REUSE_ERR in str(ve), str(ve) + assert PASSWORD_REUSE_ERR in str(ve), str(ve)