24993280ed
Beside some small improvements and bug fixes this will probably the final state for OC8. To test this you need to set up two ownCloud instances. Let's say: URL: myPC/firstOwnCloud user: user1 URL: myPC/secondOwnCloud user: user2 Now user1 can share a file with user2 by entering the username and the URL to the second ownCloud to the share-drop-down, in this case "user2@myPC/secondOwnCloud". The next time user2 login he will get a notification that he received a server-to-server share with the option to accept/decline it. If he accept it the share will be mounted. In both cases a event will be send back to user1 and add a notification to the activity stream that the share was accepted/declined. If user1 decides to unshare the file again from user2 the share will automatically be removed from the second ownCloud server and user2 will see a notification in his activity stream that user1@myPC/firstOwnCloud has unshared the file/folder from him.
112 lines
3.4 KiB
PHP
112 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
* later.
|
|
* See the COPYING-README file.
|
|
*/
|
|
|
|
class TestHTTPHelper extends \Test\TestCase {
|
|
|
|
/** @var \OCP\IConfig*/
|
|
private $config;
|
|
/** @var \OC\HTTPHelper */
|
|
private $httpHelperMock;
|
|
/** @var \OC\Security\CertificateManager */
|
|
private $certificateManager;
|
|
|
|
protected function setUp() {
|
|
parent::setUp();
|
|
|
|
$this->config = $this->getMockBuilder('\OCP\IConfig')
|
|
->disableOriginalConstructor()->getMock();
|
|
$this->certificateManager = $this->getMock('\OCP\ICertificateManager');
|
|
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
|
|
->setConstructorArgs(array($this->config, $this->certificateManager))
|
|
->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),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Note: Not using a dataprovider because onConsecutiveCalls expects not
|
|
* an array but the function arguments directly
|
|
*/
|
|
public function testGetFinalLocationOfURLValid() {
|
|
$url = 'https://www.owncloud.org/enterprise/';
|
|
$expected = 'https://www.owncloud.com/enterprise/';
|
|
$this->httpHelperMock->expects($this->any())
|
|
->method('getHeaders')
|
|
->will($this->onConsecutiveCalls(
|
|
array('Location' => 'http://www.owncloud.com/enterprise/'),
|
|
array('Location' => 'https://www.owncloud.com/enterprise/')
|
|
));
|
|
$result = $this->httpHelperMock->getFinalLocationOfURL($url);
|
|
$this->assertSame($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* Note: Not using a dataprovider because onConsecutiveCalls expects not
|
|
* an array but the function arguments directly
|
|
*/
|
|
public function testGetFinalLocationOfURLInvalid() {
|
|
$url = 'https://www.owncloud.org/enterprise/';
|
|
$expected = 'http://www.owncloud.com/enterprise/';
|
|
$this->httpHelperMock->expects($this->any())
|
|
->method('getHeaders')
|
|
->will($this->onConsecutiveCalls(
|
|
array('Location' => 'http://www.owncloud.com/enterprise/'),
|
|
array('Location' => 'file://etc/passwd'),
|
|
array('Location' => 'http://www.example.com/')
|
|
));
|
|
$result = $this->httpHelperMock->getFinalLocationOfURL($url);
|
|
$this->assertSame($expected, $result);
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Exception
|
|
* @expectedExceptionMessage URL must begin with HTTPS or HTTP.
|
|
*/
|
|
public function testGetFinalLocationOfURLException() {
|
|
$this->httpHelperMock->getFinalLocationOfURL('file://etc/passwd');
|
|
}
|
|
|
|
/**
|
|
* @dataProvider isHttpTestData
|
|
*/
|
|
public function testIsHTTP($url, $expected) {
|
|
$this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url));
|
|
}
|
|
|
|
|
|
/**
|
|
* @dataProvider postParameters
|
|
*/
|
|
public function testassemblePostParameters($parameterList, $expectedResult) {
|
|
$helper = \OC::$server->getHTTPHelper();
|
|
$result = \Test_Helper::invokePrivate($helper, 'assemblePostParameters', array($parameterList));
|
|
$this->assertSame($expectedResult, $result);
|
|
}
|
|
|
|
public function postParameters() {
|
|
return array(
|
|
array(array('k1' => 'v1'), 'k1=v1'),
|
|
array(array('k1' => 'v1', 'k2' => 'v2'), 'k1=v1&k2=v2'),
|
|
array(array(), ''),
|
|
);
|
|
}
|
|
|
|
|
|
}
|