Skip to content

Commit 29bec62

Browse files
author
Dan Lavu
committed
tests: removed overlapping test scenarios from authentication tests
* few scenarios have been removed * ppolicy tests have been made into ppolicy tests only, since normal ldap is covered by the generic provider now * renamed some of the test cases * removed su from a password change test * removed some test cases that are now covered by the new test cases
1 parent 8811c77 commit 29bec62

File tree

2 files changed

+77
-142
lines changed

2 files changed

+77
-142
lines changed

src/tests/system/tests/test_authentication.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_authentication__change_password(
5555
provider: GenericProvider,
5656
):
5757
"""
58-
:title: User logins and issues a password change
58+
:title: User issues a password change after login
5959
:setup:
6060
1. Create user 'user'
6161
2. Start SSSD
@@ -98,7 +98,7 @@ def test_authentication__change_password_with_complexity_requirement(
9898
provider: GenericProvider,
9999
):
100100
"""
101-
:title: Password change when the new passwords do not meet the complexity requirements
101+
:title: User issues a password change after login with password policy complexity enabled
102102
:setup:
103103
1. Create user 'user'
104104
2. Enable password complexity requirements

src/tests/system/tests/test_ldap.py

+75-140
Original file line numberDiff line numberDiff line change
@@ -14,173 +14,112 @@
1414
from sssd_test_framework.topology import KnownTopology
1515

1616

17-
@pytest.mark.ticket(bz=[795044, 1695574])
18-
@pytest.mark.importance("critical")
19-
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify", "exop_force"])
20-
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
21-
@pytest.mark.parametrize("sssd_service_user", ("root", "sssd"))
2217
@pytest.mark.topology(KnownTopology.LDAP)
23-
@pytest.mark.require(
24-
lambda client, sssd_service_user: ((sssd_service_user == "root") or client.features["non-privileged"]),
25-
"SSSD was built without support for running under non-root",
26-
)
27-
@pytest.mark.builtwith("ldap_use_ppolicy")
28-
def test_ldap__password_change_using_ppolicy(
29-
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str, sssd_service_user: str
30-
):
18+
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify", "exop_force"])
19+
@pytest.mark.importance("critical")
20+
def test_ldap__ppolicy_change_password(client: Client, ldap: LDAP, modify_mode: str):
3121
"""
32-
:title: Password change using ppolicy
33-
:description: PPolicy overlay is the latest implementation of IETF password policy for LDAP.
34-
This extends the password policy for the LDAP server and is configured in SSSD using
35-
'ldap_use_ppolicy'.
36-
37-
Two password modification modes are tested, Extended Operation (exop), the default and then
38-
LDAP (ldapmodify), set by 'ldap_pwmodify_mode' parameter.
39-
:note: This feature is introduced in SSSD 2.10.0
22+
:title: User issues a password change after login against ppolicy overlay
23+
:description:
24+
Password Policy (ppolicy) is a loadable module that enables password policies in LDAP.
25+
The feature offers two methods to update the password, external operation (exop) or
26+
LDAP modify.
27+
28+
The 'test_authentication__change_password' test is a generic provider test that already
29+
covers LDAP. This test is an edited copy that only tests LDAP with the ppolicy overlay.
4030
:setup:
41-
1. Add a user to LDAP
42-
2. Configure the LDAP ACI to permit user password changes
43-
3. Set "ldap_pwmodify_mode"
44-
4. Start SSSD
31+
1. Create user 'user'
32+
2. Configure SSSD with 'ldap_pwmodify_mode = exop | ldap_modify | exop_force' and 'ldap_user_ppolicy = true
33+
3. Start SSSD
4534
:steps:
46-
1. Authenticate as user
47-
2. Change the password of user
48-
3. Authenticate user with new password
49-
4. Authenticate user with old password
35+
1. Login as user
36+
2. Issue password change and enter a bad confirmation password
37+
3. Issue password change and enter a good confirmation password
38+
4. Login with old password
39+
5. Login with new password
5040
:expectedresults:
5141
1. User is authenticated
52-
2. Password is changed successfully
53-
3. User is authenticated
54-
4. User is not authenticated
42+
2. Password is change is unsuccessful
43+
3. Password change is successful
44+
4. User cannot log in
45+
5. User can log in
5546
:customerscenario: True
5647
"""
57-
user = "user1"
58-
old_pass = "Secret123"
59-
new_pass = "New_password123"
60-
61-
ldap.user(user).add(password=old_pass)
62-
ldap.aci.add('(targetattr="userpassword")(version 3.0; acl "pwp test"; allow (all) userdn="ldap:///self";)')
48+
old_password = "Secret123"
49+
invalid_password = "secret"
50+
new_password = "Secret123**%%"
6351

