forked from arnaud-lb/oauth2-php
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #72
- Loading branch information
Florent Morselli
committed
Dec 29, 2014
1 parent
23e7653
commit 52d3001
Showing
2 changed files
with
43 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
use OAuth2\OAuth2; | ||
use OAuth2\Model\OAuth2Client; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use OAuth2\Tests\Fixtures\OAuth2GrantUserStub; | ||
|
||
/** | ||
* Extra Headers test case. | ||
*/ | ||
class ExtraHeadersTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testErrorResponseContainsExtraHeaders() | ||
{ | ||
$config = array( | ||
OAuth2::CONFIG_RESPONSE_EXTRA_HEADERS => array( | ||
"Access-Control-Allow-Origin" => "http://www.foo.com", | ||
"X-Extra-Header-1" => "Foo-Bar", | ||
), | ||
); | ||
$stub = new OAuth2GrantUserStub(); | ||
$stub->addClient(new OAuth2Client('cid', 'cpass')); | ||
$stub->addUser('foo', 'bar'); | ||
$stub->setAllowedGrantTypes(array('authorization_code', 'password')); | ||
|
||
$oauth2 = new OAuth2($stub, $config); | ||
|
||
$response = $oauth2->grantAccessToken(new Request(array( | ||
'grant_type' => 'password', | ||
'client_id' => 'cid', | ||
'client_secret' => 'cpass', | ||
'username' => 'foo', | ||
'password' => 'bar', | ||
))); | ||
$this->assertSame("http://www.foo.com", $response->headers->get("Access-Control-Allow-Origin")); | ||
$this->assertSame("Foo-Bar", $response->headers->get("X-Extra-Header-1")); | ||
} | ||
} |