forked from aacotroneo/laravel-saml2
-
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.
- Loading branch information
Robert Boes
committed
Jul 13, 2017
1 parent
e4cf99e
commit c186802
Showing
1 changed file
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,53 @@ public function testCanGetLastError() | |
$this->assertSame('lastError', $saml2->getLastErrorReason()); | ||
} | ||
|
||
public function testGetUserAttribute() { | ||
$auth = m::mock('OneLogin_Saml2_Auth'); | ||
$saml2 = new Saml2Auth($auth); | ||
|
||
$user = $saml2->getSaml2User(); | ||
|
||
$auth->shouldReceive('getAttribute') | ||
->with('urn:oid:0.9.2342.19200300.100.1.3') | ||
->andReturn(['[email protected]']); | ||
|
||
$this->assertEquals(['[email protected]'], $user->getAttribute('urn:oid:0.9.2342.19200300.100.1.3')); | ||
} | ||
|
||
public function testParseSingleUserAttribute() { | ||
$auth = m::mock('OneLogin_Saml2_Auth'); | ||
$saml2 = new Saml2Auth($auth); | ||
|
||
$user = $saml2->getSaml2User(); | ||
|
||
$auth->shouldReceive('getAttribute') | ||
->with('urn:oid:0.9.2342.19200300.100.1.3') | ||
->andReturn(['[email protected]']); | ||
|
||
$user->parseUserAttribute('urn:oid:0.9.2342.19200300.100.1.3', 'email'); | ||
|
||
$this->assertEquals($user->email, ['[email protected]']); | ||
} | ||
|
||
public function testParseMultipleUserAttributes() { | ||
$auth = m::mock('OneLogin_Saml2_Auth'); | ||
$saml2 = new Saml2Auth($auth); | ||
|
||
$user = $saml2->getSaml2User(); | ||
|
||
$auth->shouldReceive('getAttribute') | ||
->twice() | ||
->andReturn(['[email protected]'], ['Test User']); | ||
|
||
$user->parseAttributes([ | ||
'email' => 'urn:oid:0.9.2342.19200300.100.1.3', | ||
'displayName' => 'urn:oid:2.16.840.1.113730.3.1.241' | ||
]); | ||
|
||
$this->assertEquals($user->email, ['[email protected]']); | ||
$this->assertEquals($user->displayName, ['Test User']); | ||
} | ||
|
||
/** | ||
* Cant test here. It uses Laravel dependencies (eg. config()) | ||
*/ | ||
|