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 | * Copyright 2016 Facebook, Inc. |
||
4 | * |
||
5 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to |
||
6 | * use, copy, modify, and distribute this software in source code or binary |
||
7 | * form for use in connection with the web services and APIs provided by |
||
8 | * Facebook. |
||
9 | * |
||
10 | * As with any software that integrates with the Facebook platform, your use |
||
11 | * of this software is subject to the Facebook Developer Principles and |
||
12 | * Policies [http://developers.facebook.com/policy/]. This copyright notice |
||
13 | * shall be included in all copies or substantial portions of the software. |
||
14 | * |
||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
21 | * DEALINGS IN THE SOFTWARE. |
||
22 | * |
||
23 | */ |
||
24 | namespace Facebook\Tests\HttpClients; |
||
25 | |||
26 | use Mockery as m; |
||
27 | use Facebook\HttpClients\FacebookStreamHttpClient; |
||
28 | |||
29 | class FacebookStreamHttpClientTest extends AbstractTestHttpClient |
||
30 | { |
||
31 | /** |
||
32 | * @var \Facebook\HttpClients\FacebookStream |
||
33 | */ |
||
34 | protected $streamMock; |
||
35 | |||
36 | /** |
||
37 | * @var FacebookStreamHttpClient |
||
38 | */ |
||
39 | protected $streamClient; |
||
40 | |||
41 | protected function setUp() |
||
42 | { |
||
43 | $this->streamMock = m::mock('Facebook\HttpClients\FacebookStream'); |
||
44 | $this->streamClient = new FacebookStreamHttpClient($this->streamMock); |
||
45 | } |
||
46 | |||
47 | public function testCanCompileHeader() |
||
48 | { |
||
49 | $headers = [ |
||
50 | 'X-foo' => 'bar', |
||
51 | 'X-bar' => 'faz', |
||
52 | ]; |
||
53 | $header = $this->streamClient->compileHeader($headers); |
||
54 | $this->assertEquals("X-foo: bar\r\nX-bar: faz", $header); |
||
55 | } |
||
56 | |||
57 | public function testCanSendNormalRequest() |
||
58 | { |
||
59 | $this->streamMock |
||
0 ignored issues
–
show
|
|||
60 | ->shouldReceive('streamContextCreate') |
||
61 | ->once() |
||
62 | ->with(m::on(function ($arg) { |
||
63 | if (!isset($arg['http']) || !isset($arg['ssl'])) { |
||
64 | return false; |
||
65 | } |
||
66 | |||
67 | if ($arg['http'] !== [ |
||
68 | 'method' => 'GET', |
||
69 | 'header' => 'X-foo: bar', |
||
70 | 'content' => 'foo_body', |
||
71 | 'timeout' => 123, |
||
72 | 'ignore_errors' => true, |
||
73 | ] |
||
74 | ) { |
||
75 | return false; |
||
76 | } |
||
77 | |||
78 | $caInfo = array_diff_assoc($arg['ssl'], [ |
||
79 | 'verify_peer' => true, |
||
80 | 'verify_peer_name' => true, |
||
81 | 'allow_self_signed' => true, |
||
82 | ]); |
||
83 | |||
84 | if (count($caInfo) !== 1) { |
||
85 | return false; |
||
86 | } |
||
87 | |||
88 | if (1 !== preg_match('/.+\/certs\/DigiCertHighAssuranceEVRootCA\.pem$/', $caInfo['cafile'])) { |
||
89 | return false; |
||
90 | } |
||
91 | |||
92 | return true; |
||
93 | })) |
||
94 | ->andReturn(null); |
||
95 | $this->streamMock |
||
0 ignored issues
–
show
The method
shouldReceive() does not seem to exist on object<Facebook\HttpClients\FacebookStream> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
96 | ->shouldReceive('getResponseHeaders') |
||
97 | ->once() |
||
98 | ->andReturn(explode("\n", trim($this->fakeRawHeader))); |
||
99 | $this->streamMock |
||
0 ignored issues
–
show
The method
shouldReceive() does not seem to exist on object<Facebook\HttpClients\FacebookStream> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
100 | ->shouldReceive('fileGetContents') |
||
101 | ->once() |
||
102 | ->with('http://foo.com/') |
||
103 | ->andReturn($this->fakeRawBody); |
||
104 | |||
105 | $response = $this->streamClient->send('http://foo.com/', 'GET', 'foo_body', ['X-foo' => 'bar'], 123); |
||
106 | |||
107 | $this->assertInstanceOf('Facebook\Http\GraphRawResponse', $response); |
||
108 | $this->assertEquals($this->fakeRawBody, $response->getBody()); |
||
109 | $this->assertEquals($this->fakeHeadersAsArray, $response->getHeaders()); |
||
110 | $this->assertEquals(200, $response->getHttpResponseCode()); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @expectedException \Facebook\Exceptions\FacebookSDKException |
||
115 | */ |
||
116 | public function testThrowsExceptionOnClientError() |
||
117 | { |
||
118 | $this->streamMock |
||
0 ignored issues
–
show
The method
shouldReceive() does not seem to exist on object<Facebook\HttpClients\FacebookStream> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
119 | ->shouldReceive('streamContextCreate') |
||
120 | ->once() |
||
121 | ->andReturn(null); |
||
122 | $this->streamMock |
||
0 ignored issues
–
show
The method
shouldReceive() does not seem to exist on object<Facebook\HttpClients\FacebookStream> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
123 | ->shouldReceive('getResponseHeaders') |
||
124 | ->once() |
||
125 | ->andReturn(null); |
||
126 | $this->streamMock |
||
0 ignored issues
–
show
The method
shouldReceive() does not seem to exist on object<Facebook\HttpClients\FacebookStream> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
127 | ->shouldReceive('fileGetContents') |
||
128 | ->once() |
||
129 | ->with('http://foo.com/') |
||
130 | ->andReturn(false); |
||
131 | |||
132 | $this->streamClient->send('http://foo.com/', 'GET', 'foo_body', [], 60); |
||
133 | } |
||
134 | } |
||
135 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.