14
14
from sssd_test_framework .topology import KnownTopology
15
15
16
16
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" ))
22
17
@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 ):
31
21
"""
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.
40
30
: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
45
34
: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
50
40
:expectedresults:
51
41
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
55
46
:customerscenario: True
56
47
"""
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**%%"
63
51
52
+ ldap .user ("user1" ).add (password = old_password )
64
53
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"
71
55
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
103
56
client .sssd .start ()
104
57
105
58
assert not client .auth .passwd .password (
106
- "user1" , "Secret123" , "Red123" , "Hat000"
59
+ "user1" , old_password , new_password , retyped = invalid_password
107
60
), "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!"
108
65
109
66
110
67
@pytest .mark .ticket (bz = [795044 , 1695574 , 1795220 ])
111
68
@pytest .mark .importance ("critical" )
112
69
@pytest .mark .parametrize ("modify_mode" , ["exop" , "ldap_modify" , "exop_force" ])
113
- @pytest .mark .parametrize ("use_ppolicy" , ["true" , "false" ])
114
70
@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 ,
118
75
):
119
76
"""
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.
121
85
:setup:
122
86
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
166
89
4. Start SSSD
167
90
: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
169
96
: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
171
102
:customerscenario: True
172
103
"""
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 )
175
110
176
111
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"
178
113
client .sssd .start ()
179
114
180
115
assert not client .auth .passwd .password (
181
- "user1" , "wrong123" , "Newpass123"
116
+ "user1" , old_password , invalid_password
182
117
), "Password should not have been able to be changed!"
183
118
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
+
184
123
185
124
@pytest .mark .importance ("low" )
186
125
@pytest .mark .ticket (bz = [1067476 , 1065534 ])
@@ -231,16 +170,14 @@ def test_ldap__authenticate_user_with_whitespace_prefix_in_userid(client: Client
231
170
@pytest .mark .ticket (bz = 1507035 )
232
171
@pytest .mark .topology (KnownTopology .LDAP )
233
172
@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 ):
235
174
"""
236
175
:title: Change password with shadow ldap password policy is set to shadow
237
176
:description: Changing a password when the password policy is managed by the shadowAccount objectclass.
238
177
: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
244
181
:steps:
245
182
1. Authenticate as "tuser" with old password
246
183
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
249
186
2. Authentication with new password was successful
250
187
:customerscenario: True
251
188
"""
252
- ldap .aci .add ('(targetattr="userpassword")(version 3.0; acl "pwp test"; allow (all) userdn="ldap:///self";)' )
253
189
ldap .user ("tuser" ).add (
254
190
uid = 999011 , gid = 999011 , shadowMin = 0 , shadowMax = 99999 , shadowWarning = 7 , shadowLastChange = 0 , password = "Secret123"
255
191
)
@@ -460,10 +396,9 @@ def test_ldap__lookup_and_authenticate_as_user_with_different_object_search_base
460
396
"modify_mode, expected, err_msg" ,
461
397
[("exop" , 1 , "Expected login failure" ), ("exop_force" , 3 , "Expected password change request" )],
462
398
)
463
- @pytest .mark .parametrize ("method" , ["su" , "ssh" ])
464
399
@pytest .mark .topology (KnownTopology .LDAP )
465
400
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
467
402
):
468
403
"""
469
404
:title: Password change when no grace logins left
@@ -500,7 +435,7 @@ def test_ldap__password_change_no_grace_logins_left(
500
435
client .sssd .domain ["ldap_pwmodify_mode" ] = modify_mode
501
436
client .sssd .start ()
502
437
503
- rc , _ , _ , _ = client .auth .parametrize ( method ) .password_with_output ("user1" , "Secret123" )
438
+ rc , _ , _ , _ = client .auth .ssh .password_with_output ("user1" , "Secret123" )
504
439
assert rc == expected , err_msg
505
440
506
441
0 commit comments