From db6d785644fb9c9369a9af9245bcb52ec935af96 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 4 Aug 2017 17:32:08 +0200 Subject: Add PHP 7.2 testing container Signed-off-by: Lukas Reschke --- .drone.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.drone.yml b/.drone.yml index a8d1940d9de..eff40807d04 100644 --- a/.drone.yml +++ b/.drone.yml @@ -171,6 +171,14 @@ pipeline: matrix: DB: NODB PHP: 7.1 + nodb-php7.2: + image: nextcloudci/php7.2:php7.2-3 + commands: + - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite + when: + matrix: + DB: NODB + PHP: 7.2 sqlite-php5.6: image: nextcloudci/php5.6:php5.6-7 commands: @@ -195,6 +203,14 @@ pipeline: matrix: DB: sqlite PHP: 7.1 + sqlite-php7.2: + image: nextcloudci/php7.2:php7.2-3 + commands: + - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite + when: + matrix: + DB: sqlite + PHP: 7.2 mysql-php5.6: image: nextcloudci/php5.6:php5.6-7 commands: @@ -599,6 +615,9 @@ matrix: - DB: NODB PHP: 7.1 ENABLE_REDIS: true + - DB: NODB + PHP: 7.2 + ENABLE_REDIS: false - DB: sqlite PHP: 5.6 ENABLE_REDIS: true @@ -608,6 +627,9 @@ matrix: - DB: sqlite PHP: 7.1 ENABLE_REDIS: true + - DB: sqlite + PHP: 7.2 + ENABLE_REDIS: false - DB: mysql PHP: 5.6 ENABLE_REDIS: true -- cgit v1.2.3 From e9dc4f107a25ecaddb1f1bbd979e397540a1b3c8 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 4 Aug 2017 17:33:31 +0200 Subject: Make declaration compatible Signed-off-by: Lukas Reschke --- lib/private/Lockdown/Filesystem/NullStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Lockdown/Filesystem/NullStorage.php b/lib/private/Lockdown/Filesystem/NullStorage.php index 831d8a8b2a0..3f3aad3df03 100644 --- a/lib/private/Lockdown/Filesystem/NullStorage.php +++ b/lib/private/Lockdown/Filesystem/NullStorage.php @@ -157,7 +157,7 @@ class NullStorage extends Common { return false; } - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); } -- cgit v1.2.3 From 0857780eb0d4e16ad29d1a7b17e00257f029b736 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 4 Aug 2017 17:33:52 +0200 Subject: Update PHP 7.2 container Signed-off-by: Lukas Reschke --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index eff40807d04..0cfbe6403dc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -172,7 +172,7 @@ pipeline: DB: NODB PHP: 7.1 nodb-php7.2: - image: nextcloudci/php7.2:php7.2-3 + image: nextcloudci/php7.2:php7.2-4 commands: - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite when: @@ -204,7 +204,7 @@ pipeline: DB: sqlite PHP: 7.1 sqlite-php7.2: - image: nextcloudci/php7.2:php7.2-3 + image: nextcloudci/php7.2:php7.2-4 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite when: -- cgit v1.2.3 From c78e999b2113c088d156f396e83759686635dec0 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 4 Aug 2017 17:47:48 +0200 Subject: Make definition compatible Signed-off-by: Lukas Reschke --- lib/private/Files/Storage/FailedStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/Storage/FailedStorage.php b/lib/private/Files/Storage/FailedStorage.php index d2aae33bb21..d4046b62fee 100644 --- a/lib/private/Files/Storage/FailedStorage.php +++ b/lib/private/Files/Storage/FailedStorage.php @@ -184,7 +184,7 @@ class FailedStorage extends Common { return true; } - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } -- cgit v1.2.3 From 70d42afb936293e5f8caefd0ee2224c4c5f0bcf3 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 4 Aug 2017 18:06:17 +0200 Subject: Use non-deprecated INTL_IDNA_VARIANT_UTS46 Signed-off-by: Lukas Reschke --- lib/private/Mail/Mailer.php | 2 +- lib/private/Mail/Message.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index e438f75d2ce..d232587df63 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -170,7 +170,7 @@ class Mailer implements IMailer { } list($name, $domain) = explode('@', $email, 2); - $domain = idn_to_ascii($domain); + $domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46); return $name.'@'.$domain; } diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php index 5ffc050360a..2d3c49d0ce1 100644 --- a/lib/private/Mail/Message.php +++ b/lib/private/Mail/Message.php @@ -58,11 +58,11 @@ class Message { foreach($addresses as $email => $readableName) { if(!is_numeric($email)) { list($name, $domain) = explode('@', $email, 2); - $domain = idn_to_ascii($domain); + $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); $convertedAddresses[$name.'@'.$domain] = $readableName; } else { list($name, $domain) = explode('@', $readableName, 2); - $domain = idn_to_ascii($domain); + $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); $convertedAddresses[$email] = $name.'@'.$domain; } } -- cgit v1.2.3 From 3bd104ef7c32ca4e1616c9caade1fb59dd1aab29 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 6 Aug 2017 21:27:28 +0200 Subject: Fix LoginController Signed-off-by: Roeland Jago Douma --- tests/Core/Controller/LoginControllerTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index 493bade9dd8..169beff2b9d 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -291,6 +291,10 @@ class LoginControllerTest extends TestCase { $this->userManager->expects($this->once()) ->method('checkPasswordNoLogging') ->will($this->returnValue(false)); + $this->userManager->expects($this->once()) + ->method('getByEmail') + ->with($user) + ->willReturn([]); $this->urlGenerator->expects($this->once()) ->method('linkToRoute') ->with('core.login.showLoginForm', [ -- cgit v1.2.3 From 8b0051eb4005522fef2d92f0a18ffaea673bc4e4 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 6 Aug 2017 21:33:16 +0200 Subject: Fix encryption test Signed-off-by: Roeland Jago Douma --- tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index a66ff14a778..80d62b16578 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -173,8 +173,9 @@ class EncryptionTest extends Storage { ->method('get') ->willReturnCallback(function($path) {return ['encrypted' => false, 'path' => $path];}); - $this->mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') - ->disableOriginalConstructor()->getMock(); + $this->mountManager = $this->createMock(\OC\Files\Mount\Manager::class); + $this->mountManager->method('findByStorageId') + ->willReturn([]); $this->instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') ->setConstructorArgs( -- cgit v1.2.3 From 459ae6d94af6bd8c20ecb0ad09c6649764817ada Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 6 Aug 2017 21:52:26 +0200 Subject: User proper anonymous function Signed-off-by: Roeland Jago Douma --- lib/private/Route/Route.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/private/Route/Route.php b/lib/private/Route/Route.php index 3a953af9011..c25d08e8bc2 100644 --- a/lib/private/Route/Route.php +++ b/lib/private/Route/Route.php @@ -148,11 +148,12 @@ class Route extends SymfonyRoute implements IRoute { * @return void */ public function actionInclude($file) { - $function = create_function('$param', - 'unset($param["_route"]);' - .'$_GET=array_merge($_GET, $param);' - .'unset($param);' - .'require_once "'.$file.'";'); + $function = function($param) use ($file) { + unset($param["_route"]); + $_GET=array_merge($_GET, $param); + unset($param); + require_once "'.$file.'"; + } ; $this->action($function); } } -- cgit v1.2.3 From 9717cdfb9ed91db270564e2a2c364e78ba3c920e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 7 Aug 2017 14:19:41 +0200 Subject: If there is no content don't error Signed-off-by: Roeland Jago Douma --- lib/private/AppFramework/Http/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index 956744e5d5e..7e21434c734 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -432,7 +432,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { // 'application/json' must be decoded manually. if (strpos($this->getHeader('Content-Type'), 'application/json') !== false) { $params = json_decode(file_get_contents($this->inputStream), true); - if(count($params) > 0) { + if($params !== null && count($params) > 0) { $this->items['params'] = $params; if($this->method === 'POST') { $this->items['post'] = $params; -- cgit v1.2.3 From ba7cf03daf4028806b9950ea2730c9282596b9a7 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 9 Aug 2017 15:46:51 +0200 Subject: Fix LostControllerTest Signed-off-by: Roeland Jago Douma --- tests/Core/Controller/LostControllerTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index d7098aafcc2..ef419e40b40 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -261,6 +261,10 @@ class LostControllerTest extends \Test\TestCase { array(false, $nonExistingUser) ))); + $this->userManager + ->method('getByEmail') + ->willReturn([]); + // With a non existing user $response = $this->lostController->email($nonExistingUser); $expectedResponse = new JSONResponse([ -- cgit v1.2.3 From db27bbf90d916193f4884f96570811913c2b8b9e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 9 Aug 2017 16:01:09 +0200 Subject: Fix CacheTest Signed-off-by: Roeland Jago Douma --- tests/lib/Files/Cache/CacheTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index 5e6301d689a..bc95a9004f8 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -352,7 +352,7 @@ class CacheTest extends \Test\TestCase { $id4 = $this->cache->put($file4, $fileData['foo2']); $id5 = $this->cache->put($file5, $fileData['foo3']); - $tagManager = \OC::$server->getTagManager()->load('files', null, null, $userId); + $tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId); $this->assertTrue($tagManager->tagAs($id1, 'tag1')); $this->assertTrue($tagManager->tagAs($id1, 'tag2')); $this->assertTrue($tagManager->tagAs($id2, 'tag2')); @@ -422,7 +422,7 @@ class CacheTest extends \Test\TestCase { $id4 = $this->cache->put($file4, $fileData['foo2']); $id5 = $this->cache->put($file5, $fileData['foo3']); - $tagManager = \OC::$server->getTagManager()->load('files', null, null, $userId); + $tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId); $this->assertTrue($tagManager->tagAs($id1, 'tag1')); $this->assertTrue($tagManager->tagAs($id1, 'tag2')); $this->assertTrue($tagManager->tagAs($id2, 'tag2')); -- cgit v1.2.3 From 26bf0ca9d42150efd2cd42d624d863908769f510 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 9 Aug 2017 16:04:57 +0200 Subject: Fix RepairMimeTypeTest Signed-off-by: Roeland Jago Douma --- tests/lib/Repair/RepairMimeTypesTest.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index f30bbdf7d11..6f3ed5ce318 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -54,16 +54,22 @@ class RepairMimeTypesTest extends \Test\TestCase { protected function tearDown() { $this->storage->getCache()->clear(); - $sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?'; - \OC_DB::executeAudited($sql, [$this->storage->getId()]); + + $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); + $qb->delete('storages') + ->where($qb->expr()->eq('id', $qb->createNamedParameter($this->storage->getId()))); + $qb->execute(); + $this->clearMimeTypes(); parent::tearDown(); } private function clearMimeTypes() { - $sql = 'DELETE FROM `*PREFIX*mimetypes`'; - \OC_DB::executeAudited($sql); + $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); + $qb->delete('mimetypes'); + $qb->execute(); + $this->mimetypeLoader->reset(); } -- cgit v1.2.3 From 1ea7f14f0a0986e4e78ead038b8601475ad71df6 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 9 Aug 2017 16:13:54 +0200 Subject: Fix SessionTest Signed-off-by: Roeland Jago Douma --- tests/lib/User/SessionTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index fcff4f64726..c4d29b979ae 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -434,6 +434,9 @@ class SessionTest extends \Test\TestCase { ->method('getSystemValue') ->with('token_auth_enforced', false) ->will($this->returnValue(false)); + $manager->method('getByEmail') + ->with('unexist') + ->willReturn([]); $this->assertFalse($userSession->logClientIn('unexist', 'doe', $request, $this->throttler)); } @@ -1163,6 +1166,10 @@ class SessionTest extends \Test\TestCase { ->method('getTime') ->will($this->returnValue(100)); + $manager->method('getByEmail') + ->with('john') + ->willReturn([]); + $userSession->logClientIn('john', 'doe', $request, $this->throttler); $this->assertEquals(10000, $token->getLastActivity()); @@ -1213,6 +1220,10 @@ class SessionTest extends \Test\TestCase { ->method('getTime') ->will($this->returnValue(100)); + $manager->method('getByEmail') + ->with('john') + ->willReturn([]); + $userSession->logClientIn('john', 'doe', $request, $this->throttler); } -- cgit v1.2.3 From c81e79f8b9c5ddd6dd40b4ecdc43ad3c18810dc9 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 9 Aug 2017 16:15:27 +0200 Subject: Fix files_sharing CacheTests Signed-off-by: Roeland Jago Douma --- apps/files_sharing/tests/CacheTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index 26ba5b21e46..82f4ad62f67 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -243,7 +243,7 @@ class CacheTest extends TestCase { $id2 = $this->sharedCache->get('subdir/another too.txt')['fileid']; $id3 = $this->sharedCache->get('subdir/not a text file.xml')['fileid']; $id4 = $this->sharedCache->get('subdir/another.txt')['fileid']; - $tagManager = \OC::$server->getTagManager()->load('files', null, null, $userId); + $tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId); $tagManager->tagAs($id1, 'tag1'); $tagManager->tagAs($id1, 'tag2'); $tagManager->tagAs($id2, 'tag1'); @@ -285,7 +285,7 @@ class CacheTest extends TestCase { $this->sharedCache->get('subdir/emptydir')['fileid'], $this->sharedCache->get('subdir/emptydir2')['fileid'], ); - $tagManager = \OC::$server->getTagManager()->load('files', null, null, $userId); + $tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId); foreach ($allIds as $id) { $tagManager->tagAs($id, 'tag1'); } -- cgit v1.2.3 From c6f6413bb195f043e6054bc8b38dedcf1bfdf6cc Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 9 Aug 2017 16:43:40 +0200 Subject: Fix ldap tests Signed-off-by: Roeland Jago Douma --- apps/user_ldap/tests/User/UserTest.php | 2 ++ apps/user_ldap/tests/User_LDAPTest.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index 0437051b134..f48abc9ce4a 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -1269,6 +1269,7 @@ class UserTest extends \Test\TestCase { return array( array( 'pwdchangedtime' => array((new \DateTime())->sub(new \DateInterval('P28D'))->format('Ymdhis').'Z'), + 'pwdgraceusetime' => [], ), ); } @@ -1342,6 +1343,7 @@ class UserTest extends \Test\TestCase { array( 'pwdpolicysubentry' => array('cn=custom,ou=policies,dc=foo,dc=bar'), 'pwdchangedtime' => array((new \DateTime())->sub(new \DateInterval('P28D'))->format('Ymdhis').'Z'), + 'pwdgraceusetime' => [], ) ); } diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index aaf67ebcab6..ced5009148d 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -135,6 +135,9 @@ class User_LDAPTest extends TestCase { return false; } })); + + $access->method('fetchUsersByLoginName') + ->willReturn([]); } /** @@ -353,6 +356,9 @@ class User_LDAPTest extends TestCase { $access->expects($this->any()) ->method('nextcloudUserNames') ->will($this->returnArgument(0)); + + $access->method('fetchUsersByLoginName') + ->willReturn([]); } public function testGetUsersNoParam() { @@ -760,6 +766,9 @@ class User_LDAPTest extends TestCase { $access->expects($this->any()) ->method('getUserMapper') ->will($this->returnValue($userMapper)); + + $access->method('fetchUsersByLoginName') + ->willReturn([]); } public function testGetDisplayName() { -- cgit v1.2.3