@@ 155-185 (lines=31) @@ | ||
152 | ], $actual->getData()); |
|
153 | } |
|
154 | ||
155 | public function testProxyConnectException() { |
|
156 | $testUrl = 'http://abc.def/foobar?123'; |
|
157 | ||
158 | $this->client->expects($this->once()) |
|
159 | ->method('newClient') |
|
160 | ->will($this->returnValue($this->newClient)); |
|
161 | $this->newClient->expects($this->once()) |
|
162 | ->method('get') |
|
163 | ->with($testUrl, [ |
|
164 | 'stream' => true, |
|
165 | 'allow_redirects' => false, |
|
166 | ]) |
|
167 | ->will($this->throwException(new ConnectException('Exception Message foo bar 42', |
|
168 | $this->exceptionRequest, $this->exceptionResponse))); |
|
169 | $this->l10n->expects($this->once()) |
|
170 | ->method('t') |
|
171 | ->with($this->equalTo('Error connecting to remote server')) |
|
172 | ->will($this->returnValue('translated string 1337')); |
|
173 | $this->logger->expects($this->once()) |
|
174 | ->method('debug') |
|
175 | ->with($this->equalTo('Exception Message foo bar 42')); |
|
176 | ||
177 | $actual = $this->controller->proxy($testUrl); |
|
178 | ||
179 | $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
|
180 | $this->assertEquals('422', $actual->getStatus()); |
|
181 | $this->assertEquals([ |
|
182 | 'message' => 'translated string 1337', |
|
183 | 'proxy_code' => -1 |
|
184 | ], $actual->getData()); |
|
185 | } |
|
186 | ||
187 | public function testProxyRequestExceptionHTTP() { |
|
188 | $testUrl = 'http://abc.def/foobar?123'; |
|
@@ 187-217 (lines=31) @@ | ||
184 | ], $actual->getData()); |
|
185 | } |
|
186 | ||
187 | public function testProxyRequestExceptionHTTP() { |
|
188 | $testUrl = 'http://abc.def/foobar?123'; |
|
189 | ||
190 | $this->client->expects($this->once()) |
|
191 | ->method('newClient') |
|
192 | ->will($this->returnValue($this->newClient)); |
|
193 | $this->newClient->expects($this->once()) |
|
194 | ->method('get') |
|
195 | ->with($testUrl, [ |
|
196 | 'stream' => true, |
|
197 | 'allow_redirects' => false, |
|
198 | ]) |
|
199 | ->will($this->throwException(new RequestException('Exception Message foo bar 42', |
|
200 | $this->exceptionRequest, $this->exceptionResponse))); |
|
201 | $this->l10n->expects($this->once()) |
|
202 | ->method('t') |
|
203 | ->with($this->equalTo('Error requesting resource on remote server')) |
|
204 | ->will($this->returnValue('translated string 1337')); |
|
205 | $this->logger->expects($this->once()) |
|
206 | ->method('debug') |
|
207 | ->with($this->equalTo('Exception Message foo bar 42')); |
|
208 | ||
209 | $actual = $this->controller->proxy($testUrl); |
|
210 | ||
211 | $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
|
212 | $this->assertEquals('422', $actual->getStatus()); |
|
213 | $this->assertEquals([ |
|
214 | 'message' => 'translated string 1337', |
|
215 | 'proxy_code' => -2 |
|
216 | ], $actual->getData()); |
|
217 | } |
|
218 | ||
219 | public function testProxyRequestExceptionHTTPS() { |
|
220 | $testUrl = 'https://abc.def/foobar?123'; |
|
@@ 219-249 (lines=31) @@ | ||
216 | ], $actual->getData()); |
|
217 | } |
|
218 | ||
219 | public function testProxyRequestExceptionHTTPS() { |
|
220 | $testUrl = 'https://abc.def/foobar?123'; |
|
221 | ||
222 | $this->client->expects($this->once()) |
|
223 | ->method('newClient') |
|
224 | ->will($this->returnValue($this->newClient)); |
|
225 | $this->newClient->expects($this->once()) |
|
226 | ->method('get') |
|
227 | ->with($testUrl, [ |
|
228 | 'stream' => true, |
|
229 | 'allow_redirects' => false, |
|
230 | ]) |
|
231 | ->will($this->throwException(new RequestException('Exception Message foo bar 42', |
|
232 | $this->exceptionRequest, $this->exceptionResponse))); |
|
233 | $this->l10n->expects($this->once()) |
|
234 | ->method('t') |
|
235 | ->with($this->equalTo('Error requesting resource on remote server. This could possibly be related to a certificate mismatch')) |
|
236 | ->will($this->returnValue('translated string 1337')); |
|
237 | $this->logger->expects($this->once()) |
|
238 | ->method('debug') |
|
239 | ->with($this->equalTo('Exception Message foo bar 42')); |
|
240 | ||
241 | $actual = $this->controller->proxy($testUrl); |
|
242 | ||
243 | $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
|
244 | $this->assertEquals('422', $actual->getStatus()); |
|
245 | $this->assertEquals([ |
|
246 | 'message' => 'translated string 1337', |
|
247 | 'proxy_code' => -2 |
|
248 | ], $actual->getData()); |
|
249 | } |
|
250 | ||
251 | public function testProxyRedirect() { |
|
252 | $testUrl = 'http://abc.def/foobar?123'; |