1414 */
1515class PasswordVerifyTest extends TestCase
1616{
17+ // Subclasses can override this to test other wrapper classes
18+ protected string $ wrapperClassName = '\SimpleSAML\Test\Module\sqlauth\Auth\Source\PasswordVerifyWrapper ' ;
19+
1720 /** @var array<string, string> */
1821 private array $ info = ['AuthId ' => 'testAuthId ' ];
1922
@@ -83,7 +86,7 @@ public function testBasicSingleSuccess(): void
8386 {
8487 // Correct username/password
8588 $ this ->config ['query ' ] = "select givenName, email, passwordhash from users where uid=:username " ;
86- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
89+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
8790 asort ($ ret );
8891 $ this ->assertCount (2 , $ ret );
8992 $ this ->assertEquals ($ ret , [
@@ -98,7 +101,7 @@ public function testBasicSingleFailedLogin(): void
98101 $ this ->expectException (\SimpleSAML \Error \Error::class);
99102 // Wrong username/password
100103 $ this ->config ['query ' ] = "select givenName, email, passwordhash from users where uid=:username " ;
101- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('alice ' , 'wrong ' );
104+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('alice ' , 'wrong ' );
102105 $ this ->assertCount (0 , $ ret );
103106 }
104107
@@ -107,7 +110,7 @@ public function testBasicSingleFailedLoginNonExisting(): void
107110 $ this ->expectException (\SimpleSAML \Error \Error::class);
108111 // Wrong username/password
109112 $ this ->config ['query ' ] = "select givenName, email, passwordhash from users where uid=:username " ;
110- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('henry ' , 'boo ' );
113+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('henry ' , 'boo ' );
111114 $ this ->assertCount (0 , $ ret );
112115 }
113116
@@ -117,7 +120,7 @@ public function testBasicSingleFailedLoginNonExistingNoPassword(): void
117120 $ this ->expectException (\SimpleSAML \Error \Error::class);
118121 // Wrong username/password
119122 $ this ->config ['query ' ] = "select givenName, email, passwordhash from users where uid=:username " ;
120- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('alice2 ' , '' );
123+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('alice2 ' , '' );
121124 $ this ->assertCount (0 , $ ret );
122125 }
123126
@@ -129,7 +132,7 @@ public function testJoinSingleSuccess(): void
129132 select u.givenName, u.email, ug.groupname, passwordhash
130133 from users u left join usergroups ug on (u.uid=ug.uid)
131134 where u.uid=:username " ;
132- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
135+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
133136 asort ($ ret );
134137 asort ($ ret ['groupname ' ]);
135138 $ this ->assertCount (3 , $ ret );
@@ -148,7 +151,7 @@ public function testJoinSingleFailedLogin(): void
148151 select u.givenName, u.email, ug.groupname, passwordhash
149152 from users u left join usergroups ug on (u.uid=ug.uid)
150153 where u.uid=:username " ;
151- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('alice ' , 'wrong ' );
154+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('alice ' , 'wrong ' );
152155 $ this ->assertCount (0 , $ ret );
153156 }
154157
@@ -159,7 +162,7 @@ public function testMultiQuerySuccess(): void
159162 "select givenName, email, passwordhash from users where uid=:username " ,
160163 "select groupname from usergroups where uid=:username " ,
161164 ];
162- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
165+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
163166 asort ($ ret );
164167 asort ($ ret ['groupname ' ]);
165168 $ this ->assertCount (3 , $ ret );
@@ -178,7 +181,7 @@ public function testMultiQueryFailedLogin(): void
178181 "select givenName, email, passwordhash from users where uid=:username " ,
179182 "select groupname from usergroups where uid=:username " ,
180183 ];
181- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('alice ' , 'wrong ' );
184+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('alice ' , 'wrong ' );
182185 $ this ->assertCount (0 , $ ret );
183186 }
184187
@@ -191,7 +194,7 @@ public function testMultiQuerySubsequentNoRowsSuccess(): void
191194 "select groupname from usergroups where uid=:username and groupname like '%nomatch%' " ,
192195 "select groupname from usergroups where uid=:username and groupname like 'stud%' " ,
193196 ];
194- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
197+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
195198 asort ($ ret );
196199 asort ($ ret ['groupname ' ]);
197200 $ this ->assertCount (3 , $ ret );
@@ -210,7 +213,7 @@ public function testMultiQuerySubsequentAppendSuccess(): void
210213 "select groupname from usergroups where uid=:username and groupname like 'stud%' " ,
211214 "select groupname from usergroups where uid=:username and groupname like '%sers' " ,
212215 ];
213- $ ret = (new PasswordVerifyWrapper ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
216+ $ ret = (new $ this -> wrapperClassName ($ this ->info , $ this ->config ))->callLogin ('bob ' , 'password1 ' );
214217 asort ($ ret );
215218 asort ($ ret ['groupname ' ]);
216219 $ this ->assertCount (3 , $ ret );
0 commit comments