Skip to content

Commit

Permalink
Merging develop into master and deprecating develop branch (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Dec 4, 2018
1 parent d4029b2 commit f2479fb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 19 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
language: php
dist: precise
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- 7.2
script:
- phpunit
- vendor/bin/phpunit
before_script:
- composer install
- composer require --dev phpunit/phpunit
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"homepage": "http://github.com/bshaffer/oauth2-server-httpfoundation-bridge",
"require":{
"php":">=5.3.0",
"symfony/http-foundation": ">=2.1",
"bshaffer/oauth2-server-php": ">=0.9"
"bshaffer/oauth2-server-php": ">=0.9",
"symfony/http-foundation": ">=2.1"
},
"autoload": {
"psr-0": { "OAuth2\\HttpFoundationBridge": "src/" }
Expand Down
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./test/bootstrap.php">
<phpunit bootstrap="./test/bootstrap.php"
convertWarningsToExceptions="false">
<testsuites>
<testsuite name="OAuth2 Server HttpFoundation Bridge Test Suite">
<directory suffix="Test.php">./test</directory>
Expand Down
16 changes: 8 additions & 8 deletions src/OAuth2/HttpFoundationBridge/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/**
*
*/
class Request extends BaseRequest implements RequestInterface
{
class Request extends BaseRequest implements RequestInterface
{
public function query($name, $default = null)
{
return $this->query->get($name, $default);
Expand Down Expand Up @@ -46,9 +46,9 @@ public static function createFromRequestStack(RequestStack $request)
$request = $request->getCurrentRequest();
return self::createFromRequest($request);
}

/**
* Creates a new request with values from PHP's super globals.
* Creates a new request with values from PHP's super globals.
* Overwrite to fix an apache header bug. Read more here:
* http://stackoverflow.com/questions/11990388/request-headers-bag-is-missing-authorization-header-in-symfony-2%E2%80%94
*
Expand All @@ -59,13 +59,13 @@ public static function createFromRequestStack(RequestStack $request)
public static function createFromGlobals()
{
$request = parent::createFromGlobals();

//fix the bug.
self::fixAuthHeader($request->headers);

return $request;
}

/**
* PHP does not include HTTP_AUTHORIZATION in the $_SERVER array, so this header is missing.
* We retrieve it from apache_request_headers()
Expand All @@ -83,4 +83,4 @@ protected static function fixAuthHeader(\Symfony\Component\HttpFoundation\Header
}
}
}
}
}
14 changes: 11 additions & 3 deletions src/OAuth2/HttpFoundationBridge/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
*
*/
class Response extends JsonResponse implements ResponseInterface
class Response extends JsonResponse implements ResponseInterface
{
public function addParameters(array $parameters)
{
Expand Down Expand Up @@ -59,10 +59,18 @@ public function setRedirect($statusCode = 302, $url, $state = null, $error = nul
if ($params) {
// add the params to the URL
$parts = parse_url($url);
$sep = isset($parts['query']) && count($parts['query']) > 0 ? '&' : '?';
$sep = isset($parts['query']) && !empty($parts['query']) ? '&' : '?';
$url .= $sep . http_build_query($params);
}

$this->headers->set('Location', $url);
}
}

/**
* @param int $statusCode
*/
public function setStatusCode($statusCode, $text = null)
{
return parent::setStatusCode($statusCode);
}
}
4 changes: 2 additions & 2 deletions test/OAuth2/HttpFoundationBridge/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
{
public function testFixAuthHeader()
{
require_once __DIR__ .'/../../includes/apache_request_headers.php';
require_once __DIR__ .'/../../includes/apache_request_headers.php';

\set_apache_request_headers(array('Authorization' => 'Bearer xyz'));
\set_apache_request_headers(array('Authorization' => 'Bearer xyz'));

$request = Request::createFromGlobals();

Expand Down
15 changes: 14 additions & 1 deletion test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,17 @@

if (file_exists($autoload_file = __DIR__.'/../vendor/autoload.php')) {
require_once $autoload_file;
}
}

// Allows us to test across multiple versions of PHPUnit
if (!class_exists('\PHPUnit\Framework\TestCase', true)) {
class_alias(
'\PHPUnit_Framework_TestCase',
'\PHPUnit\Framework\TestCase'
);
} elseif (!class_exists('\PHPUnit_Framework_TestCase', true)) {
class_alias(
'\PHPUnit\Framework\TestCase',
'\PHPUnit_Framework_TestCase'
);
}

0 comments on commit f2479fb

Please sign in to comment.