|
@@ 177-206 (lines=30) @@
|
| 174 |
|
], $actual->getData()); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
public function testProxyConnectException() { |
| 178 |
|
$testUrl = 'http://abc.def/foobar?123'; |
| 179 |
|
|
| 180 |
|
$this->client->expects($this->once()) |
| 181 |
|
->method('newClient') |
| 182 |
|
->will($this->returnValue($this->newClient)); |
| 183 |
|
$this->newClient->expects($this->once()) |
| 184 |
|
->method('get') |
| 185 |
|
->with($testUrl, [ |
| 186 |
|
'allow_redirects' => false, |
| 187 |
|
]) |
| 188 |
|
->will($this->throwException(new ConnectException('Exception Message foo bar 42', |
| 189 |
|
$this->exceptionRequest))); |
| 190 |
|
$this->l10n->expects($this->once()) |
| 191 |
|
->method('t') |
| 192 |
|
->with($this->equalTo('Error connecting to remote server')) |
| 193 |
|
->will($this->returnValue('translated string 1337')); |
| 194 |
|
$this->logger->expects($this->once()) |
| 195 |
|
->method('debug') |
| 196 |
|
->with($this->equalTo('Exception Message foo bar 42')); |
| 197 |
|
|
| 198 |
|
$actual = $this->controller->proxy($testUrl); |
| 199 |
|
|
| 200 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 201 |
|
$this->assertEquals('422', $actual->getStatus()); |
| 202 |
|
$this->assertEquals([ |
| 203 |
|
'message' => 'translated string 1337', |
| 204 |
|
'proxy_code' => -1 |
| 205 |
|
], $actual->getData()); |
| 206 |
|
} |
| 207 |
|
|
| 208 |
|
public function testProxyRequestExceptionHTTP() { |
| 209 |
|
$testUrl = 'http://abc.def/foobar?123'; |
|
@@ 208-237 (lines=30) @@
|
| 205 |
|
], $actual->getData()); |
| 206 |
|
} |
| 207 |
|
|
| 208 |
|
public function testProxyRequestExceptionHTTP() { |
| 209 |
|
$testUrl = 'http://abc.def/foobar?123'; |
| 210 |
|
|
| 211 |
|
$this->client->expects($this->once()) |
| 212 |
|
->method('newClient') |
| 213 |
|
->will($this->returnValue($this->newClient)); |
| 214 |
|
$this->newClient->expects($this->once()) |
| 215 |
|
->method('get') |
| 216 |
|
->with($testUrl, [ |
| 217 |
|
'allow_redirects' => false, |
| 218 |
|
]) |
| 219 |
|
->will($this->throwException(new RequestException('Exception Message foo bar 42', |
| 220 |
|
$this->exceptionRequest, $this->exceptionResponse))); |
| 221 |
|
$this->l10n->expects($this->once()) |
| 222 |
|
->method('t') |
| 223 |
|
->with($this->equalTo('Error requesting resource on remote server')) |
| 224 |
|
->will($this->returnValue('translated string 1337')); |
| 225 |
|
$this->logger->expects($this->once()) |
| 226 |
|
->method('debug') |
| 227 |
|
->with($this->equalTo('Exception Message foo bar 42')); |
| 228 |
|
|
| 229 |
|
$actual = $this->controller->proxy($testUrl); |
| 230 |
|
|
| 231 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 232 |
|
$this->assertEquals('422', $actual->getStatus()); |
| 233 |
|
$this->assertEquals([ |
| 234 |
|
'message' => 'translated string 1337', |
| 235 |
|
'proxy_code' => -2 |
| 236 |
|
], $actual->getData()); |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
public function testProxyRequestExceptionHTTPS() { |
| 240 |
|
$testUrl = 'https://abc.def/foobar?123'; |
|
@@ 239-268 (lines=30) @@
|
| 236 |
|
], $actual->getData()); |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
public function testProxyRequestExceptionHTTPS() { |
| 240 |
|
$testUrl = 'https://abc.def/foobar?123'; |
| 241 |
|
|
| 242 |
|
$this->client->expects($this->once()) |
| 243 |
|
->method('newClient') |
| 244 |
|
->will($this->returnValue($this->newClient)); |
| 245 |
|
$this->newClient->expects($this->once()) |
| 246 |
|
->method('get') |
| 247 |
|
->with($testUrl, [ |
| 248 |
|
'allow_redirects' => false, |
| 249 |
|
]) |
| 250 |
|
->will($this->throwException(new RequestException('Exception Message foo bar 42', |
| 251 |
|
$this->exceptionRequest, $this->exceptionResponse))); |
| 252 |
|
$this->l10n->expects($this->once()) |
| 253 |
|
->method('t') |
| 254 |
|
->with($this->equalTo('Error requesting resource on remote server. This could possible be related to a certificate mismatch')) |
| 255 |
|
->will($this->returnValue('translated string 1337')); |
| 256 |
|
$this->logger->expects($this->once()) |
| 257 |
|
->method('debug') |
| 258 |
|
->with($this->equalTo('Exception Message foo bar 42')); |
| 259 |
|
|
| 260 |
|
$actual = $this->controller->proxy($testUrl); |
| 261 |
|
|
| 262 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 263 |
|
$this->assertEquals('422', $actual->getStatus()); |
| 264 |
|
$this->assertEquals([ |
| 265 |
|
'message' => 'translated string 1337', |
| 266 |
|
'proxy_code' => -2 |
| 267 |
|
], $actual->getData()); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
public function testProxyRedirect() { |
| 271 |
|
$testUrl = 'http://abc.def/foobar?123'; |