52+
ldap.user("user1").add(password=old_password)
6453
client.sssd.domain["ldap_pwmodify_mode"] = modify_mode
65-
client.sssd.domain["ldap_use_ppolicy"] = use_ppolicy
66-
client.sssd.start(service_user=sssd_service_user)
67-
68-
assert client.auth.ssh.password(user, old_pass), "Login with old password failed!"
69-
70-
assert client.auth.passwd.password(user, old_pass, new_pass), "Password change failed!"
54+
client.sssd.domain["ldap_use_ppolicy"] = "True"
7155

72-
assert client.auth.ssh.password(user, new_pass), "User login failed!"
73-
assert not client.auth.ssh.password(user, old_pass), "Login with old password passed!"
74-
75-
76-
@pytest.mark.ticket(bz=[795044, 1695574])
77-
@pytest.mark.importance("critical")
78-
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify", "exop_force"])
79-
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
80-
@pytest.mark.topology(KnownTopology.LDAP)
81-
@pytest.mark.builtwith("ldap_use_ppolicy")
82-
def test_ldap__password_change_new_passwords_do_not_match_using_ppolicy(
83-
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str
84-
):
85-
"""
86-
:title: Password change when the new passwords do not match
87-
:setup:
88-
1. Add user to LDAP
89-
2. Configure the LDAP ACI to permit user password changes
90-
3. set "ldap_pwmodify_mode"
91-
4. Start SSSD
92-
:steps:
93-
1. Change password to new password, but retyped password is different
94-
:expectedresults:
95-
1. Password change is not successful
96-
:customerscenario: True
97-
"""
98-
ldap.user("user1").add(password="Secret123")
99-
ldap.aci.add('(targetattr="userpassword")(version 3.0; acl "pwp test"; allow (all) userdn="ldap:///self";)')
100-
101-
client.sssd.domain["ldap_pwmodify_mode"] = modify_mode
102-
client.sssd.domain["ldap_use_ppolicy"] = use_ppolicy
10356
client.sssd.start()
10457

10558
assert not client.auth.passwd.password(
106-
"user1", "Secret123", "Red123", "Hat000"
59+
"user1", old_password, new_password, retyped=invalid_password
10760
), "Password should not have been able to be changed!"
61+
assert client.auth.passwd.password("user1", old_password, new_password), "'user1' password change failed!"
62+
63+
assert not client.auth.ssh.password("user1", old_password), "'user1' shouldn't have been able to log in!"
64+
assert client.auth.ssh.password("user1", new_password), "'user1' failed to log in!"
10865

10966

