Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed Oct 20, 2023
1 parent 18a8651 commit cd505ba
Showing 1 changed file with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -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)

0 comments on commit cd505ba

Please sign in to comment.