11<?php
2+
3+ namespace SimpleSAML \Test \Module \fticks \Auth \Process ;
4+
25// Alias the PHPUnit 6.0 ancestor if available, else fall back to legacy ancestor
36if (class_exists ('\PHPUnit\Framework\TestCase ' , true ) and !class_exists ('\PHPUnit_Framework_TestCase ' , true )) {
47 class_alias ('\PHPUnit\Framework\TestCase ' , '\PHPUnit_Framework_TestCase ' , true );
58}
9+ require_once (dirname (dirname (dirname (dirname (dirname (__FILE__ ))))).'/lib/Auth/Process/Fticks.php ' );
610
711/**
812 * Test for the core:CardinalitySingle filter.
913 */
10- class sspmod_fticks_Auth_Process_FticksTest extends \PHPUnit_Framework_TestCase
14+ class FticksTest extends \PHPUnit_Framework_TestCase
1115{
1216 /** @var array minimal request */
13- private static $ _minrequest = array (
14- 'Source ' => array (
17+ private static $ _minrequest = [
18+ 'Source ' => [
1519 'entityid ' => 'https://localhost/sp ' ,
16- ) ,
17- 'Destination ' => array (
20+ ] ,
21+ 'Destination ' => [
1822 'entityid ' => 'https://localhost/idp ' ,
19- ) ,
20- ) ;
23+ ] ,
24+ ] ;
2125
2226 /** @var array SP request */
23- private static $ _sprequest = array (
27+ private static $ _sprequest =[
2428 'saml:sp:IdP ' => 'https://localhost/saml:sp:IdP ' ,
2529 'saml:sp:SessionIndex ' => 'saml:sp:SessionIndex ' ,
26- 'saml:sp:State ' => array (
30+ 'saml:sp:State ' => [
2731 'saml:sp:AuthnContext ' => 'urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified ' ,
2832 'saml:AuthnInstant ' => 1000 ,
29- ) ,
30- ) ;
33+ ] ,
34+ ] ;
3135
3236 /** @var array IdP request */
33- private static $ _idprequest = array (
37+ private static $ _idprequest = [
3438 'SimpleSAML_Auth_State.id ' => 'SimpleSAML_Auth_State.id ' ,
3539 'SimpleSAML_Auth_State.stage ' => 'sspmod_core_Auth_UserPassBase.state ' ,
3640 'UserID ' => 'user1@example.org ' ,
37- ) ;
41+ ] ;
3842
3943 /**
4044 * Helper function to run the filter with a given configuration.
@@ -45,7 +49,7 @@ class sspmod_fticks_Auth_Process_FticksTest extends \PHPUnit_Framework_TestCase
4549 */
4650 private static function processFilter (array $ config , array $ request )
4751 {
48- $ filter = new \sspmod_fticks_Auth_Process_Fticks ($ config , null );
52+ $ filter = new \SimpleSAML \ Module \ fticks \ Auth \ Process \ Fticks ($ config , null );
4953 $ filter ->process ($ request );
5054 return $ request ;
5155 }
@@ -55,13 +59,13 @@ private static function processFilter(array $config, array $request)
5559 */
5660 protected function setUp ()
5761 {
58- \SimpleSAML_Configuration ::loadFromArray (array (
62+ \SimpleSAML \Configuration ::loadFromArray ([
5963 'secretsalt ' => 'secretsalt ' ,
60- ) , '[ARRAY] ' , 'simplesaml ' );
64+ ] , '[ARRAY] ' , 'simplesaml ' );
6165 /*
62- $rm = new ReflectionMethod('SimpleSAML\Logger', 'createLoggingHandler');
66+ $rm = new ReflectionMethod('\ SimpleSAML\Logger', 'createLoggingHandler');
6367 $rm->setAccessible(true);
64- $rm->invoke('SimpleSAML\Logger\StandardErrorLoggingHandler');
68+ $rm->invoke('\ SimpleSAML\Logger\StandardErrorLoggingHandler');
6569 */
6670 }
6771
@@ -70,7 +74,7 @@ protected function setUp()
7074 */
7175 public function testMinimal ()
7276 {
73- $ config = array ( 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' ) ;
77+ $ config = [ 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' ] ;
7478 $ request = self ::$ _minrequest ;
7579 $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' ,'/ ' ).'[^#]+#TS=\d+#$/ ' );
7680 $ result = self ::processFilter ($ config , $ request );
@@ -81,7 +85,7 @@ public function testMinimal()
8185 */
8286 public function testAsServiceProvider ()
8387 {
84- $ config = array ( 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' ,) ;
88+ $ config = [ 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' ,] ;
8589 $ request = array_merge (self ::$ _minrequest , self ::$ _sprequest );
8690 $ 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# ' ,'/ ' ).'$/ ' );
8791 $ result = self ::processFilter ($ config , $ request );
@@ -92,12 +96,12 @@ public function testAsServiceProvider()
9296 */
9397 public function testSPwithUserId ()
9498 {
95- $ config = array ( 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'userId ' => 'eduPersonPrincipalName ' ) ;
96- $ request = array_merge (self ::$ _minrequest , self ::$ _sprequest , array (
97- 'Attributes ' => array (
99+ $ config = [ 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'userId ' => 'eduPersonPrincipalName ' ] ;
100+ $ request = array_merge (self ::$ _minrequest , self ::$ _sprequest , [
101+ 'Attributes ' => [
98102 'eduPersonPrincipalName ' => 'user2@example.net ' ,
99- ) ,
100- ) );
103+ ] ,
104+ ] );
101105 $ 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# ' ,'/ ' ).'$/ ' );
102106 $ result = self ::processFilter ($ config , $ request );
103107 }
@@ -107,7 +111,7 @@ public function testSPwithUserId()
107111 */
108112 public function testAsIdentityProvider ()
109113 {
110- $ config = array ( 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' ,) ;
114+ $ config = [ 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' ,] ;
111115 $ request = array_merge (self ::$ _minrequest , self ::$ _idprequest );
112116 $ 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+#$/ ' );
113117 $ result = self ::processFilter ($ config , $ request );
@@ -118,21 +122,21 @@ public function testAsIdentityProvider()
118122 */
119123 public function testExample ()
120124 {
121- $ config = array (
125+ $ config = [
122126 'federation ' => 'ACME ' ,
123127 'salt ' => 'someVerySecretStringDifferentFromTheDefault ' ,
124128 'userId ' => 'eduPersonPrincipalName ' ,
125129 'realm ' => 'schacHomeOrganization ' ,
126130 'algorithm ' => 'sha512 ' ,
127- 'exclude ' => array ( 'PN ' ) ,
131+ 'exclude ' => [ 'PN ' ] ,
128132 'logdest ' => 'stdout ' ,
129- ) ;
130- $ request = array_merge (self ::$ _minrequest , self ::$ _idprequest , array (
131- 'Attributes ' => array (
133+ ] ;
134+ $ request = array_merge (self ::$ _minrequest , self ::$ _idprequest , [
135+ 'Attributes ' => [
132136 'eduPersonPrincipalName ' => 'user3@example.com ' ,
133137 'schacHomeOrganization ' => 'example.com ' ,
134- ) ,
135- ) );
138+ ] ,
139+ ] );
136140 $ 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#$/ ' );
137141 $ result = self ::processFilter ($ config , $ request );
138142 }
@@ -142,7 +146,7 @@ public function testExample()
142146 */
143147 public function testFilteringArray ()
144148 {
145- $ config = array ( 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'exclude ' => array ( 'PN ' , 'AM ' )) ;
149+ $ config = [ 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'exclude ' => [ 'PN ' , 'AM ' ]] ;
146150 $ request = array_merge (self ::$ _minrequest , self ::$ _idprequest );
147151 $ this ->expectOutputRegex ('/^ ' .preg_quote ('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL ' ,'/ ' ).'[^#]+#TS=\d+#$/ ' );
148152 $ result = self ::processFilter ($ config , $ request );
@@ -153,7 +157,7 @@ public function testFilteringArray()
153157 */
154158 public function testFilteringString ()
155159 {
156- $ config = array ( 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'exclude ' => 'AM ' ) ;
160+ $ config = [ 'federation ' => 'ACME ' , 'logdest ' => 'stdout ' , 'exclude ' => 'AM ' ] ;
157161 $ request = array_merge (self ::$ _minrequest , self ::$ _idprequest );
158162 $ 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+#$/ ' );
159163 $ result = self ::processFilter ($ config , $ request );
0 commit comments