* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace Test;
use OCP\Http\Client\IClientService;
class HTTPHelperTest extends \Test\TestCase {
/** @var \OCP\IConfig*/
private $config;
/** @var \OC\HTTPHelper */
private $httpHelperMock;
/** @var \OCP\Http\Client\IClientService */
private $clientService;
protected function setUp() {
parent::setUp();
$this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
$this->clientService = $this->createMock(IClientService::class);
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
->setConstructorArgs(array($this->config, $this->clientService))
->setMethods(array('getHeaders'))
->getMock();
}
public function isHttpTestData() {
return array(
array('http://wwww.owncloud.org/enterprise/', true),
array('https://wwww.owncloud.org/enterprise/', true),
array('HTTPS://WWW.OWNCLOUD.ORG', true),
array('HTTP://WWW.OWNCLOUD.ORG', true),
array('FILE://WWW.OWNCLOUD.ORG', false),
array('file://www.owncloud.org', false),
array('FTP://WWW.OWNCLOUD.ORG', false),
array('ftp://www.owncloud.org', false),
);
}
/**
* @dataProvider isHttpTestData
*/
public function testIsHTTP($url, $expected) {
$this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url));
}
public function testPostSuccess() {
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
->disableOriginalConstructor()->getMock();
$this->clientService
->expects($this->once())
->method('newClient')
->will($this->returnValue($client));
$response = $this->getMockBuilder('\OCP\Http\Client\IResponse')
->disableOriginalConstructor()->getMock();
$client
->expects($this->once())
->method('post')
->with(
'https://owncloud.org',
[
'body' => [
'Foo' => 'Bar',
],
'connect_timeout' => 10,
]
)
->will($this->returnValue($response));
$response
->expects($this->once())
->method('getBody')
->will($this->returnValue('Body of the requested page'));
$response = $this->httpHelperMock->post('https://owncloud.org', ['Foo' => 'Bar']);
$expected = [
'success' => true,
'result' => 'Body of the requested page'
];
$this->assertSame($expected, $response);
}
public function testPostException() {
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
->disableOriginalConstructor()->getMock();
$this->clientService
->expects($this->once())
->method('newClient')
->will($this->returnValue($client));
$client
->expects($this->once())
->method('post')
->with(
'https://owncloud.org',
[
'body' => [
'Foo' => 'Bar',
],
'connect_timeout' => 10,
]
)
->will($this->throwException(new \Exception('Something failed')));
$response = $this->httpHelperMock->post('https://owncloud.org', ['Foo' => 'Bar']);
$expected = [
'success' => false,
'result' => 'Something failed'
];
$this->assertSame($expected, $response);
}
}
01412180710-r'>dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-3.5.3.201412180710-r
dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-7.2.1.202505142326-r
dependabot/maven/org.hsqldb-hsqldb-2.7.1
documentation
documentation-7.6
downgrade-snapshot-version-20241105
exclude-element-screenshot
feature/atmosphere-pure-javascript
feature/bootstrap-annotation
feature/combobox-communication
feature/dalvik
feature/databinding
feature/dnd
feature/elements
feature/eventbus
feature/karaf-feature-file
feature/nullrepresentation
feature/standard-gwt
feature/standard-sass
feature/vaadin8
feature/vaadin8-book
feature/vaadin8-book-vol2
feature/vaadin8-sass-valo-only
fileToFilesReplacement
fix11576
fix_event_router_prototype
grid
grid_dnd_autoscroller
grid_dragger
issue/8307_select_using_collection
master
mobile_drag_image_offset
pr/11306
remote-run/flow-atmosphere-test
snapshot/7.5
snapshot/7.6
tmattsso-patch-1
update-minor-deps
vaadin-icons-3.0.1
wip-date-time-datatype
wip-java-10-compat
Vaadin 6, 7, 8 is a Java framework for modern Java web applications: https://github.com/vaadin/framework www-data
blob: 4a9e0b0ceb933ffc11e3657cfcb8a1380bdf6fed (
plain )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.server ;
@SuppressWarnings ( "serial" )
public class NoOutputStreamException extends Exception {
}