diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2016-02-26 16:59:53 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2016-02-29 16:50:33 +0100 |
commit | 7189c72c33a03d57473f7e3443193d07bece7c15 (patch) | |
tree | 8b61c06e4006f2426037e92d1d65008d6976022c /apps/federation/tests | |
parent | eccd7cf6548e1ea639aea48cbf7e52e95dc98c11 (diff) | |
download | nextcloud-server-7189c72c33a03d57473f7e3443193d07bece7c15.tar.gz nextcloud-server-7189c72c33a03d57473f7e3443193d07bece7c15.zip |
remove remote address book if the admin removes the server from the trusted servers list
Diffstat (limited to 'apps/federation/tests')
-rw-r--r-- | apps/federation/tests/lib/dbhandlertest.php | 9 | ||||
-rw-r--r-- | apps/federation/tests/lib/trustedserverstest.php | 27 |
2 files changed, 32 insertions, 4 deletions
diff --git a/apps/federation/tests/lib/dbhandlertest.php b/apps/federation/tests/lib/dbhandlertest.php index ee28da8e02a..28f76dbb22e 100644 --- a/apps/federation/tests/lib/dbhandlertest.php +++ b/apps/federation/tests/lib/dbhandlertest.php @@ -115,6 +115,15 @@ class DbHandlerTest extends TestCase { $this->assertSame($id1, (int)$result[0]['id']); } + + public function testGetServerById() { + $this->dbHandler->addServer('server1'); + $id = $this->dbHandler->addServer('server2'); + + $result = $this->dbHandler->getServerById($id); + $this->assertSame('server2', $result['url']); + } + public function testGetAll() { $id1 = $this->dbHandler->addServer('server1'); $id2 = $this->dbHandler->addServer('server2'); diff --git a/apps/federation/tests/lib/trustedserverstest.php b/apps/federation/tests/lib/trustedserverstest.php index 130a0e3bb22..80f7843d818 100644 --- a/apps/federation/tests/lib/trustedserverstest.php +++ b/apps/federation/tests/lib/trustedserverstest.php @@ -23,7 +23,6 @@ namespace OCA\Federation\Tests\lib; -use OC\HintException; use OCA\Federation\DbHandler; use OCA\Federation\TrustedServers; use OCP\BackgroundJob\IJobList; @@ -33,6 +32,7 @@ use OCP\Http\Client\IResponse; use OCP\IConfig; use OCP\ILogger; use OCP\Security\ISecureRandom; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class TrustedServersTest extends TestCase { @@ -64,11 +64,16 @@ class TrustedServersTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | IConfig */ private $config; + /** @var \PHPUnit_Framework_MockObject_MockObject | EventDispatcherInterface */ + private $dispatcher; + public function setUp() { parent::setUp(); $this->dbHandler = $this->getMockBuilder('\OCA\Federation\DbHandler') ->disableOriginalConstructor()->getMock(); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface') + ->disableOriginalConstructor()->getMock(); $this->httpClientService = $this->getMock('OCP\Http\Client\IClientService'); $this->httpClient = $this->getMock('OCP\Http\Client\IClient'); $this->response = $this->getMock('OCP\Http\Client\IResponse'); @@ -83,7 +88,8 @@ class TrustedServersTest extends TestCase { $this->logger, $this->jobList, $this->secureRandom, - $this->config + $this->config, + $this->dispatcher ); } @@ -103,7 +109,8 @@ class TrustedServersTest extends TestCase { $this->logger, $this->jobList, $this->secureRandom, - $this->config + $this->config, + $this->dispatcher ] ) ->setMethods(['normalizeUrl', 'updateProtocol']) @@ -191,7 +198,18 @@ class TrustedServersTest extends TestCase { public function testRemoveServer() { $id = 42; + $server = ['url_hash' => 'url_hash']; $this->dbHandler->expects($this->once())->method('removeServer')->with($id); + $this->dbHandler->expects($this->once())->method('getServerById')->with($id) + ->willReturn($server); + $this->dispatcher->expects($this->once())->method('dispatch') + ->willReturnCallback( + function($eventId, $event) { + $this->assertSame($eventId, 'OCP\Federation\TrustedServerEvent::remove'); + $this->assertInstanceOf('Symfony\Component\EventDispatcher\GenericEvent', $event); + $this->assertSame('url_hash', $event->getSubject()); + } + ); $this->trustedServers->removeServer($id); } @@ -247,7 +265,8 @@ class TrustedServersTest extends TestCase { $this->logger, $this->jobList, $this->secureRandom, - $this->config + $this->config, + $this->dispatcher ] ) ->setMethods(['checkOwnCloudVersion']) |