@@ -131,9 +131,43 @@ public function test_auth_fails_when_user_not_found()
131
131
$ this ->
assertFalse (Auth::
attempt ([
'email ' =>
'[email protected] ' ,
'password ' =>
'12345 ' ]));
132
132
}
133
133
134
- public function test_credentials_key_does_not_exist ()
134
+ public function test_config_limitation_filter ()
135
135
{
136
- $ this ->
assertFalse (Auth::
attempt ([
'non-existent-key ' =>
'[email protected] ' ,
'password ' =>
'12345 ' ]));
136
+ $ filter = '(cn=John Doe) ' ;
137
+
138
+ $ expectedFilter = '(&(cn=John Doe)(objectclass=\70\65\72\73\6f\6e)(objectcategory=\70\65\72\73\6f\6e)(mail=\6a\64\6f\65\40\65\6d\61\69\6c\2e\63\6f\6d)) ' ;
139
+
140
+ $ this ->app ['config ' ]->set ('adldap_auth.limitation_filter ' , $ filter );
141
+
142
+ $ user = $ this ->getMockUser ([
143
+ 'cn ' => '' ,
144
+
145
+ 'samaccountname ' => 'jdoe ' ,
146
+ ]);
147
+
148
+ $ connection = $ this ->getMockConnection ();
149
+
150
+ $ connection ->expects ($ this ->exactly (1 ))->method ('isBound ' )->willReturn (true );
151
+
152
+ $ connection ->expects ($ this ->exactly (1 ))->method ('search ' )->with (
153
+ $ this ->equalTo ('' ),
154
+ $ this ->equalTo ($ expectedFilter ),
155
+ $ this ->equalTo ([])
156
+ )->willReturn ('resource ' );
157
+
158
+ $ connection ->expects ($ this ->exactly (1 ))->method ('getEntries ' )->willReturn ([
159
+ 'count ' => 1 ,
160
+ $ user ->getAttributes (),
161
+ ]);
162
+
163
+ $ connection ->expects ($ this ->exactly (2 ))->method ('bind ' )
164
+ ->with ($ this ->logicalOr (
165
+ $ this ->equalTo ('jdoe ' ),
166
+ $ this ->equalTo ('admin ' )
167
+ ))
168
+ ->willReturn (true );
169
+
170
+ $ this ->
assertTrue (Auth::
attempt ([
'email ' =>
'[email protected] ' ,
'password ' =>
'password ' ]));
137
171
}
138
172
139
173
public function test_config_callback_attribute_handler ()
0 commit comments