* This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ namespace Test\Http\Client; use GuzzleHttp\Message\Response; use OC\Http\Client\Client; use OC\Security\CertificateManager; use OCP\ICertificateManager; use OCP\IConfig; /** * Class ClientTest */ class ClientTest extends \Test\TestCase { /** @var \GuzzleHttp\Client|\PHPUnit_Framework_MockObject_MockObject */ private $guzzleClient; /** @var CertificateManager|\PHPUnit_Framework_MockObject_MockObject */ private $certificateManager; /** @var Client */ private $client; /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ private $config; public function setUp() { parent::setUp(); $this->config = $this->createMock(IConfig::class); $this->guzzleClient = $this->getMockBuilder('\GuzzleHttp\Client') ->disableOriginalConstructor() ->getMock(); $this->certificateManager = $this->createMock(ICertificateManager::class); $this->client = new Client( $this->config, $this->certificateManager, $this->guzzleClient ); } public function testGetProxyUri() { $this->config ->expects($this->at(0)) ->method('getSystemValue') ->with('proxy', null) ->willReturn(null); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('proxyuserpwd', null) ->willReturn(null); $this->assertSame('', self::invokePrivate($this->client, 'getProxyUri')); } public function testGetProxyUriProxyHostEmptyPassword() { $this->config ->expects($this->at(0)) ->method('getSystemValue') ->with('proxy', null) ->willReturn('foo'); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('proxyuserpwd', null) ->willReturn(null); $this->assertSame('foo', self::invokePrivate($this->client, 'getProxyUri')); } public function testGetProxyUriProxyHostWithPassword() { $this->config ->expects($this->at(0)) ->method('getSystemValue') ->with('proxy', null) ->willReturn('foo'); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('proxyuserpwd', null) ->willReturn('username:password'); $this->assertSame('username:password@foo', self::invokePrivate($this->client, 'getProxyUri')); } public function testGet() { $this->guzzleClient->method('get') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->get('http://localhost/', [])->getStatusCode()); } public function testPost() { $this->guzzleClient->method('post') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->post('http://localhost/', [])->getStatusCode()); } public function testPut() { $this->guzzleClient->method('put') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->put('http://localhost/', [])->getStatusCode()); } public function testDelete() { $this->guzzleClient->method('delete') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->delete('http://localhost/', [])->getStatusCode()); } public function testOptions() { $this->guzzleClient->method('options') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->options('http://localhost/', [])->getStatusCode()); } public function testHead() { $this->guzzleClient->method('head') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->head('http://localhost/', [])->getStatusCode()); } public function testSetDefaultOptionsWithNotInstalled() { $this->config ->expects($this->at(0)) ->method('getSystemValue') ->with('installed', false) ->willReturn(false); $this->certificateManager ->expects($this->once()) ->method('listCertificates') ->willReturn([]); $this->guzzleClient ->expects($this->at(0)) ->method('setDefaultOption') ->with('verify', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); $this->guzzleClient ->expects($this->at(1)) ->method('setDefaultOption') ->with('headers/User-Agent', 'Nextcloud Server Crawler'); self::invokePrivate($this->client, 'setDefaultOptions'); } public function testSetDefaultOptionsWithProxy() { $this->config ->expects($this->at(0)) ->method('getSystemValue') ->with('proxy', null) ->willReturn('foo'); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('proxyuserpwd', null) ->willReturn(null); $this->certificateManager ->expects($this->once()) ->method('getAbsoluteBundlePath') ->with(null) ->willReturn('/my/path.crt'); $this->guzzleClient ->expects($this->at(0)) ->method('setDefaultOption') ->with('verify', '/my/path.crt'); $this->guzzleClient ->expects($this->at(1)) ->method('setDefaultOption') ->with('headers/User-Agent', 'Nextcloud Server Crawler'); $this->guzzleClient ->expects($this->at(2)) ->method('setDefaultOption') ->with('proxy', 'foo'); self::invokePrivate($this->client, 'setDefaultOptions'); } } en_users'>artonge/feat/allow_partial_seen_users Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Encryption/IFile.php
blob: 209245677bba5eb01b141182db1a16a5d5dfaf11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Björn Schießle <bjoern@schiessle.org>
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 */
namespace OCP\Encryption;

/**
 * Interface IFile
 *
 * @since 8.1.0
 */
interface IFile {
	/**
	 * get list of users with access to the file
	 *
	 * @param string $path to the file
	 * @return array
	 * @since 8.1.0
	 */
	public function getAccessList($path);
}