Completed
Push — master ( 3d69b3...71e1b2 )
by Paweł
391:57 queued 377:20
created

it_allows_to_refresh_an_access_token()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Tests\Controller;
13
14
use Lakion\ApiTestCase\JsonApiTestCase;
15
use Symfony\Component\HttpFoundation\Response;
16
17
/**
18
 * @author Łukasz Chruściel <[email protected]>
19
 */
20
final class OauthTokenApiTest extends JsonApiTestCase
21
{
22
    /**
23
     * @test
24
     */
25
    public function it_provides_an_access_token()
26
    {
27
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
28
29
        $data =
30
<<<EOT
31
        {
32
            "client_id": "client_id",
33
            "client_secret": "secret",
34
            "grant_type": "password",
35
            "username": "[email protected]",
36
            "password": "sylius"
37
        }
38
EOT;
39
40
        $this->client->request('POST', '/api/oauth/v2/token', [], [], ['CONTENT_TYPE' => 'application/json'], $data);
41
42
43
        $response = $this->client->getResponse();
44
        $this->assertResponse($response, 'authentication/new_access_token', Response::HTTP_OK);
45
    }
46
    /**
47
     * @test
48
     */
49
    public function it_allows_to_refresh_an_access_token()
50
    {
51
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
52
53
        $data =
54
<<<EOT
55
        {
56
            "client_id": "client_id",
57
            "client_secret": "secret",
58
            "grant_type": "refresh_token",
59
            "refresh_token": "SampleRefreshTokenODllODY4ZTQyOThlNWIyMjA1ZDhmZjE1ZDYyMGMwOTUxOWM2NGFmNGRjNjQ2NDBhMDVlNGZjMmQ0YzgyNDM2Ng"
60
        }
61
EOT;
62
63
        $this->client->request('POST', '/api/oauth/v2/token', [], [], ['CONTENT_TYPE' => 'application/json'], $data);
64
65
66
        $response = $this->client->getResponse();
67
        $this->assertResponse($response, 'authentication/new_access_token', Response::HTTP_OK);
68
    }
69
}
70