Skip to content

Commit aea7f4e

Browse files
author
Dan Lavu
committed
test: authentication, adding generic password policy tests
1 parent 58a2fee commit aea7f4e

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

src/tests/system/tests/test_authentication.py

+83
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from sssd_test_framework.roles.ad import AD
1111
from sssd_test_framework.roles.client import Client
1212
from sssd_test_framework.roles.generic import GenericProvider
13+
from sssd_test_framework.roles.ldap import LDAP
1314
from sssd_test_framework.topology import KnownTopology, KnownTopologyGroup
1415

1516

@@ -47,6 +48,88 @@ def test_authentication__with_default_settings(
4748
), "User logged in with an invalid password!"
4849

4950

51+
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
52+
@pytest.mark.parametrize("method", ["su", "ssh"])
53+
@pytest.mark.parametrize("sssd_service_user", ("root", "sssd"))
54+
@pytest.mark.importance("critical")
55+
@pytest.mark.require(
56+
lambda client, sssd_service_user: ((sssd_service_user == "root") or client.features["non-privileged"]),
57+
"SSSD was built without support for running under non-root",
58+
)
59+
def test_authentication__password_change_on_login(
60+
client: Client, provider: GenericProvider, sssd_service_user: str, method: str
61+
):
62+
"""
63+
:title: User must change their password during the login prompt
64+
:setup:
65+
1. Create user
66+
2. Start SSSD
67+
:steps:
68+
1. Authenticate as user
69+
2. Expire the user password
70+
3. Authenticate as user
71+
4. Authenticate user with old password
72+
:expectedresults:
73+
1. User is authenticated
74+
2. User password is expired
75+
3. User is forced to change password and login is successful
76+
4. User is not authenticated
77+
:customerscenario: True
78+
"""
79+
old_pass = "Secret123"
80+
new_pass = "Password123"
81+
82+
user = provider.user("user1").add(password=old_pass)
83+
client.sssd.start(service_user=sssd_service_user)
84+
85+
assert client.auth.ssh.password(user.name, old_pass), "User failed to authenticate!"
86+
user.password_change_at_logon
87+
88+
# 389ds 'Must change password' needs to be triggered by an administrative password reset first.
89+
if isinstance(provider, LDAP):
90+
user.modify(password=old_pass)
91+
92+
assert client.auth.parametrize(method).password_expired(user.name, old_pass, new_pass), "Password change failed!"
93+
94+
assert client.auth.parametrize(method).password(user.name, new_pass), "User login failed!"
95+
assert not client.auth.parametrize(method).password(user.name, old_pass), "Login with old password passed!"
96+
97+
98+
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
99+
@pytest.mark.parametrize("method", ["su", "ssh"])
100+
@pytest.mark.importance("critical")
101+
def test_authentication__password_change_does_not_meet_complexity_requirements(
102+
client: Client, provider: GenericProvider, method: str
103+
):
104+
"""
105+
:title: Password change on login when the new passwords do not meet the complexity requirements
106+
:setup:
107+
1. Create user
108+
2. Enable password complexity
109+
3. Start SSSD
110+
:steps:
111+
1. Login as user
112+
2. Prompt, enter password that does not meet complexity requirements
113+
:expectedresults:
114+
1. User logins and is prompted to change password
115+
2. Password change fails
116+
:customerscenario: True
117+
"""
118+
user = provider.user("user1").add(password="Secret123").password_change_at_logon
119+
provider.password.complexity(enable=True)
120+
121+
# 389ds 'Must change password' needs to be triggered by an administrative password reset first.
122+
if isinstance(provider, LDAP):
123+
user.modify(password="Secret123")
124+
125+
client.sssd.start()
126+
127+
# rc == 1, is specific to failing complexity constraints
128+
assert (
129+
client.auth.parametrize(method).password_expired_with_output(user.name, "Secret123", "red_32")[0] == 1
130+
), "Password change should not pass!"
131+
132+
50133
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
51134
@pytest.mark.parametrize("method", ["su", "ssh"])
52135
@pytest.mark.parametrize("sssd_service_user", ("root", "sssd"))

0 commit comments

Comments
 (0)