From 03497ec8b6c693b148860b20ee836d4cb22007eb Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 16 Dec 2019 16:31:15 +0545 Subject: [PATCH 1/2] Update to latest drone starlark code --- .drone.starlark | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.starlark b/.drone.starlark index 4b3bd39d..aa49a644 100644 --- a/.drone.starlark +++ b/.drone.starlark @@ -1270,7 +1270,7 @@ def setupCeph(serviceParams): createFirstBucket = serviceParams['createFirstBucket'] if 'createFirstBucket' in serviceParams else True setupCommands = serviceParams['setupCommands'] if 'setupCommands' in serviceParams else [ - 'wait-for-it -t 120 ceph:80', + 'wait-for-it -t 600 ceph:80', 'cd /var/www/owncloud/server/apps/files_primary_s3', 'cp tests/drone/ceph.config.php /var/www/owncloud/server/config', 'cd /var/www/owncloud/server', @@ -1298,7 +1298,7 @@ def setupScality(serviceParams): createFirstBucket = serviceParams['createFirstBucket'] if 'createFirstBucket' in serviceParams else True createExtraBuckets = serviceParams['createExtraBuckets'] if 'createExtraBuckets' in serviceParams else False setupCommands = serviceParams['setupCommands'] if 'setupCommands' in serviceParams else [ - 'wait-for-it -t 120 scality:8000', + 'wait-for-it -t 600 scality:8000', 'cd /var/www/owncloud/server/apps/files_primary_s3', 'cp tests/drone/%s /var/www/owncloud/server/config' % configFile, 'cd /var/www/owncloud/server' From 542a4298e95f93b85c1947ca58057e980ce30e41 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 16 Dec 2019 16:32:06 +0545 Subject: [PATCH 2/2] Implement coding-standard 2.0.0 --- .../Dav/GroupMembershipCollectionTest.php | 42 ++++++++++++------- tests/unit/Dav/GroupsCollectionTest.php | 24 +++++++---- tests/unit/Dav/MembershipNodeTest.php | 18 +++++--- tests/unit/Dav/RootCollectionTest.php | 3 +- tests/unit/Dav/UsersCollectionTest.php | 18 +++++--- vendor-bin/owncloud-codestyle/composer.json | 2 +- 6 files changed, 71 insertions(+), 36 deletions(-) diff --git a/tests/unit/Dav/GroupMembershipCollectionTest.php b/tests/unit/Dav/GroupMembershipCollectionTest.php index d00826a3..4a85d8e7 100644 --- a/tests/unit/Dav/GroupMembershipCollectionTest.php +++ b/tests/unit/Dav/GroupMembershipCollectionTest.php @@ -191,9 +191,10 @@ public function testDeleteAsAdmin() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteAsNonAdmin() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(['group_id' => 1, 'user_id' => self::CURRENT_USER, 'role' => CustomGroupsDatabaseHandler::ROLE_MEMBER]); $this->config->method('getSystemValue') ->willReturn(true); @@ -209,9 +210,10 @@ public function testDeleteAsNonAdmin() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteAsNonMember() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(null); $this->config->method('getSystemValue') ->willReturn(true); @@ -380,10 +382,11 @@ public function testAddMemberAsAdmin($isSuperAdmin, $currentMemberInfo) { } /** - * @expectedException \Sabre\DAV\Exception\PreconditionFailed * @dataProvider adminProvider */ public function testAddMemberAsAdminFails($isSuperAdmin, $currentMemberInfo) { + $this->expectException(\Sabre\DAV\Exception\PreconditionFailed::class); + $this->setCurrentUserMemberInfo($currentMemberInfo); $this->setCurrentUserSuperAdmin($isSuperAdmin); @@ -401,10 +404,11 @@ public function testAddMemberAsAdminFails($isSuperAdmin, $currentMemberInfo) { } /** - * @expectedException \Sabre\DAV\Exception\PreconditionFailed * @dataProvider adminProvider */ public function testAddNonExistingMemberAsAdmin($isSuperAdmin, $currentMemberInfo) { + $this->expectException(\Sabre\DAV\Exception\PreconditionFailed::class); + $this->setCurrentUserMemberInfo($currentMemberInfo); $this->setCurrentUserSuperAdmin($isSuperAdmin); @@ -420,10 +424,11 @@ public function testAddNonExistingMemberAsAdmin($isSuperAdmin, $currentMemberInf } /** - * @expectedException \Sabre\DAV\Exception\PreconditionFailed * @dataProvider adminProvider */ public function testAddNonExistingMemberMismatchCaseAsAdmin($isSuperAdmin, $currentMemberInfo) { + $this->expectException(\Sabre\DAV\Exception\PreconditionFailed::class); + $this->setCurrentUserMemberInfo($currentMemberInfo); $this->setCurrentUserSuperAdmin($isSuperAdmin); @@ -439,9 +444,10 @@ public function testAddNonExistingMemberMismatchCaseAsAdmin($isSuperAdmin, $curr } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testAddMemberAsNonAdmin() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(['group_id' => 1, 'user_id' => self::CURRENT_USER, 'role' => CustomGroupsDatabaseHandler::ROLE_MEMBER]); $this->config->method('getSystemValue') @@ -456,9 +462,10 @@ public function testAddMemberAsNonAdmin() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testAddMemberAsNonMember() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(null); $this->config->method('getSystemValue') @@ -473,9 +480,10 @@ public function testAddMemberAsNonMember() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testAddMemberWithShareToMemberRestrictionAndNoCommonGroup() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(['group_id' => 1, 'user_id' => self::CURRENT_USER, 'role' => CustomGroupsDatabaseHandler::ROLE_ADMIN]); $this->config->method('getSystemValue') ->willReturn(true); @@ -537,9 +545,10 @@ public function testIsMember() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testIsMemberAsNonMember() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(null); $this->config->method('getSystemValue') ->willReturn(true); @@ -598,9 +607,10 @@ public function testGetMember($isSuperAdmin, $currentMemberInfo) { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testGetMemberAsNonMember() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(null); $this->config->method('getSystemValue') ->willReturn(true); @@ -671,9 +681,10 @@ public function testSearchMembers($isSuperAdmin, $currentMemberInfo) { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testGetMembersAsNonMember() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(null); $this->config->method('getSystemValue') ->willReturn(true); @@ -684,16 +695,18 @@ public function testGetMembersAsNonMember() { } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testSetName() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->node->setName('x'); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testCreateDirectory() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->node->createDirectory('somedir'); } @@ -711,9 +724,10 @@ public function providesUpdateDisplayNameValidateException() { /** * @dataProvider providesUpdateDisplayNameValidateException * @param string $groupName - * @expectedException \OCA\CustomGroups\Exception\ValidationException */ public function testUpdateDisplayNameValidatException($groupName) { + $this->expectException(\OCA\CustomGroups\Exception\ValidationException::class); + $this->node->updateDisplayName($groupName); } } diff --git a/tests/unit/Dav/GroupsCollectionTest.php b/tests/unit/Dav/GroupsCollectionTest.php index 4177f808..65ec3855 100644 --- a/tests/unit/Dav/GroupsCollectionTest.php +++ b/tests/unit/Dav/GroupsCollectionTest.php @@ -250,9 +250,10 @@ public function testCreateGroup() { } /** - * @expectedException \Sabre\DAV\Exception\Conflict */ public function testCreateGroupNoDuplicates() { + $this->expectException(\Sabre\DAV\Exception\Conflict::class); + $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('user1'); $this->userSession->method('getUser')->willReturn($user); @@ -287,9 +288,10 @@ public function providesTestCreateException() { /** * @dataProvider providesTestCreateException - * @expectedException \OCA\CustomGroups\Exception\ValidationException */ public function testCreateGroupExceptions($groupName, $displayName) { + $this->expectException(\OCA\CustomGroups\Exception\ValidationException::class); + $mkCol = new MkCol([], [ GroupMembershipCollection::PROPERTY_DISPLAY_NAME => $displayName ]); @@ -314,9 +316,10 @@ public function testCreateGroupExceptionsStatusCode($groupName, $displayName) { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testCreateGroupNoPermission() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $helper = $this->createMock(MembershipHelper::class); $helper->expects($this->once()) ->method('canCreateGroups') @@ -338,9 +341,10 @@ public function testCreateGroupNoPermission() { } /** - * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ public function testCreateGroupAlreadyExists() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->handler->expects($this->once()) ->method('createGroup') ->with('group1', 'group1') @@ -364,9 +368,10 @@ public function testGetGroup() { } /** - * @expectedException \Sabre\DAV\Exception\NotFound */ public function testGetGroupNonExisting() { + $this->expectException(\Sabre\DAV\Exception\NotFound::class); + $this->handler->expects($this->any()) ->method('getGroupByUri') ->with('groupx') @@ -388,23 +393,26 @@ public function testGroupExists() { } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testSetName() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->setName('x'); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testDelete() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->delete(); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testCreateFile() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->createFile('somefile.txt'); } } diff --git a/tests/unit/Dav/MembershipNodeTest.php b/tests/unit/Dav/MembershipNodeTest.php index bd7d12df..9a7e95c2 100644 --- a/tests/unit/Dav/MembershipNodeTest.php +++ b/tests/unit/Dav/MembershipNodeTest.php @@ -203,9 +203,10 @@ public function testDeleteAsAdmin() { } /** - * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ public function testDeleteAsAdminFailed() { + $this->expectException(\Sabre\DAV\Exception\PreconditionFailed::class); + $memberInfo = ['group_id' => 1, 'user_id' => self::CURRENT_USER, 'role' => CustomGroupsDatabaseHandler::ROLE_ADMIN]; $this->config->method('getSystemValue') ->willReturn(true); @@ -229,9 +230,10 @@ public function testDeleteAsAdminFailed() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteAsNonAdmin() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->setCurrentUserMemberInfo(['group_id' => 1, 'user_id' => self::CURRENT_USER, 'role' => CustomGroupsDatabaseHandler::ROLE_MEMBER]); $this->config->method('getSystemValue') ->willReturn(true); @@ -334,9 +336,10 @@ public function testDeleteSelfAsNonAdmin() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteAsNonMember() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->config->method('getSystemValue') ->willReturn(true); $this->groupManager->method('isAdmin') @@ -377,9 +380,10 @@ public function testDeleteAsSuperAdmin() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteSelfAsLastAdmin() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->config->method('getSystemValue') ->willReturn(true); $this->groupManager->method('isAdmin') @@ -403,9 +407,10 @@ public function testDeleteSelfAsLastAdmin() { } /** - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteLastAdminAsSuperAdmin() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->config->method('getSystemValue') ->willReturn(true); $this->groupManager->method('isAdmin') @@ -611,9 +616,10 @@ public function testUnsetdminWhenLastAdminAsSuperAdmin() { } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testSetName() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->node->setName('x'); } } diff --git a/tests/unit/Dav/RootCollectionTest.php b/tests/unit/Dav/RootCollectionTest.php index 57e164d2..964adf57 100644 --- a/tests/unit/Dav/RootCollectionTest.php +++ b/tests/unit/Dav/RootCollectionTest.php @@ -59,9 +59,10 @@ public function testGetUsers() { } /** - * @expectedException Sabre\DAV\Exception\NotFound */ public function testGetNonExisting() { + $this->expectException(\Sabre\DAV\Exception\NotFound::class); + $this->collection->getChild('somethingelse'); } } diff --git a/tests/unit/Dav/UsersCollectionTest.php b/tests/unit/Dav/UsersCollectionTest.php index 8852f301..16aa21bd 100644 --- a/tests/unit/Dav/UsersCollectionTest.php +++ b/tests/unit/Dav/UsersCollectionTest.php @@ -111,16 +111,18 @@ public function testBase() { } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testListUsers() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->getChildren(); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testCreateUser() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->createDirectory('user1'); } @@ -131,9 +133,10 @@ public function testGetCurrentUser() { } /** - * @expectedException Sabre\DAV\Exception\Forbidden */ public function testGetAnotherUser() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->collection->getChild('another'); } @@ -153,23 +156,26 @@ public function testUserExistsAnother() { } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testSetName() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->setName('x'); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testDelete() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->delete(); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ public function testCreateFile() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->collection->createFile('somefile.txt'); } } diff --git a/vendor-bin/owncloud-codestyle/composer.json b/vendor-bin/owncloud-codestyle/composer.json index d55aad75..c1738f3a 100644 --- a/vendor-bin/owncloud-codestyle/composer.json +++ b/vendor-bin/owncloud-codestyle/composer.json @@ -1,5 +1,5 @@ { "require": { - "owncloud/coding-standard": "^1.0" + "owncloud/coding-standard": "^2.0" } } \ No newline at end of file