GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bb96e0...68e81a )
by luca
02:33
created

AuthTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 60
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Test\unit;
4
5
use Audiens\AdobeClient\Auth;
6
use Audiens\AdobeClient\Authentication\AuthStrategyInterface;
7
use Test\TestCase;
8
use GuzzleHttp\ClientInterface;
9
use GuzzleHttp\Psr7\Response;
10
use GuzzleHttp\Psr7\Stream;
11
use Prophecy\Argument;
12
13
/**
14
 * Class AuthTest
15
 */
16
class AuthTest extends TestCase
17
{
18
    /**
19
     * @test
20
     */
21
    public function should_append_the_authorization_token_when_performing_any_request()
22
    {
23
24
        $client_id = 'sample_client_id';
25
        $secret_key = 'sample_secret_key';
26
        $username = 'sample_username';
27
        $password = 'sample_password';
28
        $token = 'a_sample_token123456789';
29
30
        $dummyStream = $this->prophesize(Stream::class);
31
        $dummyStream->getContents("{'response:{}'}");
32
33
        $dummyResponse = $this->prophesize(Response::class);
34
        $dummyResponse->getBody()->willReturn($dummyStream->reveal());
35
        $dummyResponse->getStatusCode()->willReturn(200);
36
37
        $authStrategy = $this->prophesize(AuthStrategyInterface::class);
38
39
        $authStrategy->authenticate($client_id, $secret_key, $username, $password, Argument::any())->willReturn($token)->shouldBeCalled();
40
41
        $expectedRequestOptions =
42
            [
43
                    'headers' => [
44
                        'Authorization' => ['Bearer ' . $token],
45
                    ]
46
            ];
47
48
        $client = $this->prophesize(ClientInterface::class);
49
        $client->request('POST', 'random_url', $expectedRequestOptions)->willReturn($dummyResponse->reveal())->shouldBeCalled();
50
51
        $auth = new Auth($client_id, $secret_key, $username, $password, $client->reveal(), $authStrategy->reveal());
52
        $auth->request('POST', 'random_url', []);
53
54
55
    }
56
57
    /**
58
     * @param $token
59
     *
60
     * @return Response
61
     */
62
    protected function getTokenResponse($token)
63
    {
64
65
        $responseBody = json_encode(
66
            [
67
                'access_token' => $token,
68
            ]
69
        );
70
71
        return new Response(200, [], $responseBody);
72
73
    }
74
75
}
76