update check for api key

This commit is contained in:
Nabeel Shahzad 2017-12-30 13:02:22 -06:00
parent 87867746aa
commit caac722a72
2 changed files with 4 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class ApiAuth
{ {
// Check if Authorization header is in place // Check if Authorization header is in place
$auth = $request->header('Authorization', null); $auth = $request->header('Authorization', null);
if(empty($auth)) { if($auth === null) {
return $this->unauthorized('Authorization header missing'); return $this->unauthorized('Authorization header missing');
} }

View File

@ -29,6 +29,9 @@ class ApiTest extends TestCase
$this->withHeaders(['Authorization' => 'invalidKey'])->get($uri) $this->withHeaders(['Authorization' => 'invalidKey'])->get($uri)
->assertStatus(401); ->assertStatus(401);
$this->withHeaders(['Authorization' => ''])->get($uri)
->assertStatus(401);
// Test upper/lower case of Authorization header, etc // Test upper/lower case of Authorization header, etc
$this->withHeaders($this->apiHeaders())->get($uri) $this->withHeaders($this->apiHeaders())->get($uri)
->assertStatus(200) ->assertStatus(200)