Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-10-12 20:55:12 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-11-02 03:09:01 +0300
commit00e4c8aee4cbf2cf7ba71da8a1321dadf08f3409 (patch)
tree5f48254ca8c0ac91939c45f58261141d04861a07 /tests
parent8bfbefa11734e99d0550eb679efccb7773b4a1d7 (diff)
Fix update share tests
The update share tests only checked that the share returned by "update()" had the expected values. However, as "update()" returns the same share that was given as a parameter the tests were not really verifying that the values were updated in the database. In a similar way, the test that checked that a password was removed did not set a password first, so even if the database returned null it could be simply returning the default value for the share; a password must be set first to ensure that it is removed. Besides that, a typo was fixed too that made the checks on the original share instead of on the one returned by "update()"; right now it is the same share, so the change makes no difference, but it is how the check should be done anyway. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php52
1 files changed, 50 insertions, 2 deletions
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 19f37160627..d368304453f 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -1788,6 +1788,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ $this->assertSame('user3', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
}
public function testUpdateLink() {
@@ -1833,7 +1841,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share2 = $this->provider->update($share);
$this->assertEquals($id, $share2->getId());
- $this->assertEquals('password', $share->getPassword());
+ $this->assertEquals('password', $share2->getPassword());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ $this->assertEquals('password', $share2->getPassword());
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
@@ -1843,6 +1859,12 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, 'foo', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->update('share');
+ $qb->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
+ $qb->set('password', $qb->createNamedParameter('password'));
+ $this->assertEquals(1, $qb->execute());
+
$users = [];
for($i = 0; $i < 6; $i++) {
$user = $this->createMock(IUser::class);
@@ -1882,7 +1904,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share2 = $this->provider->update($share);
$this->assertEquals($id, $share2->getId());
- $this->assertEquals(null, $share->getPassword());
+ $this->assertEquals(null, $share2->getPassword());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ $this->assertEquals(null, $share2->getPassword());
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
@@ -1949,6 +1979,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user4', $share2->getSharedBy());
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
+
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ // Group shares do not allow updating the recipient
+ $this->assertSame('group0', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
}
public function testUpdateGroupSubShares() {
@@ -2019,6 +2058,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
+ $share2 = $this->provider->getShareById($id);
+
+ $this->assertEquals($id, $share2->getId());
+ // Group shares do not allow updating the recipient
+ $this->assertSame('group0', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
+ $this->assertSame(1, $share2->getPermissions());
+
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
->from('share')