diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-09 13:58:13 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-09 14:41:26 +0100 |
commit | bc8632856a1d2588ba8675a768ed6fe700677e55 (patch) | |
tree | b6842bdd2d52ff8f7a3314cb1e20af0610845f21 /apps/federation/tests | |
parent | d11179a0f5b69ae479c214033a1ffc8d64752c83 (diff) | |
download | nextcloud-server-bc8632856a1d2588ba8675a768ed6fe700677e55.tar.gz nextcloud-server-bc8632856a1d2588ba8675a768ed6fe700677e55.zip |
Forward exception message to the admin in case of errors and in case the remote server version is to low and appropriate message is displayed as well
Diffstat (limited to 'apps/federation/tests')
-rw-r--r-- | apps/federation/tests/lib/trustedserverstest.php | 40 | ||||
-rw-r--r-- | apps/federation/tests/middleware/addservermiddlewaretest.php | 3 |
2 files changed, 27 insertions, 16 deletions
diff --git a/apps/federation/tests/lib/trustedserverstest.php b/apps/federation/tests/lib/trustedserverstest.php index e57391ed198..130a0e3bb22 100644 --- a/apps/federation/tests/lib/trustedserverstest.php +++ b/apps/federation/tests/lib/trustedserverstest.php @@ -23,6 +23,7 @@ namespace OCA\Federation\Tests\lib; +use OC\HintException; use OCA\Federation\DbHandler; use OCA\Federation\TrustedServers; use OCP\BackgroundJob\IJobList; @@ -282,41 +283,50 @@ class TrustedServersTest extends TestCase { ]; } + /** + * @expectedException \Exception + * @expectedExceptionMessage simulated exception + */ public function testIsOwnCloudServerFail() { $server = 'server1'; $this->httpClientService->expects($this->once())->method('newClient') ->willReturn($this->httpClient); - $this->logger->expects($this->once())->method('error') - ->with('simulated exception', ['app' => 'federation']); - $this->httpClient->expects($this->once())->method('get')->with($server . '/status.php') ->willReturnCallback(function () { throw new \Exception('simulated exception'); }); - $this->assertFalse($this->trustedServers->isOwnCloudServer($server)); - + $this->trustedServers->isOwnCloudServer($server); } /** * @dataProvider dataTestCheckOwnCloudVersion - * - * @param $statusphp - * @param $expected */ - public function testCheckOwnCloudVersion($statusphp, $expected) { - $this->assertSame($expected, - $this->invokePrivate($this->trustedServers, 'checkOwnCloudVersion', [$statusphp]) - ); + public function testCheckOwnCloudVersion($status) { + $this->assertTrue($this->invokePrivate($this->trustedServers, 'checkOwnCloudVersion', [$status])); } public function dataTestCheckOwnCloudVersion() { return [ - ['{"version":"8.4.0"}', false], - ['{"version":"9.0.0"}', true], - ['{"version":"9.1.0"}', true] + ['{"version":"9.0.0"}'], + ['{"version":"9.1.0"}'] + ]; + } + + /** + * @dataProvider dataTestCheckOwnCloudVersionTooLow + * @expectedException \OC\HintException + * @expectedExceptionMessage Remote server version is too low. ownCloud 9.0 is required. + */ + public function testCheckOwnCloudVersionTooLow($status) { + $this->invokePrivate($this->trustedServers, 'checkOwnCloudVersion', [$status]); + } + + public function dataTestCheckOwnCloudVersionTooLow() { + return [ + ['{"version":"8.2.3"}'], ]; } diff --git a/apps/federation/tests/middleware/addservermiddlewaretest.php b/apps/federation/tests/middleware/addservermiddlewaretest.php index a94d907ae76..49e34cc73d6 100644 --- a/apps/federation/tests/middleware/addservermiddlewaretest.php +++ b/apps/federation/tests/middleware/addservermiddlewaretest.php @@ -27,6 +27,7 @@ use OC\HintException; use OCA\Federation\Middleware\AddServerMiddleware; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; +use OCP\ILogger; use Test\TestCase; class AddServerMiddlewareTest extends TestCase { @@ -93,7 +94,7 @@ class AddServerMiddlewareTest extends TestCase { public function dataTestAfterException() { return [ [new HintException('message', 'hint'), 'message', 'hint'], - [new \Exception('message'), 'message', 'Unknown error'], + [new \Exception('message'), 'message', 'message'], ]; } |