This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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
|
|||
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 |
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: