File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use UnityWebPortal \lib \exceptions \PhpUnitNoDieException ;
4+ use PHPUnit \Framework \TestCase ;
5+ use PHPUnit \Framework \Attributes \DataProvider ;
6+
7+ class InvalidEPPNTest extends TestCase
8+ {
9+ public static function provider ()
10+ {
11+ return [
12+ ["" , false ],
13+ ["a " , false ],
14+ ["a@b " , true ],
15+ ["a@b@c " , false ],
16+ ];
17+ }
18+
19+ #[DataProvider("provider " )]
20+ public function testInitGetSSO (string $ eppn , bool $ is_valid ): void
21+ {
22+ global $ SSO ;
23+ $ original_server = $ _SERVER ;
24+ $ original_sso = $ SSO ;
25+ if (!$ is_valid ) {
26+ $ this ->expectException (PhpUnitNoDieException::class);
27+ $ this ->expectExceptionMessageMatches ("/.*Invalid eppn.*/ " );
28+ }
29+ try {
30+ $ _SERVER ["REMOTE_USER " ] = $ eppn ;
31+ $ _SERVER ["REMOTE_ADDR " ] = "127.0.0.1 " ;
32+ $ _SERVER ["eppn " ] = $ eppn ;
33+ $ _SERVER ["givenName " ] = "foo " ;
34+ $ _SERVER ["sn " ] = "bar " ;
35+ // can't use http_get because it does `require_once`
36+ // won't use phpunit --process-isolation because when I try that argument all tests fail with a blank error message
37+ include __DIR__ . "/../../resources/init.php " ;
38+ } finally {
39+ session_destroy (); // autoload does session_start()
40+ $ _SERVER = $ original_server ;
41+ $ SSO = $ original_sso ;
42+ }
43+ $ this ->assertTrue (true ); // if $is_valid, there are no other assertions
44+ }
45+ }
Original file line number Diff line number Diff line change 1919require_once __DIR__ . "/../resources/lib/UnityRedis.php " ;
2020require_once __DIR__ . "/../resources/lib/UnityGithub.php " ;
2121require_once __DIR__ . "/../resources/lib/exceptions/PhpUnitNoDieException.php " ;
22+ require_once __DIR__ . "/../resources/lib/exceptions/SSOException.php " ;
2223
2324$ GLOBALS ["PHPUNIT_NO_DIE_PLEASE " ] = true ;
2425
You can’t perform that action at this time.
0 commit comments