22
33namespace SimpleSAML \Test \Module \fticks \Auth \Process ;
44
5- class FticksTest extends \PHPUnit_Framework_TestCase
5+ use PHPUnit \Framework \TestCase ;
6+ use SimpleSAML \Module \fticks \Auth \Process \Fticks ;
7+ use SimpleSAML \Configuration ;
8+ use SimpleSAML \Logger ;
9+ use SimpleSAML \Logger \StandardErrorLoggingHandler ;
10+
11+ class FticksTest extends TestCase
612{
713 /** @var array minimal request */
814 private static $ minRequest = [
@@ -40,7 +46,7 @@ class FticksTest extends \PHPUnit_Framework_TestCase
4046 */
4147 private static function processFilter (array $ config , array $ request )
4248 {
43- $ filter = new \ SimpleSAML \ Module \ fticks \ Auth \ Process \ Fticks ($ config , null );
49+ $ filter = new Fticks ($ config , null );
4450 $ filter ->process ($ request );
4551 return $ request ;
4652 }
@@ -50,13 +56,13 @@ private static function processFilter(array $config, array $request)
5056 */
5157 protected function setUp ()
5258 {
53- \ SimpleSAML \ Configuration::loadFromArray ([
59+ Configuration::loadFromArray ([
5460 'secretsalt ' => 'secretsalt ' ,
5561 ], '[ARRAY] ' , 'simplesaml ' );
5662 /*
57- $rm = new ReflectionMethod('\SimpleSAML\ Logger' , 'createLoggingHandler');
63+ $rm = new ReflectionMethod(Logger::class , 'createLoggingHandler');
5864 $rm->setAccessible(true);
59- $rm->invoke('\SimpleSAML\Logger\ StandardErrorLoggingHandler' );
65+ $rm->invoke(StandardErrorLoggingHandler::class );
6066 */
6167 }
6268
@@ -67,7 +73,8 @@ public function testMinimal()
6773 {
6874 $ config = ['federation ' => 'ACME ' , 'logdest ' => 'stdout ' ];
6975 $ request = self ::$ minRequest ;
70- $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' ).'[^#]+#TS=\d+#$/ ' );
76+ $ pattern = preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' );
77+ $ this ->expectOutputRegex ('/^ ' .$ pattern .'[^#]+#TS=\d+#$/ ' );
7178 $ result = self ::processFilter ($ config , $ request );
7279 }
7380
@@ -78,7 +85,9 @@ public function testAsServiceProvider()
7885 {
7986 $ config = ['federation ' => 'ACME ' , 'logdest ' => 'stdout ' ,];
8087 $ request = array_merge (self ::$ minRequest , self ::$ spRequest );
81- $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/saml:sp:IdP#RP=https://localhost/idp#CSI=CL ' , '/ ' ).'[^#]+ ' .preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified#TS=1000# ' , '/ ' ).'$/ ' );
88+ $ pattern1 = preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/saml:sp:IdP#RP=https://localhost/idp#CSI=CL ' , '/ ' );
89+ $ pattern2 = preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified#TS=1000# ' , '/ ' );
90+ $ this ->expectOutputRegex ('/^ ' .$ pattern1 .'[^#]+ ' .$ pattern2 .'$/ ' );
8291 $ result = self ::processFilter ($ config , $ request );
8392 }
8493
@@ -93,7 +102,9 @@ public function testSPwithUserId()
93102 'eduPersonPrincipalName ' => 'user2@example.net ' ,
94103 ],
95104 ]);
96- $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/saml:sp:IdP#RP=https://localhost/idp#CSI=CL ' , '/ ' ).'[^#]+ ' .preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified#PN=e5d066a96d5809a21264e153013c3c793e6574cb77afdfa248ad2cefab9b0451#TS=1000# ' , '/ ' ).'$/ ' );
105+ $ pattern1 = preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/saml:sp:IdP#RP=https://localhost/idp#CSI=CL ' , '/ ' );
106+ $ pattern2 = preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified#PN=e5d066a96d5809a21264e153013c3c793e6574cb77afdfa248ad2cefab9b0451#TS=1000# ' , '/ ' );
107+ $ this ->expectOutputRegex ('/^ ' .$ pattern1 .'[^#]+ ' .$ pattern2 .'$/ ' );
97108 $ result = self ::processFilter ($ config , $ request );
98109 }
99110
@@ -104,7 +115,9 @@ public function testAsIdentityProvider()
104115 {
105116 $ config = ['federation ' => 'ACME ' , 'logdest ' => 'stdout ' ,];
106117 $ request = array_merge (self ::$ minRequest , self ::$ idpRequest );
107- $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' ).'[^#]+ ' .preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:Password#PN=d844a9a0666bb3990e88f72b8f5c20accbcfa46f7b8a7ab38593bfbbab6e9cbc#TS= ' , '/ ' ).'\d+#$/ ' );
118+ $ pattern1 = preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' );
119+ $ pattern2 = preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:Password#PN=d844a9a0666bb3990e88f72b8f5c20accbcfa46f7b8a7ab38593bfbbab6e9cbc#TS= ' , '/ ' );
120+ $ this ->expectOutputRegex ('/^ ' .$ pattern1 .'[^#]+ ' .$ pattern2 .'\d+#$/ ' );
108121 $ result = self ::processFilter ($ config , $ request );
109122 }
110123
@@ -128,7 +141,9 @@ public function testExample()
128141 'schacHomeOrganization ' => 'example.com ' ,
129142 ],
130143 ]);
131- $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' ).'[^#]+ ' .preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:Password#TS= ' , '/ ' ).'\d+#REALM=example.com#$/ ' );
144+ $ pattern1 = preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' );
145+ $ pattern2 = preg_quote ('#AM=urn:oasis:names:tc:SAML:2.0:ac:classes:Password#TS= ' , '/ ' );
146+ $ this ->expectOutputRegex ('/^ ' .$ pattern1 .'[^#]+ ' .$ pattern2 .'\d+#REALM=example.com#$/ ' );
132147 $ result = self ::processFilter ($ config , $ request );
133148 }
134149
@@ -139,7 +154,8 @@ public function testFilteringArray()
139154 {
140155 $ config = ['federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'exclude ' => ['PN ' , 'AM ' ]];
141156 $ request = array_merge (self ::$ minRequest , self ::$ idpRequest );
142- $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' ).'[^#]+#TS=\d+#$/ ' );
157+ $ pattern1 = preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' );
158+ $ this ->expectOutputRegex ('/^ ' .$ pattern1 .'[^#]+#TS=\d+#$/ ' );
143159 $ result = self ::processFilter ($ config , $ request );
144160 }
145161
@@ -150,7 +166,9 @@ public function testFilteringString()
150166 {
151167 $ config = ['federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'exclude ' => 'AM ' ];
152168 $ request = array_merge (self ::$ minRequest , self ::$ idpRequest );
153- $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' ).'[^#]+ ' .preg_quote ('#PN=d844a9a0666bb3990e88f72b8f5c20accbcfa46f7b8a7ab38593bfbbab6e9cbc#TS= ' , '/ ' ).'\d+#$/ ' );
169+ $ pattern1 = preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' , '/ ' );
170+ $ pattern2 = preg_quote ('#PN=d844a9a0666bb3990e88f72b8f5c20accbcfa46f7b8a7ab38593bfbbab6e9cbc#TS= ' , '/ ' );
171+ $ this ->expectOutputRegex ('/^ ' .$ pattern1 .'[^#]+ ' .$ pattern2 .'\d+#$/ ' );
154172 $ result = self ::processFilter ($ config , $ request );
155173 }
156174}
0 commit comments