Issues (2014)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/Unit/OAuth2/Service/HubicTest.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace OAuthTest\Unit\OAuth2\Service;
4
5
use OAuth\OAuth2\Service\Hubic;
6
use PHPUnit\Framework\TestCase;
7
8
class HubicTest extends TestCase
9
{
10
    /**
11
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
12
     */
13
    public function testConstructCorrectInterfaceWithoutCustomUri(): void
14
    {
15
        $service = new Hubic(
16
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
17
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
18
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
19
        );
20
21
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service);
22
    }
23
24
    /**
25
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
26
     */
27
    public function testConstructCorrectInstanceWithoutCustomUri(): void
28
    {
29
        $service = new Hubic(
30
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
31
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
32
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
33
        );
34
35
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service);
36
    }
37
38
    /**
39
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
40
     */
41
    public function testConstructCorrectInstanceWithCustomUri(): void
42
    {
43
        $service = new Hubic(
44
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
45
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
46
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
47
            [],
48
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
49
        );
50
51
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service);
52
    }
53
54
    /**
55
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
56
     * @covers \OAuth\OAuth2\Service\Hubic::getAuthorizationEndpoint
57
     */
58
    public function testGetAuthorizationEndpoint(): void
59
    {
60
        $service = new Hubic(
61
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
62
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
63
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
64
        );
65
66
        self::assertSame(
67
            'https://api.hubic.com/oauth/auth',
68
            $service->getAuthorizationEndpoint()->getAbsoluteUri()
69
        );
70
    }
71
72
    /**
73
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
74
     * @covers \OAuth\OAuth2\Service\Hubic::getAccessTokenEndpoint
75
     */
76
    public function testGetAccessTokenEndpoint(): void
77
    {
78
        $service = new Hubic(
79
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
80
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
81
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
82
        );
83
84
        self::assertSame(
85
            'https://api.hubic.com/oauth/token',
86
            $service->getAccessTokenEndpoint()->getAbsoluteUri()
87
        );
88
    }
89
90
    /**
91
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
92
     * @covers \OAuth\OAuth2\Service\Hubic::parseAccessTokenResponse
93
     */
94
    public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse(): void
95
    {
96
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
97
        $client->expects(self::once())->method('retrieveResponse')->willReturn(null);
98
99
        $service = new Hubic(
100
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
101
            $client,
0 ignored issues
show
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
102
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
103
        );
104
105
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
106
107
        $service->requestAccessToken('foo');
108
    }
109
110
    /**
111
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
112
     * @covers \OAuth\OAuth2\Service\Hubic::parseAccessTokenResponse
113
     */
114
    public function testParseAccessTokenResponseThrowsExceptionOnError(): void
115
    {
116
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
117
        $client->expects(self::once())->method('retrieveResponse')->willReturn('error=some_error');
118
119
        $service = new Hubic(
120
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
121
            $client,
0 ignored issues
show
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
122
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
123
        );
124
125
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
126
127
        $service->requestAccessToken('foo');
128
    }
129
130
    /**
131
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
132
     * @covers \OAuth\OAuth2\Service\Hubic::parseAccessTokenResponse
133
     */
134
    public function testParseAccessTokenResponseValidWithoutRefreshToken(): void
135
    {
136
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
137
        $client->expects(self::once())->method('retrieveResponse')->willReturn('{"access_token":"foo","expires_in":"bar"}');
138
139
        $service = new Hubic(
140
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
141
            $client,
0 ignored issues
show
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
142
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
143
        );
144
145
        self::assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo'));
146
    }
147
148
    /**
149
     * @covers \OAuth\OAuth2\Service\Hubic::__construct
150
     * @covers \OAuth\OAuth2\Service\Hubic::parseAccessTokenResponse
151
     */
152
    public function testParseAccessTokenResponseValidWithRefreshToken(): void
153
    {
154
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
155
        $client->expects(self::once())->method('retrieveResponse')->willReturn('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}');
156
157
        $service = new Hubic(
158
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
159
            $client,
0 ignored issues
show
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
160
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
161
        );
162
163
        self::assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo'));
164
    }
165
}
166