[files_sharing] Remove unneeded update steps
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
6bd1c50dc3
commit
4d7c7b1816
2 changed files with 0 additions and 263 deletions
|
@ -24,17 +24,6 @@ use OCA\Files_Sharing\Migration;
|
|||
|
||||
$installedVersion = \OC::$server->getConfig()->getAppValue('files_sharing', 'installed_version');
|
||||
|
||||
// Migration OC8.2 -> OC9
|
||||
if (version_compare($installedVersion, '0.9.1', '<')) {
|
||||
$m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
|
||||
$m->removeReShares();
|
||||
$m->updateInitiatorInfo();
|
||||
}
|
||||
|
||||
if (version_compare($installedVersion, '1.1.1', '<')) {
|
||||
$m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
|
||||
}
|
||||
|
||||
if (version_compare($installedVersion, '1.4.0', '<')) {
|
||||
$m = new Migration(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig());
|
||||
$m->addPasswordColumn();
|
||||
|
|
|
@ -68,198 +68,6 @@ class MigrationTest extends TestCase {
|
|||
$query->delete($this->table)->execute();
|
||||
}
|
||||
|
||||
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
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_CONTACT)
|
||||
->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
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
||||
->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
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
||||
->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
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_GROUP)
|
||||
->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
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
||||
->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
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
||||
->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
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_USER)
|
||||
->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()
|
||||
);
|
||||
$parent = $query->getLastInsertId();
|
||||
// third re-share, should be attached to the first user share after migration
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_REMOTE)
|
||||
->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()
|
||||
);
|
||||
|
||||
// Link reshare should keep its parent
|
||||
$query->setParameter('share_type', Share::SHARE_TYPE_LINK)
|
||||
->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()
|
||||
);
|
||||
}
|
||||
|
||||
public function testRemoveReShares() {
|
||||
$this->addDummyValues();
|
||||
$this->migration->removeReShares();
|
||||
$this->verifyResult();
|
||||
}
|
||||
|
||||
public function verifyResult() {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->select('*')->from($this->table)->orderBy('id');
|
||||
|
@ -297,66 +105,6 @@ class MigrationTest extends TestCase {
|
|||
$this->assertSame($result[7]['id'], $result[9]['parent']);
|
||||
}
|
||||
|
||||
public function test1001DeepReshares() {
|
||||
$parent = null;
|
||||
for ($i = 0; $i < 1001; $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', Share::SHARE_TYPE_USER)
|
||||
->setParameter('share_with', 'user'.($i+1))
|
||||
->setParameter('uid_owner', 'user'.($i))
|
||||
->setParameter('uid_initiator', null)
|
||||
->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();
|
||||
$this->migration->updateInitiatorInfo();
|
||||
|
||||
$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']);
|
||||
$this->assertEquals('user' . ($i), $share['uid_initiator']);
|
||||
$this->assertEquals('user0', $share['uid_owner']);
|
||||
$this->assertEquals(null, $share['parent']);
|
||||
$i++;
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
$this->assertEquals(1001, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that we really remove the "shareapi_allow_mail_notification" setting only
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue