2015-01-12 19:04:19 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-01-12 19:04:19 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* @license AGPL-3.0
|
2015-01-12 19:04:19 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
2015-01-12 19:04:19 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2015-01-12 19:04:19 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-03-26 13:44:34 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2015-01-12 19:04:19 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-01-12 19:04:19 +03:00
|
|
|
*
|
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2016-05-17 12:42:03 +03:00
|
|
|
namespace OCA\Files_Sharing\Tests;
|
|
|
|
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2015-01-12 19:04:19 +03:00
|
|
|
use OCA\Files_Sharing\Migration;
|
2017-03-28 16:11:07 +03:00
|
|
|
use OCP\Share;
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2015-11-03 03:52:41 +03:00
|
|
|
/**
|
|
|
|
* Class MigrationTest
|
|
|
|
*
|
|
|
|
* @group DB
|
|
|
|
*/
|
2015-01-12 19:04:19 +03:00
|
|
|
class MigrationTest extends TestCase {
|
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
/** @var \OCP\IDBConnection */
|
2015-01-12 19:04:19 +03:00
|
|
|
private $connection;
|
|
|
|
|
2016-11-02 14:03:52 +03:00
|
|
|
/** @var \OCP\IConfig */
|
|
|
|
private $config;
|
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
/** @var Migration */
|
|
|
|
private $migration;
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
private $table = 'share';
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
$this->connection = \OC::$server->getDatabaseConnection();
|
2016-11-02 14:03:52 +03:00
|
|
|
$this->config = \OC::$server->getConfig();
|
|
|
|
$this->migration = new Migration($this->connection, $this->config);
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
$this->cleanDB();
|
|
|
|
}
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
|
|
|
$this->cleanDB();
|
|
|
|
}
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
private function cleanDB() {
|
|
|
|
$query = $this->connection->getQueryBuilder();
|
|
|
|
$query->delete($this->table)->execute();
|
|
|
|
}
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
public function addDummyValues() {
|
|
|
|
$query = $this->connection->getQueryBuilder();
|
|
|
|
$query->insert($this->table)
|
|
|
|
->values(
|
|
|
|
array(
|
|
|
|
'share_type' => $query->createParameter('share_type'),
|
|
|
|
'share_with' => $query->createParameter('share_with'),
|
|
|
|
'uid_owner' => $query->createParameter('uid_owner'),
|
|
|
|
'uid_initiator' => $query->createParameter('uid_initiator'),
|
|
|
|
'parent' => $query->createParameter('parent'),
|
|
|
|
'item_type' => $query->createParameter('item_type'),
|
|
|
|
'item_source' => $query->createParameter('item_source'),
|
|
|
|
'item_target' => $query->createParameter('item_target'),
|
|
|
|
'file_source' => $query->createParameter('file_source'),
|
|
|
|
'file_target' => $query->createParameter('file_target'),
|
|
|
|
'permissions' => $query->createParameter('permissions'),
|
|
|
|
'stime' => $query->createParameter('stime'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
// shared contact, shouldn't be modified
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_CONTACT)
|
2016-01-12 18:28:47 +03:00
|
|
|
->setParameter('share_with', 'user1')
|
|
|
|
->setParameter('uid_owner', 'owner1')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', null)
|
|
|
|
->setParameter('item_type', 'contact')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', null)
|
|
|
|
->setParameter('file_target', null)
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
|
|
|
// shared calendar, shouldn't be modified
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
2016-01-12 18:28:47 +03:00
|
|
|
->setParameter('share_with', 'user1')
|
|
|
|
->setParameter('uid_owner', 'owner1')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', null)
|
|
|
|
->setParameter('item_type', 'calendar')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', null)
|
|
|
|
->setParameter('file_target', null)
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
|
|
|
// single user share, shouldn't be modified
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
2016-01-12 18:28:47 +03:00
|
|
|
->setParameter('share_with', 'user1')
|
|
|
|
->setParameter('uid_owner', 'owner1')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', null)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foo')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
|
|
|
// single group share, shouldn't be modified
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_GROUP)
|
2016-01-12 18:28:47 +03:00
|
|
|
->setParameter('share_with', 'group1')
|
|
|
|
->setParameter('uid_owner', 'owner1')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', null)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foo')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
|
|
|
$parent = $query->getLastInsertId();
|
|
|
|
// unique target for group share, shouldn't be modified
|
|
|
|
$query->setParameter('share_type', 2)
|
|
|
|
->setParameter('share_with', 'group1')
|
|
|
|
->setParameter('uid_owner', 'owner1')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', $parent)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foo renamed')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
|
|
|
// first user share, shouldn't be modified
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
2016-01-12 18:28:47 +03:00
|
|
|
->setParameter('share_with', 'user1')
|
|
|
|
->setParameter('uid_owner', 'owner2')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', null)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foobar')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
|
|
|
$parent = $query->getLastInsertId();
|
|
|
|
// first re-share, should be attached to the first user share after migration
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
2016-01-12 18:28:47 +03:00
|
|
|
->setParameter('share_with', 'user2')
|
|
|
|
->setParameter('uid_owner', 'user1')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', $parent)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foobar')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
|
|
|
$parent = $query->getLastInsertId();
|
|
|
|
// second re-share, should be attached to the first user share after migration
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
2016-01-12 18:28:47 +03:00
|
|
|
->setParameter('share_with', 'user3')
|
|
|
|
->setParameter('uid_owner', 'user2')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', $parent)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foobar')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
2016-02-08 17:11:48 +03:00
|
|
|
$parent = $query->getLastInsertId();
|
|
|
|
// third re-share, should be attached to the first user share after migration
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_REMOTE)
|
2016-02-08 17:11:48 +03:00
|
|
|
->setParameter('share_with', 'user@server.com')
|
|
|
|
->setParameter('uid_owner', 'user3')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', $parent)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foobar')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
2016-02-11 15:28:15 +03:00
|
|
|
|
|
|
|
// Link reshare should keep its parent
|
2017-03-28 16:11:07 +03:00
|
|
|
$query->setParameter('share_type', Share::SHARE_TYPE_LINK)
|
2016-02-11 15:28:15 +03:00
|
|
|
->setParameter('share_with', null)
|
|
|
|
->setParameter('uid_owner', 'user3')
|
|
|
|
->setParameter('uid_initiator', '')
|
|
|
|
->setParameter('parent', $parent)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foobar')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
$this->assertSame(1,
|
|
|
|
$query->execute()
|
|
|
|
);
|
2016-01-12 18:28:47 +03:00
|
|
|
}
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
public function testRemoveReShares() {
|
|
|
|
$this->addDummyValues();
|
|
|
|
$this->migration->removeReShares();
|
|
|
|
$this->verifyResult();
|
|
|
|
}
|
2015-01-12 19:04:19 +03:00
|
|
|
|
2016-01-12 18:28:47 +03:00
|
|
|
public function verifyResult() {
|
|
|
|
$query = $this->connection->getQueryBuilder();
|
|
|
|
$query->select('*')->from($this->table)->orderBy('id');
|
|
|
|
$result = $query->execute()->fetchAll();
|
2016-02-11 15:28:15 +03:00
|
|
|
$this->assertSame(10, count($result));
|
2016-01-12 18:28:47 +03:00
|
|
|
|
|
|
|
// shares which shouldn't be modified
|
|
|
|
for ($i = 0; $i < 4; $i++) {
|
|
|
|
$this->assertSame('owner1', $result[$i]['uid_owner']);
|
|
|
|
$this->assertEmpty($result[$i]['uid_initiator']);
|
|
|
|
$this->assertNull($result[$i]['parent']);
|
|
|
|
}
|
|
|
|
// group share with unique target
|
|
|
|
$this->assertSame('owner1', $result[4]['uid_owner']);
|
|
|
|
$this->assertEmpty($result[4]['uid_initiator']);
|
|
|
|
$this->assertNotEmpty($result[4]['parent']);
|
|
|
|
// initial user share which was re-shared
|
|
|
|
$this->assertSame('owner2', $result[5]['uid_owner']);
|
|
|
|
$this->assertEmpty($result[5]['uid_initiator']);
|
|
|
|
$this->assertNull($result[5]['parent']);
|
|
|
|
// flatted re-shares
|
2016-02-08 17:11:48 +03:00
|
|
|
for($i = 6; $i < 9; $i++) {
|
2016-01-12 18:28:47 +03:00
|
|
|
$this->assertSame('owner2', $result[$i]['uid_owner']);
|
|
|
|
$user = 'user' . ($i - 5);
|
|
|
|
$this->assertSame($user, $result[$i]['uid_initiator']);
|
|
|
|
$this->assertNull($result[$i]['parent']);
|
2015-01-12 19:04:19 +03:00
|
|
|
}
|
2016-02-11 15:28:15 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The link share is flattend but has an owner to avoid invisible shares
|
|
|
|
* see: https://github.com/owncloud/core/pull/22317
|
|
|
|
*/
|
|
|
|
$this->assertSame('owner2', $result[9]['uid_owner']);
|
|
|
|
$this->assertSame('user3', $result[9]['uid_initiator']);
|
|
|
|
$this->assertSame($result[7]['id'], $result[9]['parent']);
|
2015-01-12 19:04:19 +03:00
|
|
|
}
|
|
|
|
|
2016-01-25 20:06:34 +03:00
|
|
|
public function test1001DeepReshares() {
|
2016-01-25 19:57:41 +03:00
|
|
|
$parent = null;
|
2016-01-25 20:06:34 +03:00
|
|
|
for ($i = 0; $i < 1001; $i++) {
|
2016-01-25 19:57:41 +03:00
|
|
|
$query = $this->connection->getQueryBuilder();
|
|
|
|
$query->insert($this->table)
|
|
|
|
->values(
|
|
|
|
[
|
|
|
|
'share_type' => $query->createParameter('share_type'),
|
|
|
|
'share_with' => $query->createParameter('share_with'),
|
|
|
|
'uid_owner' => $query->createParameter('uid_owner'),
|
|
|
|
'uid_initiator' => $query->createParameter('uid_initiator'),
|
|
|
|
'parent' => $query->createParameter('parent'),
|
|
|
|
'item_type' => $query->createParameter('item_type'),
|
|
|
|
'item_source' => $query->createParameter('item_source'),
|
|
|
|
'item_target' => $query->createParameter('item_target'),
|
|
|
|
'file_source' => $query->createParameter('file_source'),
|
|
|
|
'file_target' => $query->createParameter('file_target'),
|
|
|
|
'permissions' => $query->createParameter('permissions'),
|
|
|
|
'stime' => $query->createParameter('stime'),
|
|
|
|
]
|
|
|
|
)
|
2017-03-28 16:11:07 +03:00
|
|
|
->setParameter('share_type', Share::SHARE_TYPE_USER)
|
2016-01-25 19:57:41 +03:00
|
|
|
->setParameter('share_with', 'user'.($i+1))
|
|
|
|
->setParameter('uid_owner', 'user'.($i))
|
2016-01-25 20:06:34 +03:00
|
|
|
->setParameter('uid_initiator', null)
|
2016-01-25 19:57:41 +03:00
|
|
|
->setParameter('parent', $parent)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foobar')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
|
|
|
|
$this->assertSame(1, $query->execute());
|
|
|
|
$parent = $query->getLastInsertId();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->migration->removeReShares();
|
2016-01-25 20:06:34 +03:00
|
|
|
$this->migration->updateInitiatorInfo();
|
2016-01-25 19:57:41 +03:00
|
|
|
|
|
|
|
$qb = $this->connection->getQueryBuilder();
|
|
|
|
|
|
|
|
$stmt = $qb->select('id', 'share_with', 'uid_owner', 'uid_initiator', 'parent')
|
|
|
|
->from('share')
|
|
|
|
->orderBy('id', 'asc')
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
while($share = $stmt->fetch()) {
|
|
|
|
$this->assertEquals('user'.($i+1), $share['share_with']);
|
2016-01-25 20:06:34 +03:00
|
|
|
$this->assertEquals('user' . ($i), $share['uid_initiator']);
|
|
|
|
$this->assertEquals('user0', $share['uid_owner']);
|
2016-01-25 19:57:41 +03:00
|
|
|
$this->assertEquals(null, $share['parent']);
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
$stmt->closeCursor();
|
2016-01-25 20:06:34 +03:00
|
|
|
$this->assertEquals(1001, $i);
|
2016-01-25 19:57:41 +03:00
|
|
|
}
|
2016-11-02 14:03:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* test that we really remove the "shareapi_allow_mail_notification" setting only
|
|
|
|
*/
|
|
|
|
public function testRemoveSendMailOption() {
|
|
|
|
$this->config->setAppValue('core', 'shareapi_setting1', 'dummy-value');
|
|
|
|
$this->config->setAppValue('core', 'shareapi_allow_mail_notification', 'no');
|
|
|
|
$this->config->setAppValue('core', 'shareapi_allow_public_notification', 'no');
|
|
|
|
|
|
|
|
$this->migration->removeSendMailOption();
|
|
|
|
|
|
|
|
$this->assertNull(
|
|
|
|
$this->config->getAppValue('core', 'shareapi_allow_mail_notification', null)
|
|
|
|
);
|
|
|
|
$this->assertNull(
|
|
|
|
$this->config->getAppValue('core', 'shareapi_allow_public_notification', null)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame('dummy-value',
|
|
|
|
$this->config->getAppValue('core', 'shareapi_setting1', null)
|
|
|
|
);
|
|
|
|
}
|
2017-03-28 16:11:07 +03:00
|
|
|
|
|
|
|
public function testAddPasswordColumn() {
|
|
|
|
|
|
|
|
$shareTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_EMAIL, Share::SHARE_TYPE_LINK];
|
|
|
|
|
|
|
|
foreach ($shareTypes as $shareType) {
|
|
|
|
|
|
|
|
for ($i = 0; $i < 5; $i++) {
|
|
|
|
$query = $this->connection->getQueryBuilder();
|
|
|
|
$query->insert($this->table)
|
|
|
|
->values(
|
|
|
|
[
|
|
|
|
'share_type' => $query->createParameter('share_type'),
|
|
|
|
'share_with' => $query->createParameter('share_with'),
|
|
|
|
'uid_owner' => $query->createParameter('uid_owner'),
|
|
|
|
'uid_initiator' => $query->createParameter('uid_initiator'),
|
|
|
|
'parent' => $query->createParameter('parent'),
|
|
|
|
'item_type' => $query->createParameter('item_type'),
|
|
|
|
'item_source' => $query->createParameter('item_source'),
|
|
|
|
'item_target' => $query->createParameter('item_target'),
|
|
|
|
'file_source' => $query->createParameter('file_source'),
|
|
|
|
'file_target' => $query->createParameter('file_target'),
|
|
|
|
'permissions' => $query->createParameter('permissions'),
|
|
|
|
'stime' => $query->createParameter('stime'),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
->setParameter('share_type', $shareType)
|
|
|
|
->setParameter('share_with', 'shareWith')
|
|
|
|
->setParameter('uid_owner', 'user' . ($i))
|
|
|
|
->setParameter('uid_initiator', null)
|
|
|
|
->setParameter('parent', 0)
|
|
|
|
->setParameter('item_type', 'file')
|
|
|
|
->setParameter('item_source', '2')
|
|
|
|
->setParameter('item_target', '/2')
|
|
|
|
->setParameter('file_source', 2)
|
|
|
|
->setParameter('file_target', '/foobar')
|
|
|
|
->setParameter('permissions', 31)
|
|
|
|
->setParameter('stime', time());
|
|
|
|
|
|
|
|
$this->assertSame(1, $query->execute());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->migration->addPasswordColumn();
|
|
|
|
|
|
|
|
$query = $this->connection->getQueryBuilder();
|
|
|
|
$query->select('*')->from('share');
|
|
|
|
$allShares = $query->execute()->fetchAll();
|
|
|
|
|
|
|
|
foreach ($allShares as $share) {
|
|
|
|
if ((int)$share['share_type'] === Share::SHARE_TYPE_LINK) {
|
|
|
|
$this->assertSame(null, $share['share_with']);
|
|
|
|
$this->assertSame('shareWith', $share['password']);
|
|
|
|
} else {
|
|
|
|
$this->assertSame('shareWith', $share['share_with']);
|
|
|
|
$this->assertSame(null, $share['password']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-12 19:04:19 +03:00
|
|
|
}
|