From ac32522c2594ec85b1d2bd121feb82662100d1c3 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Thu, 20 Oct 2016 11:41:23 -0700 Subject: [PATCH] should always return 200 --- controllers/Token.php | 4 ++-- tests/TokenTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/Token.php b/controllers/Token.php index b7f12a5..cc99b69 100644 --- a/controllers/Token.php +++ b/controllers/Token.php @@ -82,7 +82,7 @@ class Token { // Catch HTTP errors here such as timeouts if($token['error']) { - return $this->respond($response, 400, [ + return $this->respond($response, 200, [ 'error' => $token['error'], 'error_description' => $token['error_description'] ?: 'An unknown error occurred trying to fetch the token' ]); @@ -97,7 +97,7 @@ class Token { $headers['Content-Type'] = $token['headers']['Content-Type']; } - return $this->respond($response, $token['code'], $body ?: $token['body'], $headers); + return $this->respond($response, 200, $body ?: $token['body'], $headers); } private function respond(Response $response, $code, $params, $headers=[]) { diff --git a/tests/TokenTest.php b/tests/TokenTest.php index 686a449..74b7027 100644 --- a/tests/TokenTest.php +++ b/tests/TokenTest.php @@ -124,7 +124,7 @@ class TokenTest extends PHPUnit_Framework_TestCase { $response = $this->token(['source' => $url, 'code' => '1234']); $body = $response->getContent(); - $this->assertEquals(400, $response->getStatusCode()); + $this->assertEquals(200, $response->getStatusCode()); $data = json_decode($body); $this->assertObjectHasAttribute('error', $data); @@ -136,7 +136,7 @@ class TokenTest extends PHPUnit_Framework_TestCase { $response = $this->token(['source' => $url, 'code' => '1234']); $body = $response->getContent(); - $this->assertEquals(400, $response->getStatusCode()); + $this->assertEquals(200, $response->getStatusCode()); $data = json_decode($body); $this->assertObjectHasAttribute('error', $data); @@ -148,7 +148,7 @@ class TokenTest extends PHPUnit_Framework_TestCase { $response = $this->token(['source' => $url, 'code' => '1234']); $body = $response->getContent(); - $this->assertEquals(400, $response->getStatusCode()); + $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals('text/plain', $response->headers->get('content-type')); $this->assertEquals('Invalid request', $body); }