diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-03-30 17:03:04 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-04-07 15:43:59 +0200 |
commit | 3323d01db1eda016f6e4665ae094c85903a83856 (patch) | |
tree | 8845984a62b5bd0d7b27bdbcdc7325c9dc3ee6de /apps | |
parent | 676a4c781a5ff16ea34259c2958521596efc89b1 (diff) | |
download | nextcloud-server-3323d01db1eda016f6e4665ae094c85903a83856.tar.gz nextcloud-server-3323d01db1eda016f6e4665ae094c85903a83856.zip |
update unit tests
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps')
5 files changed, 12 insertions, 42 deletions
diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php index 61f87e9ec67..233395dec9f 100644 --- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php @@ -67,7 +67,7 @@ class RequestHandlerControllerTest extends TestCase { /** @var \OCA\FederatedFileSharing\AddressHandler|\PHPUnit_Framework_MockObject_MockObject */ private $addressHandler; - + /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ private $userManager; @@ -107,7 +107,7 @@ class RequestHandlerControllerTest extends TestCase { $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock(); $this->cloudIdManager = new CloudIdManager(); - + $this->registerHttpHelper($httpHelperMock); $this->s2s = new RequestHandlerController( @@ -384,6 +384,7 @@ class RequestHandlerControllerTest extends TestCase { 'parent' => null, 'accepted' => '0', 'expiration' => null, + 'password' => null, 'mail_send' => '0' ]; diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index b810a515082..bc525b6ef82 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -669,13 +669,14 @@ class ShareAPIController extends OCSController { throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist')); } + if ($permissions === null && $password === null && $publicUpload === null && $expireDate === null) { + throw new OCSBadRequestException($this->l->t('Wrong or no update parameter given')); + } + /* * expirationdate, password and publicUpload only make sense for link shares */ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { - if ($permissions === null && $password === null && $publicUpload === null && $expireDate === null) { - throw new OCSBadRequestException($this->l->t('Wrong or no update parameter given')); - } $newPermissions = null; if ($publicUpload === 'true') { diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 540905a7dc9..046ede1f83e 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -938,36 +938,6 @@ class ApiTest extends TestCase { /** * @medium - * @depends testCreateShareUserFile - */ - public function testUpdateShareInvalidPermissions() { - $node1 = $this->userFolder->get($this->filename); - $share1 = $this->shareManager->newShare(); - $share1->setNode($node1) - ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) - ->setPermissions(19); - $share1 = $this->shareManager->createShare($share1); - - $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - try { - $ocs->updateShare($share1->getId()); - $this->fail(); - } catch (OCSBadRequestException $e) { - - } - $ocs->cleanup(); - - //Permissions should not have changed! - $share1 = $this->shareManager->getShareById('ocinternal:' . $share1->getId()); - $this->assertEquals(19, $share1->getPermissions()); - - $this->shareManager->deleteShare($share1); - } - - /** - * @medium */ function testUpdateShareUpload() { $node1 = $this->userFolder->get($this->folder); diff --git a/apps/files_sharing/tests/MigrationTest.php b/apps/files_sharing/tests/MigrationTest.php index a357e814f25..708de1c0eca 100644 --- a/apps/files_sharing/tests/MigrationTest.php +++ b/apps/files_sharing/tests/MigrationTest.php @@ -429,11 +429,11 @@ class MigrationTest extends TestCase { foreach ($allShares as $share) { if ((int)$share['share_type'] === Share::SHARE_TYPE_LINK) { - $this->assertSame(null, $share['share_with']); + $this->assertNull( $share['share_with']); $this->assertSame('shareWith', $share['password']); } else { $this->assertSame('shareWith', $share['share_with']); - $this->assertSame(null, $share['password']); + $this->assertNull($share['password']); } } } diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 4ec62dc1a03..288ebb4bb45 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -23,7 +23,6 @@ namespace OCA\ShareByMail\Tests; -use OC\HintException; use OCA\ShareByMail\Settings\SettingsManager; use OCA\ShareByMail\ShareByMailProvider; use OCP\Files\IRootFolder; @@ -33,9 +32,7 @@ use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\Mail\IMailer; -use OCP\Security\IHasher; use OCP\Security\ISecureRandom; -use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IShare; use Test\TestCase; @@ -127,7 +124,8 @@ class ShareByMailProviderTest extends TestCase { $this->logger, $this->mailer, $this->urlGenerator, - $this->activityManager + $this->activityManager, + $this->settingsManager ] ); @@ -318,7 +316,7 @@ class ShareByMailProviderTest extends TestCase { $this->share->expects($this->once())->method('getPermissions')->willReturn($permissions + 1); $this->share->expects($this->once())->method('getShareOwner')->willReturn($uidOwner); $this->share->expects($this->once())->method('getSharedBy')->willReturn($sharedBy); - $this->share->expects($this->once())->method('getId')->willReturn($id); + $this->share->expects($this->atLeastOnce())->method('getId')->willReturn($id); $this->assertSame($this->share, $instance->update($this->share) |