-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from ProfiCloS/feature/api-token
feature/api-token
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/** | ||
* User: czPechy | ||
* Date: 30/07/2018 | ||
* Time: 22:42 | ||
*/ | ||
|
||
namespace Cloudflare\API\Auth; | ||
|
||
class APIToken implements Auth | ||
{ | ||
private $apiToken; | ||
|
||
public function __construct(string $apiToken) | ||
{ | ||
$this->apiToken = $apiToken; | ||
} | ||
|
||
public function getHeaders(): array | ||
{ | ||
return [ | ||
'Authorization' => 'Bearer ' . $this->apiToken | ||
]; | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
/** | ||
* User: czPechy | ||
* Date: 30/07/2018 | ||
* Time: 23:25 | ||
*/ | ||
class APITokenTest extends TestCase | ||
{ | ||
public function testGetHeaders() | ||
{ | ||
$auth = new \Cloudflare\API\Auth\APIToken('zKq9RDO6PbCjs6PRUXF3BoqFi3QdwY36C2VfOaRy'); | ||
$headers = $auth->getHeaders(); | ||
|
||
$this->assertArrayHasKey('Authorization', $headers); | ||
|
||
$this->assertEquals('Bearer zKq9RDO6PbCjs6PRUXF3BoqFi3QdwY36C2VfOaRy', $headers['Authorization']); | ||
|
||
$this->assertCount(1, $headers); | ||
} | ||
} |