Browse Source

should always return 200

pull/39/head
Aaron Parecki 7 years ago
parent
commit
ac32522c25
No known key found for this signature in database GPG Key ID: 3745E500B4FF7CB1
2 changed files with 5 additions and 5 deletions
  1. +2
    -2
      controllers/Token.php
  2. +3
    -3
      tests/TokenTest.php

+ 2
- 2
controllers/Token.php View File

@ -82,7 +82,7 @@ class Token {
// Catch HTTP errors here such as timeouts // Catch HTTP errors here such as timeouts
if($token['error']) { if($token['error']) {
return $this->respond($response, 400, [
return $this->respond($response, 200, [
'error' => $token['error'], 'error' => $token['error'],
'error_description' => $token['error_description'] ?: 'An unknown error occurred trying to fetch the token' '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']; $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=[]) { private function respond(Response $response, $code, $params, $headers=[]) {

+ 3
- 3
tests/TokenTest.php View File

@ -124,7 +124,7 @@ class TokenTest extends PHPUnit_Framework_TestCase {
$response = $this->token(['source' => $url, 'code' => '1234']); $response = $this->token(['source' => $url, 'code' => '1234']);
$body = $response->getContent(); $body = $response->getContent();
$this->assertEquals(400, $response->getStatusCode());
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body); $data = json_decode($body);
$this->assertObjectHasAttribute('error', $data); $this->assertObjectHasAttribute('error', $data);
@ -136,7 +136,7 @@ class TokenTest extends PHPUnit_Framework_TestCase {
$response = $this->token(['source' => $url, 'code' => '1234']); $response = $this->token(['source' => $url, 'code' => '1234']);
$body = $response->getContent(); $body = $response->getContent();
$this->assertEquals(400, $response->getStatusCode());
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body); $data = json_decode($body);
$this->assertObjectHasAttribute('error', $data); $this->assertObjectHasAttribute('error', $data);
@ -148,7 +148,7 @@ class TokenTest extends PHPUnit_Framework_TestCase {
$response = $this->token(['source' => $url, 'code' => '1234']); $response = $this->token(['source' => $url, 'code' => '1234']);
$body = $response->getContent(); $body = $response->getContent();
$this->assertEquals(400, $response->getStatusCode());
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('text/plain', $response->headers->get('content-type')); $this->assertEquals('text/plain', $response->headers->get('content-type'));
$this->assertEquals('Invalid request', $body); $this->assertEquals('Invalid request', $body);
} }

Loading…
Cancel
Save