Passed
Push — master ( 7e4f27...ed015a )
by Conrad
01:50
created

testFailedScopeAuthentication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: conrad
5
 * Date: 21/05/18
6
 * Time: 3:59 PM
7
 */
8
9
namespace AdvancedLearning\Oauth2Server\Tests;
10
11
12
use AdvancedLearning\Oauth2Server\Utilities\Authenticator;
13
use SilverStripe\Control\HTTPRequest;
14
use SilverStripe\Dev\SapphireTest;
15
16
class UtilitiesAuthenticatorTest extends SapphireTest
17
{
18
    use Authenticator;
19
20 View Code Duplication
    public function testAuthentication()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22
        $request = new HTTPRequest('GET', '/test');
23
        $request->addHeader('oauth_client_id', 'someclientid');
24
        $request->addHeader('oauth_scopes', 'scope1,scope2');
25
26
        $authenticated = $this->oauthAuthenticate($request, ['scope1', 'scope2']);
27
28
        $this->assertTrue($authenticated, 'Request should have been authenticated');
29
    }
30
31 View Code Duplication
    public function testFailedScopeAuthentication()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $request = new HTTPRequest('GET', '/test');
34
        $request->addHeader('oauth_client_id', 'someclientid');
35
        $request->addHeader('oauth_scopes', 'scope1');
36
37
        $authenticated = $this->oauthAuthenticate($request, ['scope1', 'scope2']);
38
39
        $this->assertFalse($authenticated, 'Request should have failed due to invalid scopes');
40
    }
41
42
}
43