Skip to content

Commit

Permalink
Small tweaks for WebDavClientService and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Petry committed Oct 26, 2017
1 parent e9ff770 commit 9f29e65
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 45 deletions.
8 changes: 4 additions & 4 deletions lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class DAV extends Common {
/** @var \OCP\Http\Client\IClientService */
private $httpClientService;

/** @var \OCP\Http\Client\IWebdavClientService */
private $webdavClientService;
/** @var \OCP\Http\Client\IWebDavClientService */
private $webDavClientService;

/**
* @param array $params
Expand All @@ -93,7 +93,7 @@ class DAV extends Common {
public function __construct($params) {
$this->statCache = new ArrayCache();
$this->httpClientService = \OC::$server->getHTTPClientService();
$this->webdavClientService = \OC::$server->getWebdavClientService();
$this->webDavClientService = \OC::$server->getWebDavClientService();
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
$host = $params['host'];
//remove leading http[s], will be generated in createBaseUri()
Expand Down Expand Up @@ -141,7 +141,7 @@ protected function init() {
$settings['authType'] = $this->authType;
}

$this->client = $this->webdavClientService->newClient($settings);
$this->client = $this->webDavClientService->newClient($settings);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@

namespace OC\Http\Client;

use OCP\Http\Client\IWebdavClientService;
use OCP\Http\Client\IWebDavClientService;
use OCP\IConfig;
use OCP\ICertificateManager;
use Sabre\DAV\Client;

/**
* Class WebdavClientService
* Class WebDavClientService
*
* @package OC\Http
*/
class WebdavClientService implements IWebdavClientService {
class WebDavClientService implements IWebDavClientService {
/** @var IConfig */
private $config;
/** @var ICertificateManager */
Expand Down
12 changes: 6 additions & 6 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
use OC\Files\External\Service\UserGlobalStoragesService;
use OC\Files\External\Service\GlobalStoragesService;
use OC\Files\External\Service\DBConfigService;
use OC\Http\Client\WebdavClientService;
use OC\Http\Client\WebDavClientService;
use Symfony\Component\EventDispatcher\GenericEvent;

/**
Expand Down Expand Up @@ -501,10 +501,10 @@ public function __construct($webRoot, \OC\Config $config) {
new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
);
});
$this->registerService('WebdavClientService', function (Server $c) {
$this->registerService('WebDavClientService', function (Server $c) {
$user = \OC_User::getUser();
$uid = $user ? $user : null;
return new WebdavClientService(
return new WebDavClientService(
$c->getConfig(),
new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
);
Expand Down Expand Up @@ -1285,10 +1285,10 @@ public function getHTTPClientService() {
/**
* Returns an instance of the Webdav client service
*
* @return \OCP\Http\Client\IWebdavClientService
* @return \OCP\Http\Client\IWebDavClientService
*/
public function getWebdavClientService() {
return $this->query('WebdavClientService');
public function getWebDavClientService() {
return $this->query('WebDavClientService');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
use Sabre\HTTP\Client;

/**
* Interface IWebdavClientService
* Interface IWebDavClientService
*
* @package OCP\Http
* @since 10.0.4
*/
interface IWebdavClientService {
interface IWebDavClientService {
/**
* Settings are provided through the 'settings' argument. The following
* settings are supported:
Expand Down
48 changes: 24 additions & 24 deletions tests/lib/Files/Storage/DavTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IClient;
use Sabre\DAV\Client;
use OCP\Http\Client\IWebdavClientService;
use OCP\Http\Client\IWebDavClientService;
use Sabre\HTTP\ClientHttpException;
use OCP\Lock\LockedException;
use OCP\AppFramework\Http;
Expand All @@ -50,37 +50,37 @@
class DavTest extends TestCase {

/**
* @var DAV
* @var DAV | \PHPUnit_Framework_MockObject_MockObject
*/
private $instance;

/**
* @var IClientService
* @var IClientService | \PHPUnit_Framework_MockObject_MockObject
*/
private $httpClientService;

/**
* @var IWebdavClientService
* @var IWebDavClientService | \PHPUnit_Framework_MockObject_MockObject
*/
private $webdavClientService;
private $webDavClientService;

/**
* @var Client
* @var Client | \PHPUnit_Framework_MockObject_MockObject
*/
private $davClient;

/**
* @var IClient
* @var IClient | \PHPUnit_Framework_MockObject_MockObject
**/
private $httpClient;

/**
* @var ITimeFactory
* @var ITimeFactory | \PHPUnit_Framework_MockObject_MockObject
*/
private $timeFactory;

/**
* @var Cache
* @var Cache | \PHPUnit_Framework_MockObject_MockObject
*/
private $cache;

Expand All @@ -90,8 +90,8 @@ protected function setUp() {
$this->httpClientService = $this->createMock(IClientService::class);
$this->overwriteService('HttpClientService', $this->httpClientService);

$this->webdavClientService = $this->createMock(IWebdavClientService::class);
$this->overwriteService('WebdavClientService', $this->webdavClientService);
$this->webDavClientService = $this->createMock(IWebDavClientService::class);
$this->overwriteService('WebDavClientService', $this->webDavClientService);

$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->overwriteService('TimeFactory', $this->timeFactory);
Expand All @@ -100,7 +100,7 @@ protected function setUp() {
$this->httpClientService->method('newClient')->willReturn($this->httpClient);

$this->davClient = $this->createMock(Client::class);
$this->webdavClientService->method('newClient')->willReturn($this->davClient);
$this->webDavClientService->method('newClient')->willReturn($this->davClient);

$this->instance = $this->getMockBuilder(\OC\Files\Storage\DAV::class)
->setConstructorArgs([[
Expand All @@ -119,7 +119,7 @@ protected function setUp() {

protected function tearDown() {
$this->restoreService('HttpClientService');
$this->restoreService('WebdavClientService');
$this->restoreService('WebDavClientService');
$this->restoreService('TimeFactory');
parent::tearDown();
}
Expand All @@ -128,21 +128,21 @@ public function testId() {
$this->assertEquals('webdav::davuser@davhost//davroot/', $this->instance->getId());
}

public function instantiateWebdavClientDataProvider() {
public function instantiateWebDavClientDataProvider() {
return [
[false, 'http'],
[true, 'https'],
];
}

/**
* @dataProvider instantiateWebdavClientDataProvider
* @dataProvider instantiateWebDavClientDataProvider
*/
public function testInstantiateWebdavClient($secure, $protocol) {
$this->restoreService('WebdavClientService');
$this->webdavClientService = $this->createMock(IWebdavClientService::class);
$this->overwriteService('WebdavClientService', $this->webdavClientService);
$this->webdavClientService->expects($this->once())
public function testInstantiateWebDavClient($secure, $protocol) {
$this->restoreService('WebDavClientService');
$this->webDavClientService = $this->createMock(IWebDavClientService::class);
$this->overwriteService('WebDavClientService', $this->webDavClientService);
$this->webDavClientService->expects($this->once())
->method('newClient')
->with([
'baseUri' => $protocol . '://davhost/davroot/',
Expand Down Expand Up @@ -187,7 +187,7 @@ public function invalidConfigDataProvider() {
* @dataProvider invalidConfigDataProvider
* @expectedException \InvalidArgumentException
*/
public function testInstantiateWebdavClientInvalidConfig($params) {
public function testInstantiateWebDavClientInvalidConfig($params) {
new \OC\Files\Storage\DAV($params);
}

Expand Down Expand Up @@ -1273,7 +1273,7 @@ public function testHasUpdatedPathNotfound() {
}

/**
* @expectedException OCP\Files\StorageNotAvailableException
* @expectedException \OCP\Files\StorageNotAvailableException
*/
public function testHasUpdatedRootPathNotfound() {
$this->davClient->expects($this->once())
Expand All @@ -1284,7 +1284,7 @@ public function testHasUpdatedRootPathNotfound() {
}

/**
* @expectedException OCP\Files\StorageNotAvailableException
* @expectedException \OCP\Files\StorageNotAvailableException
*/
public function testHasUpdatedRootPathMethodNotAllowed() {
$this->davClient->expects($this->once())
Expand All @@ -1295,7 +1295,7 @@ public function testHasUpdatedRootPathMethodNotAllowed() {
}

/**
* @expectedException OCP\Files\StorageNotAvailableException
* @expectedException \OCP\Files\StorageNotAvailableException
*/
public function testHasUpdatedMethodNotAllowed() {
$this->davClient->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

use OCP\IConfig;
use OCP\ICertificateManager;
use OC\Http\Client\WebdavClientService;
use OC\Http\Client\WebDavClientService;
use Sabre\DAV\Client;
use OCP\ITempManager;

/**
* Class WebdavClientServiceTest
* Class WebDavClientServiceTest
*/
class WebdavClientServiceTest extends \Test\TestCase {
class WebDavClientServiceTest extends \Test\TestCase {
/**
* @var ITempManager
*/
Expand All @@ -52,7 +52,7 @@ public function testNewClient() {
$certificateManager->method('getAbsoluteBundlePath')
->willReturn($this->tempManager->getTemporaryFolder());

$clientService = new WebdavClientService($config, $certificateManager);
$clientService = new WebDavClientService($config, $certificateManager);

$client = $clientService->newClient([
'baseUri' => 'https://davhost/davroot/',
Expand All @@ -73,7 +73,7 @@ public function testNewClientWithProxy() {
$certificateManager->method('getAbsoluteBundlePath')
->willReturn($this->tempManager->getTemporaryFolder());

$clientService = new WebdavClientService($config, $certificateManager);
$clientService = new WebDavClientService($config, $certificateManager);

$client = $clientService->newClient([
'baseUri' => 'https://davhost/davroot/',
Expand All @@ -89,7 +89,7 @@ public function testNewClientWithoutCertificate() {
$certificateManager->method('getAbsoluteBundlePath')
->willReturn($this->tempManager->getTemporaryFolder() . '/unexist');

$clientService = new WebdavClientService($config, $certificateManager);
$clientService = new WebDavClientService($config, $certificateManager);

$client = $clientService->newClient([
'baseUri' => 'https://davhost/davroot/',
Expand Down

0 comments on commit 9f29e65

Please sign in to comment.