Skip to content

Commit edfbe4b

Browse files
committed
Better unit testing, now we can log to stdout
1 parent 959f5b7 commit edfbe4b

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

tests/lib/Auth/Process/FticksTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ protected function setUp()
5151
{
5252
\SimpleSAML_Configuration::loadFromArray(array(
5353
'secretsalt' => 'secretsalt',
54-
'logging.format' => '%msg',
5554
), '[ARRAY]', 'simplesaml');
5655
/*
5756
$rm = new ReflectionMethod('SimpleSAML\Logger', 'createLoggingHandler');
@@ -62,33 +61,37 @@ protected function setUp()
6261

6362
public function testMinimal()
6463
{
65-
$config = array('federation' => 'ACME',);
64+
$config = array('federation' => 'ACME', 'logdest' => 'stdout');
6665
$request = self::$_minrequest;
66+
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL','/').'[^#]+#TS=\d+#$/');
6767
$result = self::processFilter($config, $request);
6868
}
6969

7070
public function testAsServiceProvider()
7171
{
72-
$config = array('federation' => 'ACME',);
72+
$config = array('federation' => 'ACME', 'logdest' => 'stdout',);
7373
$request = array_merge(self::$_minrequest, self::$_sprequest);
74+
$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#','/').'$/');
7475
$result = self::processFilter($config, $request);
7576
}
7677

7778
public function testSPwithUserId()
7879
{
79-
$config = array('federation' => 'ACME', 'userId' => 'eduPersonPrincipalName');
80+
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'userId' => 'eduPersonPrincipalName');
8081
$request = array_merge(self::$_minrequest, self::$_sprequest, array(
8182
'Attributes' => array(
8283
'eduPersonPrincipalName' => 'user2@example.net',
8384
),
8485
));
86+
$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#','/').'$/');
8587
$result = self::processFilter($config, $request);
8688
}
8789

8890
public function testAsIdentityProvider()
8991
{
90-
$config = array('federation' => 'ACME',);
92+
$config = array('federation' => 'ACME', 'logdest' => 'stdout',);
9193
$request = array_merge(self::$_minrequest, self::$_idprequest);
94+
$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+#$/');
9295
$result = self::processFilter($config, $request);
9396
}
9497

@@ -101,27 +104,31 @@ public function testExample()
101104
'realm' => 'schacHomeOrganization',
102105
'algorithm' => 'sha512',
103106
'exclude' => array('PN'),
107+
'logdest' => 'stdout',
104108
);
105109
$request = array_merge(self::$_minrequest, self::$_idprequest, array(
106110
'Attributes' => array(
107111
'eduPersonPrincipalName' => 'user3@example.com',
108112
'schacHomeOrganization' => 'example.com',
109113
),
110114
));
115+
$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#$/');
111116
$result = self::processFilter($config, $request);
112117
}
113118

114119
public function testFilteringArray()
115120
{
116-
$config = array('federation' => 'ACME', 'exclude' => array('PN', 'AM'));
121+
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => array('PN', 'AM'));
117122
$request = array_merge(self::$_minrequest, self::$_idprequest);
123+
$this->expectOutputRegex('/^'.preg_quote('F-TICKS/ACME/1.0#RESULT=OK#AP=https://localhost/sp#RP=https://localhost/idp#CSI=CL','/').'[^#]+#TS=\d+#$/');
118124
$result = self::processFilter($config, $request);
119125
}
120126

121127
public function testFilteringString()
122128
{
123-
$config = array('federation' => 'ACME', 'exclude' => 'AM');
129+
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => 'AM');
124130
$request = array_merge(self::$_minrequest, self::$_idprequest);
131+
$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+#$/');
125132
$result = self::processFilter($config, $request);
126133
}
127134
}

0 commit comments

Comments
 (0)