-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from xp-forge/feature/cas-session-namespace
Make it possible to change the session namespace (CAS)
- Loading branch information
Showing
4 changed files
with
43 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
use web\{Error, Request, Response}; | ||
|
||
class CasFlowTest extends FlowTest { | ||
const SNS = 'cas::flow'; | ||
const SSO = 'https://example.com/sso'; | ||
const SERVICE = 'https://service.example.com'; | ||
const TICKET = 'ST-1856339-aA5Yuvrxzpv8Tau1cYQ7'; | ||
|
@@ -147,7 +148,29 @@ public function validate($ticket, $service) { | |
$this->authenticate($fixture, '/?ticket='.self::TICKET, $session); | ||
Assert::equals( | ||
['username' => 'test'], | ||
$session->value(CasFlow::SESSION_KEY) | ||
$session->value(self::SNS) | ||
); | ||
} | ||
|
||
#[Test, Values(['cas::flow', 'flow'])] | ||
public function session_namespace($namespace) { | ||
$fixture= new class(self::SSO) extends CasFlow { | ||
public function validate($ticket, $service) { | ||
return CasFlowTest::response(' | ||
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas"> | ||
<cas:authenticationSuccess> | ||
<cas:user>test</cas:user> | ||
</cas:authenticationSuccess> | ||
</cas:serviceResponse> | ||
'); | ||
} | ||
}; | ||
$session= (new ForTesting())->create(); | ||
|
||
$this->authenticate($fixture->namespaced($namespace), '/?ticket='.self::TICKET, $session); | ||
Assert::equals( | ||
['username' => 'test'], | ||
$session->value($namespace) | ||
); | ||
} | ||
|
||
|
@@ -173,7 +196,7 @@ public function validate($ticket, $service) { | |
$this->authenticate($fixture, '/?ticket='.self::TICKET, $session); | ||
Assert::equals( | ||
['username' => 'test', 'givenName' => 'John Doe', 'email' => '[email protected]'], | ||
$session->value(CasFlow::SESSION_KEY) | ||
$session->value(self::SNS) | ||
); | ||
} | ||
|
||
|
@@ -183,7 +206,7 @@ public function returns_user_in_final_step() { | |
|
||
$fixture= new CasFlow(self::SSO); | ||
$session= (new ForTesting())->create(); | ||
$session->register(CasFlow::SESSION_KEY, $user); | ||
$session->register(self::SNS, $user); | ||
|
||
$req= new Request(new TestInput('GET', '/')); | ||
$res= new Response(new TestOutput()); | ||
|