11067
@pytest.mark.ticket(bz=[795044, 1695574, 1795220])
11168
@pytest.mark.importance("critical")
11269
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify", "exop_force"])
113-
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
11470
@pytest.mark.topology(KnownTopology.LDAP)
115-
@pytest.mark.builtwith("ldap_use_ppolicy")
116-
def test_ldap__password_change_new_password_does_not_meet_complexity_requirements_using_ppolicy(
117-
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str
71+
def test_ldap__ppolicy_change_password_with_complexity_requirement(
72+
client: Client,
73+
ldap: LDAP,
74+
modify_mode: str,
11875
):
11976
"""
120-
:title: Password change when the new passwords do not meet the complexity requirements using ppolicy
77+
:title: User issues a password change after login with password policy complexity enabled against ppolicy overlay
78+
:description:
79+
Password Policy (ppolicy) is a loadable module that enables password policies in LDAP.
80+
The feature offers two methods to update the password, external operation (exop) or
81+
LDAP modify.
82+
83+
The 'test_authentication__change_password_with_complexity_requirement' test is a generic
84+
provider test that already covers LDAP. This test is an edited copy that only tests LDAP with the ppolicy overlay.
12185
:setup:
12286
1. Add a user to LDAP
123-
2. Configure the LDAP ACI to permit user password changes
124-
3. Set "passwordCheckSyntax" to "on"
125-
4. Set "ldap_pwmodify_mode"
126-
5. Start SSSD
127-
:steps:
128-
1. Change password to new password, but all letters are lower-case
129-
2. Check logs
130-
:expectedresults:
131-
1. Password change failed
132-
2. Password change failure is logged
133-
:customerscenario: True
134-
"""
135-
ldap.user("user1").add(password="Secret123")
136-
ldap.aci.add('(targetattr="userpassword")(version 3.0; acl "pwp test"; allow (all) userdn="ldap:///self";)')
137-
ldap.ldap.modify("cn=config", replace={"passwordCheckSyntax": "on"})
138-
139-
client.sssd.domain["ldap_pwmodify_mode"] = modify_mode
140-
client.sssd.domain["ldap_use_ppolicy"] = use_ppolicy
141-
client.sssd.start()
142-
143-
assert not client.auth.passwd.password(
144-
"user1", "Secret123", "red_32"
145-
), "Password should not have been able to be changed!"
146-
147-
match = client.journald.is_match(r"pam_sss\(passwd:chauthtok\): User info message: Password change failed.")
148-
assert match, "'Password change failed.' message is not in log!"
149-
150-
151-
@pytest.mark.ticket(bz=[1695574, 1795220])
152-
@pytest.mark.importance("critical")
153-
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify", "exop_force"])
154-
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
155-
@pytest.mark.topology(KnownTopology.LDAP)
156-
@pytest.mark.builtwith("ldap_use_ppolicy")
157-
def test_ldap__password_change_with_invalid_current_password_using_ppolicy(
158-
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str
159-
):
160-
"""
161-
:title: Password change fails with invalid current password
162-
:setup:
163-
1. Add a user to LDAP, set his password
164-
2. Configure the LDAP ACI to permit user password changes
165-
3. Set "ldap_pwmodify_mode"
87+
2. Enable password complexity requirements
88+
3. Configure SSSD with 'ldap_pwmodify_mode = exop | ldap_modify | exop_force' and 'ldap_user_ppolicy = true
16689
4. Start SSSD
16790
:steps:
168-
1. Attempt to change the password but enter the incorrect password
91+
1. Login as user
92+
2. Issue password change as user with password that does not meet complexity requirements
93+
3. Issue password change as user with password meeting complexity requirements and logout
94+
4. Login with old password
95+
5. Login with new password
16996
:expectedresults:
170-
1. Password change is not successful
97+
1. User is authenticated
98+
2. Password is change is unsuccessful
99+
3. Password change is successful
100+
4. User cannot log in
101+
5. User can log in
171102
:customerscenario: True
172103
"""
173-
ldap.user("user1").add(password="Secret123")
174-
ldap.aci.add('(targetattr="userpassword")(version 3.0; acl "pwp test"; allow (all) userdn="ldap:///self";)')
104+
old_password = "Secret123"
105+
invalid_password = "secret"
106+
new_password = "Secret123**%%"
107+
108+
ldap.user("user1").add(password=old_password)
109+
ldap.password_policy.complexity(enable=True)
175110

176111
client.sssd.domain["ldap_pwmodify_mode"] = modify_mode
177-
client.sssd.domain["ldap_use_ppolicy"] = use_ppolicy
112+
client.sssd.domain["ldap_use_ppolicy"] = "True"
178113
client.sssd.start()
179114

180115
assert not client.auth.passwd.password(
181-
"user1", "wrong123", "Newpass123"
116+
"user1", old_password, invalid_password
182117
), "Password should not have been able to be changed!"
183118

119+
assert client.auth.passwd.password("user1", old_password, new_password), "'user1' password change failed!"
120+
assert not client.auth.ssh.password("user1", old_password), "'user1' shouldn't have been able to log in!"
121+
assert client.auth.ssh.password("user1", new_password), "'user1' failed to log in!"
122+
184123

185124
@pytest.mark.importance("low")
186125
@pytest.mark.ticket(bz=[1067476, 1065534])
@@ -231,16 +170,14 @@ def test_ldap__authenticate_user_with_whitespace_prefix_in_userid(client: Client
231170
@pytest.mark.ticket(bz=1507035)
232171
@pytest.mark.topology(KnownTopology.LDAP)
233172
@pytest.mark.parametrize("method", ["su", "ssh"])
234-
def test_ldap__change_password_when_ldap_pwd_policy_is_set_to_shadow(client: Client, ldap: LDAP, method: str):
173+
def test_ldap__shadow_policy_change_password(client: Client, ldap: LDAP, method: str):
235174
"""
236175
:title: Change password with shadow ldap password policy is set to shadow
237176
:description: Changing a password when the password policy is managed by the shadowAccount objectclass.
238177
:setup:
239-
1. Configure the LDAP ACI to permit user password changes
240-
2. Create user with shadowLastChange = 0, shadowMin = 0, shadowMax = 99999 and shadowWarning = 7
241-
3. Set "ldap_pwd_policy = shadow"
242-
4. Set "ldap_chpass_update_last_change = True"
243-
5. Start SSSD
178+
1. Create user with shadowLastChange = 0, shadowMin = 0, shadowMax = 99999 and shadowWarning = 7
179+
2. Set "ldap_pwd_policy = shadow" and "ldap_chpass_update_last_change = True"
180+
3. Start SSSD
244181
:steps:
245182
1. Authenticate as "tuser" with old password
246183
2. Authenticate as "tuser" with new password
@@ -249,7 +186,6 @@ def test_ldap__change_password_when_ldap_pwd_policy_is_set_to_shadow(client: Cli
249186
2. Authentication with new password was successful
250187
:customerscenario: True
251188
"""
252-
ldap.aci.add('(targetattr="userpassword")(version 3.0; acl "pwp test"; allow (all) userdn="ldap:///self";)')
253189
ldap.user("tuser").add(
254190
uid=999011, gid=999011, shadowMin=0, shadowMax=99999, shadowWarning=7, shadowLastChange=0, password="Secret123"
255191
)
@@ -460,10 +396,9 @@ def test_ldap__lookup_and_authenticate_as_user_with_different_object_search_base
460396
"modify_mode, expected, err_msg",
461397
[("exop", 1, "Expected login failure"), ("exop_force", 3, "Expected password change request")],
462398
)
463-
@pytest.mark.parametrize("method", ["su", "ssh"])
464399
@pytest.mark.topology(KnownTopology.LDAP)
465400
def test_ldap__password_change_no_grace_logins_left(
466-
client: Client, ldap: LDAP, modify_mode: str, expected: int, err_msg: str, method: str
401+
client: Client, ldap: LDAP, modify_mode: str, expected: int, err_msg: str
467402
):
468403
"""
469404
:title: Password change when no grace logins left
@@ -500,7 +435,7 @@ def test_ldap__password_change_no_grace_logins_left(
500435
client.sssd.domain["ldap_pwmodify_mode"] = modify_mode
501436
client.sssd.start()
502437

503-
rc, _, _, _ = client.auth.parametrize(method).password_with_output("user1", "Secret123")
438+
rc, _, _, _ = client.auth.ssh.password_with_output("user1", "Secret123")
504439
assert rc == expected, err_msg
505440

506441

0 commit comments

Comments
 (0)