Failed Conditions
Push — ng ( 625bbc...a06888 )
by Florent
08:03
created

ImplicitGrantTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 2
A theRequestHasNoGrantType() 0 7 1
A theImplicitGrantTypeCannotBeCalledFromTheTokenEndpoint() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Bundle\Tests\Functional\Grant\Implicit;
15
16
use OAuth2Framework\Component\ImplicitGrant\ImplicitGrantType;
17
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
18
19
/**
20
 * @group Bundle
21
 * @group Functional
22
 * @group Grant
23
 * @group Implicit
24
 */
25
class ImplicitGrantTest extends WebTestCase
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function setUp()
31
    {
32
        if (!class_exists(ImplicitGrantType::class)) {
33
            $this->markTestSkipped('The component "oauth2-framework/implicit-grant" is not installed.');
34
        }
35
    }
36
37
    /**
38
     * @test
39
     */
40
    public function theRequestHasNoGrantType()
41
    {
42
        $client = static::createClient();
43
        $client->request('POST', '/token/get', [], [], ['HTTPS' => 'on'], null);
44
        $response = $client->getResponse();
45
        self::assertEquals('{"error":"invalid_request","error_description":"The \"grant_type\" parameter is missing."}', $response->getContent());
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function theImplicitGrantTypeCannotBeCalledFromTheTokenEndpoint()
52
    {
53
        $client = static::createClient();
54
        $client->request('POST', '/token/get', ['grant_type' => 'implicit'], [], ['HTTPS' => 'on'], null);
55
        $response = $client->getResponse();
56
        self::assertEquals(400, $response->getStatusCode());
57
        self::assertEquals('{"error":"invalid_grant","error_description":"The implicit grant type cannot be called from the token endpoint."}', $response->getContent());
58
    }
59
}
60