summaryrefslogtreecommitdiffstats
path: root/tests/lib/Repair/RepairInvalidSharesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Repair/RepairInvalidSharesTest.php')
-rw-r--r--tests/lib/Repair/RepairInvalidSharesTest.php153
1 files changed, 1 insertions, 152 deletions
diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php
index 83dbed7d202..fa75f58472a 100644
--- a/tests/lib/Repair/RepairInvalidSharesTest.php
+++ b/tests/lib/Repair/RepairInvalidSharesTest.php
@@ -39,7 +39,7 @@ class RepairInvalidSharesTest extends TestCase {
$config->expects($this->any())
->method('getSystemValue')
->with('version')
- ->will($this->returnValue('8.0.0.0'));
+ ->will($this->returnValue('12.0.0.0'));
$this->connection = \OC::$server->getDatabaseConnection();
$this->deleteAllShares();
@@ -60,157 +60,6 @@ class RepairInvalidSharesTest extends TestCase {
}
/**
- * Test remove expiration date for non-link shares
- */
- public function testRemoveExpirationDateForNonLinkShares() {
- // user share with bogus expiration date
- $qb = $this->connection->getQueryBuilder();
- $qb->insert('share')
- ->values([
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER),
- 'share_with' => $qb->expr()->literal('recipientuser1'),
- 'uid_owner' => $qb->expr()->literal('user1'),
- 'item_type' => $qb->expr()->literal('folder'),
- 'item_source' => $qb->expr()->literal(123),
- 'item_target' => $qb->expr()->literal('/123'),
- 'file_source' => $qb->expr()->literal(123),
- 'file_target' => $qb->expr()->literal('/test'),
- 'permissions' => $qb->expr()->literal(1),
- 'stime' => $qb->expr()->literal(time()),
- 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00')
- ])
- ->execute();
-
- $bogusShareId = $this->getLastShareId();
-
- // link share with expiration date
- $qb = $this->connection->getQueryBuilder();
- $qb->insert('share')
- ->values([
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_LINK),
- 'uid_owner' => $qb->expr()->literal('user1'),
- 'item_type' => $qb->expr()->literal('folder'),
- 'item_source' => $qb->expr()->literal(123),
- 'item_target' => $qb->expr()->literal('/123'),
- 'file_source' => $qb->expr()->literal(123),
- 'file_target' => $qb->expr()->literal('/test'),
- 'permissions' => $qb->expr()->literal(1),
- 'stime' => $qb->expr()->literal(time()),
- 'expiration' => $qb->expr()->literal('2015-09-25 00:00:00'),
- 'token' => $qb->expr()->literal('abcdefg')
- ])->execute();
-
- /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
- $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->repair->run($outputMock);
-
- $results = $this->connection->getQueryBuilder()
- ->select('*')
- ->from('share')
- ->orderBy('share_type', 'ASC')
- ->execute()
- ->fetchAll();
-
- $this->assertCount(2, $results);
-
- $userShare = $results[0];
- $linkShare = $results[1];
- $this->assertEquals($bogusShareId, $userShare['id'], 'sanity check');
- $this->assertNull($userShare['expiration'], 'bogus expiration date was removed');
- $this->assertNotNull($linkShare['expiration'], 'valid link share expiration date still there');
- }
-
- /**
- * Test remove expiration date for non-link shares
- */
- public function testAddShareLinkDeletePermission() {
- $oldPerms = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE;
- $newPerms = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE;
-
- // share with old permissions
- $qb = $this->connection->getQueryBuilder();
- $qb->insert('share')
- ->values([
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_LINK),
- 'uid_owner' => $qb->expr()->literal('user1'),
- 'item_type' => $qb->expr()->literal('folder'),
- 'item_source' => $qb->expr()->literal(123),
- 'item_target' => $qb->expr()->literal('/123'),
- 'file_source' => $qb->expr()->literal(123),
- 'file_target' => $qb->expr()->literal('/test'),
- 'permissions' => $qb->expr()->literal($oldPerms),
- 'stime' => $qb->expr()->literal(time()),
- ])
- ->execute();
-
- $bogusShareId = $this->getLastShareId();
-
- // share with read-only permissions
- $qb = $this->connection->getQueryBuilder();
- $qb->insert('share')
- ->values([
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_LINK),
- 'uid_owner' => $qb->expr()->literal('user1'),
- 'item_type' => $qb->expr()->literal('folder'),
- 'item_source' => $qb->expr()->literal(123),
- 'item_target' => $qb->expr()->literal('/123'),
- 'file_source' => $qb->expr()->literal(123),
- 'file_target' => $qb->expr()->literal('/test'),
- 'permissions' => $qb->expr()->literal(\OCP\Constants::PERMISSION_READ),
- 'stime' => $qb->expr()->literal(time()),
- ])
- ->execute();
-
- $keepThisShareId = $this->getLastShareId();
-
- // user share to keep
- $qb = $this->connection->getQueryBuilder();
- $qb->insert('share')
- ->values([
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER),
- 'share_with' => $qb->expr()->literal('recipientuser1'),
- 'uid_owner' => $qb->expr()->literal('user1'),
- 'item_type' => $qb->expr()->literal('folder'),
- 'item_source' => $qb->expr()->literal(123),
- 'item_target' => $qb->expr()->literal('/123'),
- 'file_source' => $qb->expr()->literal(123),
- 'file_target' => $qb->expr()->literal('/test'),
- 'permissions' => $qb->expr()->literal(3),
- 'stime' => $qb->expr()->literal(time()),
- ])
- ->execute();
-
- $keepThisShareId2 = $this->getLastShareId();
-
- /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
- $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->repair->run($outputMock);
-
- $results = $this->connection->getQueryBuilder()
- ->select('*')
- ->from('share')
- ->orderBy('permissions', 'ASC')
- ->execute()
- ->fetchAll();
-
- $this->assertCount(3, $results);
-
- $untouchedShare = $results[0];
- $untouchedShare2 = $results[1];
- $updatedShare = $results[2];
- $this->assertEquals($keepThisShareId, $untouchedShare['id'], 'sanity check');
- $this->assertEquals($keepThisShareId2, $untouchedShare2['id'], 'sanity check');
- $this->assertEquals($bogusShareId, $updatedShare['id'], 'sanity check');
- $this->assertEquals($newPerms, $updatedShare['permissions'], 'delete permission was added');
- }
-
- /**
* Test remove shares where the parent share does not exist anymore
*/
public function testSharesNonExistingParent() {