diff --git a/.github/workflows/phpunit-mariadb.yml b/.github/workflows/phpunit-mariadb.yml index 9a9b646792fb5..b8b70029dc31c 100644 --- a/.github/workflows/phpunit-mariadb.yml +++ b/.github/workflows/phpunit-mariadb.yml @@ -104,6 +104,7 @@ jobs: ini-file: development ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies diff --git a/.github/workflows/phpunit-memcached.yml b/.github/workflows/phpunit-memcached.yml index 96729c1e8dd58..7aa42765fe9a8 100644 --- a/.github/workflows/phpunit-memcached.yml +++ b/.github/workflows/phpunit-memcached.yml @@ -88,6 +88,7 @@ jobs: ini-file: development ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies diff --git a/.github/workflows/phpunit-mysql-sharding.yml b/.github/workflows/phpunit-mysql-sharding.yml index f8c458b8e961a..204b151b92e18 100644 --- a/.github/workflows/phpunit-mysql-sharding.yml +++ b/.github/workflows/phpunit-mysql-sharding.yml @@ -56,8 +56,8 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.2'] - mysql-versions: ['8.4'] + php-versions: ["8.2"] + mysql-versions: ["8.4"] name: Sharding - MySQL ${{ matrix.mysql-versions }} (PHP ${{ matrix.php-versions }}) - database tests @@ -137,6 +137,7 @@ jobs: ini-file: development ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml index ffc1f9d90a3c0..a0f4a3f3136ed 100644 --- a/.github/workflows/phpunit-mysql.yml +++ b/.github/workflows/phpunit-mysql.yml @@ -104,6 +104,7 @@ jobs: ini-file: development ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies diff --git a/.github/workflows/phpunit-nodb.yml b/.github/workflows/phpunit-nodb.yml index 3c7af086a4bd1..3504d3568754a 100644 --- a/.github/workflows/phpunit-nodb.yml +++ b/.github/workflows/phpunit-nodb.yml @@ -59,9 +59,9 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.3', '8.4', '8.5'] + php-versions: ["8.3", "8.4", "8.5"] include: - - php-versions: '8.2' + - php-versions: "8.2" coverage: ${{ github.event_name != 'pull_request' }} name: No DB unit tests (PHP ${{ matrix.php-versions }}) @@ -86,12 +86,13 @@ jobs: with: php-version: ${{ matrix.php-versions }} # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation - extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, imagick, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite + extensions: apcu, bz2, ctype, curl, dom, fileinfo, gd, iconv, imagick, intl, json, libxml, mbstring, openssl, pcntl, pdo_sqlite, posix, redis, session, simplexml, sqlite, xmlreader, xmlwriter, zip, zlib coverage: ${{ matrix.coverage && 'xdebug' || 'none' }} ini-file: development # Required for tests that use pcntl ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies @@ -106,7 +107,7 @@ jobs: php -f tests/enable_all.php - name: PHPUnit nodb testsuite - run: composer run test -- --exclude-group DB --exclude-group SLOWDB --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.nodb.xml' || '' }} + run: composer run test -- --exclude-group DB --exclude-group SLOWDB --exclude-group Memcached --exclude-group PRIMARY-swift --exclude-group PRIMARY-s3 --exclude-group PRIMARY-azure --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.nodb.xml' || '' }} - name: Upload nodb code coverage if: ${{ !cancelled() && matrix.coverage }} diff --git a/.github/workflows/phpunit-object-store-primary.yml b/.github/workflows/phpunit-object-store-primary.yml index b7187d349a0a0..0b1e0106b71c7 100644 --- a/.github/workflows/phpunit-object-store-primary.yml +++ b/.github/workflows/phpunit-object-store-primary.yml @@ -49,8 +49,8 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.2'] - key: ['s3', 's3-multibucket'] + php-versions: ["8.2"] + key: ["s3", "s3-multibucket"] name: php${{ matrix.php-versions }}-${{ matrix.key }}-minio @@ -84,6 +84,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up Nextcloud @@ -113,10 +114,9 @@ jobs: docker ps -a docker ps -aq | while read container ; do IMAGE=$(docker inspect --format='{{.Config.Image}}' $container); echo $IMAGE; docker logs $container; echo "\n\n" ; done - object-store-primary-summary: runs-on: ubuntu-latest-low - needs: [changes,object-store-primary-tests-minio] + needs: [changes, object-store-primary-tests-minio] if: always() diff --git a/.github/workflows/phpunit-oci.yml b/.github/workflows/phpunit-oci.yml index c53687707d943..2e524df428f90 100644 --- a/.github/workflows/phpunit-oci.yml +++ b/.github/workflows/phpunit-oci.yml @@ -111,6 +111,7 @@ jobs: ini-file: development ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml index a7c3814315604..789ac9ff0d54c 100644 --- a/.github/workflows/phpunit-pgsql.yml +++ b/.github/workflows/phpunit-pgsql.yml @@ -107,6 +107,7 @@ jobs: ini-file: development ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index 22236155fec3d..0ff8a56e5a14b 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -90,6 +90,7 @@ jobs: ini-file: development ini-values: disable_functions="" env: + fail-fast: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up dependencies @@ -110,7 +111,7 @@ jobs: run: ./occ app:list && echo "======= System config =======" && ./occ config:list system - name: PHPUnit database tests - run: composer run test:db -- --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.db.xml' || '' }} tests/lib/Preview/PostscriptTest.php + run: composer run test:db -- --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.db.xml' || '' }} - name: Upload db code coverage if: ${{ !cancelled() && matrix.coverage }} diff --git a/apps/dav/lib/CardDAV/AddressBookImpl.php b/apps/dav/lib/CardDAV/AddressBookImpl.php index 0668d8fdb7367..2413b2c9cc34f 100644 --- a/apps/dav/lib/CardDAV/AddressBookImpl.php +++ b/apps/dav/lib/CardDAV/AddressBookImpl.php @@ -41,9 +41,10 @@ public function __construct( /** * @return string defining the technical unique key * @since 5.0.0 + * @since 35.0.0 Typed return type */ #[\Override] - public function getKey() { + public function getKey(): string { return (string)$this->addressBookInfo['id']; } diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 6d406b1739a5b..a29961c2a2ae6 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -496,10 +496,9 @@ protected function userToPrincipal($user, ?array $propertyFilter = null) { }; $userId = $user->getUID(); - $displayName = $user->getDisplayName(); $principal = [ 'uri' => $this->principalPrefix . '/' . $userId, - '{DAV:}displayname' => is_null($displayName) ? $userId : $displayName, + '{DAV:}displayname' => $user->getDisplayName(), '{urn:ietf:params:xml:ns:caldav}calendar-user-type' => 'INDIVIDUAL', ]; diff --git a/apps/dav/tests/unit/Connector/Sabre/AddExtraHeadersPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/AddExtraHeadersPluginTest.php index 2906afea7d8d3..f913010773b79 100644 --- a/apps/dav/tests/unit/Connector/Sabre/AddExtraHeadersPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/AddExtraHeadersPluginTest.php @@ -81,9 +81,13 @@ function ($method, $callback) use (&$afterPut): void { $this->tree->expects($this->once())->method('getNodeForPath') ->willReturn($node); - $user = $this->createMock(IUser::class); - $node->expects($this->once())->method('getOwner')->willReturn($user); - $user->expects($this->once())->method('getUID')->willReturn($ownerId); + if ($ownerId !== null) { + $user = $this->createMock(IUser::class); + $node->expects($this->once())->method('getOwner')->willReturn($user); + $user->expects($this->once())->method('getUID')->willReturn($ownerId); + } else { + $node->expects($this->once())->method('getOwner')->willReturn(null); + } $node->expects($this->once())->method('getDavPermissions')->willReturn($permissions); $matcher = $this->exactly($expectedInvocations); diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php index 8699903e1ec10..8cd19b1143cac 100644 --- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php @@ -101,6 +101,10 @@ public function testGetPrincipalsByPrefixWithUsers(): void { ->expects($this->once()) ->method('getSystemEMailAddress') ->willReturn('bar@nextcloud.com'); + $barUser + ->expects($this->once()) + ->method('getDisplayName') + ->willReturn('bar'); $this->userManager ->expects($this->once()) ->method('search') @@ -189,6 +193,10 @@ public function testGetPrincipalsByPathWithoutMail(): void { ->expects($this->once()) ->method('getUID') ->willReturn('foo'); + $fooUser + ->expects($this->once()) + ->method('getDisplayName') + ->willReturn('foo'); $this->userManager ->expects($this->once()) ->method('get') @@ -221,6 +229,10 @@ public function testGetPrincipalsByPathWithMail(): void { ->expects($this->once()) ->method('getUID') ->willReturn('foo'); + $fooUser + ->expects($this->once()) + ->method('getDisplayName') + ->willReturn('foo'); $this->userManager ->expects($this->once()) ->method('get') diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php index 1ed6bc9b3fe01..eedd3aba726ae 100644 --- a/apps/files_sharing/tests/ShareTest.php +++ b/apps/files_sharing/tests/ShareTest.php @@ -148,8 +148,6 @@ public function testShareWithDifferentShareFolder(): void { } public function testShareWithGroupUniqueName(): void { - $this->markTestSkipped('TODO: Disable because fails on drone'); - $this->loginHelper(self::TEST_FILES_SHARING_API_USER1); Filesystem::file_put_contents('test.txt', 'test'); diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index b5edf37bf2f2c..b32b2ccb7c687 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -850,7 +850,7 @@ private static function calculateFreeSpace(Folder $userFolder, int|float $trashb $softQuota = true; $quota = $user->getQuota(); - if ($quota === null || $quota === 'none') { + if ($quota === 'none') { $quota = Filesystem::free_space('/'); $softQuota = false; // inf or unknown free space diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 47f14d96b61c6..cf49e5a1d4d26 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -879,7 +879,7 @@ public static function expire($filename, $uid) { $softQuota = true; $quota = $user->getQuota(); - if ($quota === null || $quota === 'none') { + if ($quota === 'none') { $quota = Filesystem::free_space('/'); $softQuota = false; } else { diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index b251610e67f96..3cda3ae74ba2a 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -216,7 +216,7 @@ public function getGroupUsersDetails(string $groupId, string $search = '', ?int foreach ($users as $user) { try { /** @var IUser $user */ - $userId = (string)$user->getUID(); + $userId = $user->getUID(); $userData = $this->getUserData($userId); // Do not insert empty entry if ($userData !== null) { diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php index 39a4dbc42c0e6..1a47fa5b74f00 100644 --- a/apps/settings/tests/Controller/UsersControllerTest.php +++ b/apps/settings/tests/Controller/UsersControllerTest.php @@ -675,7 +675,7 @@ public static function dataTestSetUserSettingsSubset(): array { } #[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataTestSaveUserSettings')] - public function testSaveUserSettings(array $data, ?string $oldEmailAddress, ?string $oldDisplayName): void { + public function testSaveUserSettings(array $data, ?string $oldEmailAddress, string $oldDisplayName): void { $controller = $this->getController(); $user = $this->createMock(IUser::class); @@ -690,7 +690,7 @@ public function testSaveUserSettings(array $data, ?string $oldEmailAddress, ?str ->with($data[IAccountManager::PROPERTY_EMAIL]['value']); } - if ($data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName ?? '') { + if ($data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName) { $user->expects($this->never())->method('setDisplayName'); } else { $user->expects($this->once())->method('setDisplayName') @@ -775,7 +775,7 @@ public static function dataTestSaveUserSettings(): array { IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'john@example.com', - null + '' ], [ [ @@ -783,7 +783,7 @@ public static function dataTestSaveUserSettings(): array { IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'JOHN@example.com', - null + '' ], ]; } diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 3bc0580be366a..3cc86922dada4 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -313,7 +313,7 @@ public function writeToCache($key, $value, ?int $ttlOverride = null): void { $key = $this->getCacheKey($key); $value = base64_encode(json_encode($value)); $ttl = $ttlOverride ?? $this->configuration->ldapCacheTTL; - $this->cache->set($key, $value, $ttl); + $this->cache->set($key, $value, (int)$ttl); } public function clearCache() { diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php index 8450e787a873d..3551daf261ba5 100644 --- a/apps/user_ldap/tests/AccessTest.php +++ b/apps/user_ldap/tests/AccessTest.php @@ -712,7 +712,7 @@ public function testUserStateUpdate(): void { ->method('__get') ->willReturnMap([ [ 'ldapUserDisplayName', 'displayName' ], - [ 'ldapUserDisplayName2', null], + [ 'ldapUserDisplayName2', ''], ]); $offlineUserMock = $this->createMock(OfflineUser::class); diff --git a/build/integration/features/bootstrap/Avatar.php b/build/integration/features/bootstrap/Avatar.php index 59d9ed920a110..e3ebde513a7d0 100644 --- a/build/integration/features/bootstrap/Avatar.php +++ b/build/integration/features/bootstrap/Avatar.php @@ -183,15 +183,11 @@ private function getColorFromLastAvatar() { // on solid color images the resizing can cause some small // artifacts that slightly modify the color of certain pixels. if (!$this->isSameColor($firstPixelColor, $currentPixelColor)) { - imagedestroy($image); - return null; } } } - imagedestroy($image); - return $firstPixelColor; } diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index fe478aab69d41..ca0d4b6785c53 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -3417,6 +3417,7 @@ + diff --git a/composer.json b/composer.json index 03881a15fc071..56ab4e65aabed 100644 --- a/composer.json +++ b/composer.json @@ -84,9 +84,9 @@ ], "test": [ "Composer\\Config::disableProcessTimeout", - "phpunit --fail-on-warning --fail-on-risky --display-warnings --display-deprecations --display-phpunit-deprecations --colors=always --configuration tests/phpunit-autotest.xml" + "phpunit --fail-on-warning --fail-on-risky --display-warnings --display-deprecations --display-phpunit-deprecations --display-skipped --colors=always --configuration tests/phpunit-autotest.xml" ], - "test:db": "@composer run test -- --group DB --group SLOWDB", + "test:db": "@composer run test -- --group DB --group SLOWDB --exclude-group S3 --exclude-group PRIMARY-swift --exclude-group PRIMARY-s3 --exclude-group PRIMARY-azure", "test:files_external": "phpunit --fail-on-warning --fail-on-risky --display-warnings --display-deprecations --display-phpunit-deprecations --colors=always --configuration tests/phpunit-autotest-external.xml", "rector": "rector --config=build/rector.php && composer cs:fix", "rector:strict": "rector --config=build/rector-strict.php && composer cs:fix", diff --git a/core/Command/Background/Job.php b/core/Command/Background/Job.php index 4ab7c930b790c..f8e3df9972afa 100644 --- a/core/Command/Background/Job.php +++ b/core/Command/Background/Job.php @@ -124,7 +124,6 @@ protected function printJobInfo(string $jobId, IJob $job, OutputInterface $outpu if ($isTimedJob) { $reflection = new \ReflectionClass($job); $intervalProperty = $reflection->getProperty('interval'); - $intervalProperty->setAccessible(true); $interval = $intervalProperty->getValue($job); $nextRun = new \DateTime(); diff --git a/core/Command/Background/JobBase.php b/core/Command/Background/JobBase.php index 558ccccf29dc8..484e2556d14d3 100644 --- a/core/Command/Background/JobBase.php +++ b/core/Command/Background/JobBase.php @@ -65,7 +65,6 @@ protected function printJobInfo(string $jobId, IJob $job, OutputInterface $outpu if ($isTimedJob) { $reflection = new \ReflectionClass($job); $intervalProperty = $reflection->getProperty('interval'); - $intervalProperty->setAccessible(true); $interval = $intervalProperty->getValue($job); $nextRun = new \DateTime(); diff --git a/lib/private/Authentication/Token/PublicKeyToken.php b/lib/private/Authentication/Token/PublicKeyToken.php index e3d5e7001ff5b..42c186f5e3373 100644 --- a/lib/private/Authentication/Token/PublicKeyToken.php +++ b/lib/private/Authentication/Token/PublicKeyToken.php @@ -205,6 +205,10 @@ public function getRemember(): int { return parent::getRemember(); } + public function getToken(): string { + return parent::getToken(); + } + #[\Override] public function setToken(string $token): void { parent::setToken($token); diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index a079c5e38f1ab..9f0d4ccbe9662 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -531,16 +531,18 @@ public function updatePasswords(string $uid, string $password) { $hashNeedsUpdate = []; foreach ($tokens as $t) { - if (!isset($hashNeedsUpdate[$t->getPasswordHash()])) { - if ($t->getPasswordHash() === null) { - $hashNeedsUpdate[$t->getPasswordHash() ?: ''] = true; - } elseif (!$this->hasher->verify(sha1($password) . $password, $t->getPasswordHash())) { - $hashNeedsUpdate[$t->getPasswordHash() ?: ''] = true; + $passwordHash = $t->getPasswordHash(); + if ($passwordHash === null) { + $hashNeedsUpdate[''] = true; + $needsUpdating = true; + } elseif (!isset($hashNeedsUpdate[$passwordHash])) { + if (!$this->hasher->verify(sha1($password) . $password, $passwordHash)) { + $hashNeedsUpdate[$passwordHash] = true; } else { - $hashNeedsUpdate[$t->getPasswordHash() ?: ''] = false; + $hashNeedsUpdate[$passwordHash] = false; } + $needsUpdating = $hashNeedsUpdate[$passwordHash] ?? true; } - $needsUpdating = $hashNeedsUpdate[$t->getPasswordHash() ?: ''] ?? true; if ($needsUpdating) { if ($newPasswordHash === null) { diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index 415a38ef41830..4dddfb3ed3779 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -452,7 +452,7 @@ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0 $matchingUsers = []; foreach ($groupUsers as $groupUser) { - $matchingUsers[(string)$groupUser->getUID()] = $groupUser->getDisplayName(); + $matchingUsers[$groupUser->getUID()] = $groupUser->getDisplayName(); } return $matchingUsers; } diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index dbf18a05c36a0..accdf47efe61c 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -287,7 +287,7 @@ public function findLocale($lang = null) { // Default : use system default locale $defaultLocale = $this->config->getSystemValue('default_locale', false); - if ($defaultLocale !== false && $this->localeExists($defaultLocale)) { + if (is_string($defaultLocale) && $this->localeExists($defaultLocale)) { return $defaultLocale; } @@ -463,12 +463,8 @@ public function getUserLanguage(?IUser $user = null): string { return $this->cleanLanguage($this->request->getParam('forceLanguage')) ?? $this->config->getSystemValueString('default_language', 'en'); } - /** - * @param string $locale - * @return bool - */ #[\Override] - public function localeExists($locale) { + public function localeExists(string $locale): bool { if ($locale === 'en') { //english is always available return true; } diff --git a/lib/private/TempManager.php b/lib/private/TempManager.php index f5801e5ab9896..fa7f891ca9272 100644 --- a/lib/private/TempManager.php +++ b/lib/private/TempManager.php @@ -50,13 +50,14 @@ public function getTemporaryFile($postFix = ''): string|false { $path = $this->generateTemporaryPath($postFix); $old_umask = umask(0077); - $fp = fopen($path, 'x'); + $fp = @fopen($path, 'x'); umask($old_umask); if ($fp === false) { $this->log->warning( 'Can not create a temporary file in directory {dir}. Check it exists and has correct permissions', [ 'dir' => $this->tmpBaseDir, + 'error' => error_get_last(), ] ); return false; @@ -71,11 +72,12 @@ public function getTemporaryFile($postFix = ''): string|false { public function getTemporaryFolder($postFix = ''): string|false { $path = $this->generateTemporaryPath($postFix) . '/'; - if (mkdir($path, 0700) === false) { + if (@mkdir($path, 0700) === false) { $this->log->warning( 'Can not create a temporary folder in directory {dir}. Check it exists and has correct permissions', [ 'dir' => $this->tmpBaseDir, + 'error' => error_get_last(), ] ); return false; diff --git a/lib/private/User/LazyUser.php b/lib/private/User/LazyUser.php index 3ae6a557a2dca..8a010782a03e2 100644 --- a/lib/private/User/LazyUser.php +++ b/lib/private/User/LazyUser.php @@ -1,6 +1,7 @@ displayName) { return $this->displayName; } @@ -56,7 +58,7 @@ public function getDisplayName() { } #[\Override] - public function setDisplayName($displayName) { + public function setDisplayName($displayName): bool { return $this->getUser()->setDisplayName($displayName); } @@ -76,12 +78,12 @@ public function updateLastLoginTimestamp(): bool { } #[\Override] - public function delete() { + public function delete(): bool { return $this->getUser()->delete(); } #[\Override] - public function setPassword($password, $recoveryPassword = null) { + public function setPassword($password, $recoveryPassword = null): bool { return $this->getUser()->setPassword($password, $recoveryPassword); } @@ -96,12 +98,12 @@ public function setPasswordHash(string $passwordHash): bool { } #[\Override] - public function getHome() { + public function getHome(): string { return $this->getUser()->getHome(); } #[\Override] - public function getBackendClassName() { + public function getBackendClassName(): string { return $this->getUser()->getBackendClassName(); } @@ -136,17 +138,17 @@ public function canEditProperty(string $property): bool { } #[\Override] - public function isEnabled() { + public function isEnabled(): bool { return $this->getUser()->isEnabled(); } #[\Override] - public function setEnabled(bool $enabled = true) { - return $this->getUser()->setEnabled($enabled); + public function setEnabled(bool $enabled = true): void { + $this->getUser()->setEnabled($enabled); } #[\Override] - public function getEMailAddress() { + public function getEMailAddress(): ?string { return $this->getUser()->getEMailAddress(); } @@ -161,17 +163,17 @@ public function getPrimaryEMailAddress(): ?string { } #[\Override] - public function getAvatarImage($size) { + public function getAvatarImage($size): ?IImage { return $this->getUser()->getAvatarImage($size); } #[\Override] - public function getCloudId() { + public function getCloudId(): string { return $this->getUser()->getCloudId(); } #[\Override] - public function setEMailAddress($mailAddress) { + public function setEMailAddress($mailAddress): void { $this->getUser()->setEMailAddress($mailAddress); } @@ -186,7 +188,7 @@ public function setPrimaryEMailAddress(string $mailAddress): void { } #[\Override] - public function getQuota() { + public function getQuota(): string { return $this->getUser()->getQuota(); } @@ -196,7 +198,7 @@ public function getQuotaBytes(): int|float { } #[\Override] - public function setQuota($quota) { + public function setQuota($quota): void { $this->getUser()->setQuota($quota); } diff --git a/lib/private/User/User.php b/lib/private/User/User.php index d22b8ae89a478..e54ac397b3efe 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -481,11 +481,9 @@ public function isEnabled(): bool { /** * set the enabled status for the user - * - * @return void */ #[\Override] - public function setEnabled(bool $enabled = true) { + public function setEnabled(bool $enabled = true): void { $oldStatus = $this->isEnabled(); $setDatabaseValue = function (bool $enabled): void { $this->config->setUserValue($this->uid, 'core', 'enabled', $enabled ? 'true' : 'false'); @@ -524,18 +522,12 @@ public function getEMailAddress(): ?string { return $this->getPrimaryEMailAddress() ?? $this->getSystemEMailAddress(); } - /** - * @inheritDoc - */ #[\Override] public function getSystemEMailAddress(): ?string { $email = $this->config->getUserValue($this->uid, 'settings', 'email', null); return $email ? mb_strtolower(trim($email)) : null; } - /** - * @inheritDoc - */ #[\Override] public function getPrimaryEMailAddress(): ?string { $email = $this->config->getUserValue($this->uid, 'settings', 'primary_email', null); diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index da8b9ded24c7a..60914b70dad77 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -314,7 +314,14 @@ public static function checkServer(SystemConfig $config) { [$urlGenerator->linkToDocs('admin-dir_permissions')]) ]; } - } elseif (!is_writable($CONFIG_DATADIRECTORY) || !is_readable($CONFIG_DATADIRECTORY)) { + } elseif (!is_readable($CONFIG_DATADIRECTORY)) { + $permissionsHint = $l->t('Permissions can usually be fixed by giving the web server write access to the root directory. See %s.', + [$urlGenerator->linkToDocs('admin-dir_permissions')]); + $errors[] = [ + 'error' => $l->t('Your data directory is not readable.'), + 'hint' => $permissionsHint + ]; + } elseif (!is_writable($CONFIG_DATADIRECTORY)) { // is_writable doesn't work for NFS mounts, so try to write a file and check if it exists. $testFile = sprintf('%s/%s.tmp', $CONFIG_DATADIRECTORY, uniqid('data_dir_writability_test_')); $handle = fopen($testFile, 'w'); diff --git a/lib/public/Cache/CappedMemoryCache.php b/lib/public/Cache/CappedMemoryCache.php index a071d7a9cb93d..40a4d26cbbe56 100644 --- a/lib/public/Cache/CappedMemoryCache.php +++ b/lib/public/Cache/CappedMemoryCache.php @@ -1,5 +1,7 @@ + * @template-implements \ArrayAccess */ class CappedMemoryCache implements ICache, \ArrayAccess { private int $capacity; @@ -37,7 +39,7 @@ public function __construct(int $capacity = 512) { * @since 25.0.0 */ #[\Override] - public function hasKey($key): bool { + public function hasKey(string|int $key): bool { return isset($this->cache[$key]); } @@ -46,25 +48,18 @@ public function hasKey($key): bool { * @since 25.0.0 */ #[\Override] - public function get($key) { + public function get(string|int $key) { return $this->cache[$key] ?? null; } /** * @inheritdoc - * @param string $key * @param T $value - * @param int $ttl * @since 25.0.0 - * @return bool */ #[\Override] - public function set($key, $value, $ttl = 0): bool { - if (is_null($key)) { - $this->cache[] = $value; - } else { - $this->cache[$key] = $value; - } + public function set(string|int $key, $value, int $ttl = 0): bool { + $this->cache[$key] = $value; $this->garbageCollect(); return true; } @@ -73,7 +68,7 @@ public function set($key, $value, $ttl = 0): bool { * @since 25.0.0 */ #[\Override] - public function remove($key): bool { + public function remove(string|int $key): bool { unset($this->cache[$key]); return true; } @@ -83,7 +78,7 @@ public function remove($key): bool { * @since 25.0.0 */ #[\Override] - public function clear($prefix = ''): bool { + public function clear(string $prefix = ''): bool { $this->cache = []; return true; } diff --git a/lib/public/IAddressBook.php b/lib/public/IAddressBook.php index 5a5cc487cee42..cd7a13e27d4d8 100644 --- a/lib/public/IAddressBook.php +++ b/lib/public/IAddressBook.php @@ -18,8 +18,9 @@ interface IAddressBook { /** * @return string defining the technical unique key * @since 5.0.0 + * @since 35.0.0 Typed return type */ - public function getKey(); + public function getKey(): string; /** * @return string defining the unique uri diff --git a/lib/public/ICache.php b/lib/public/ICache.php index 5e755d81e1448..8fd9fea7e60b6 100644 --- a/lib/public/ICache.php +++ b/lib/public/ICache.php @@ -1,5 +1,7 @@ method('getProperty') ->with('UID') ->willReturn('member1'); - $entries[0]->method('getProperty') + $entries[1]->method('getProperty') ->with('UID') ->willReturn('member2'); diff --git a/tests/data/guest_avatar_einstein_32.png b/tests/data/guest_avatar_einstein_32.png index d280dadcc8deb..d03f0509bac3b 100644 Binary files a/tests/data/guest_avatar_einstein_32.png and b/tests/data/guest_avatar_einstein_32.png differ diff --git a/tests/lib/Archive/TestBase.php b/tests/lib/Archive/TestBase.php index 24b518104d53a..fc5ad22c8f313 100644 --- a/tests/lib/Archive/TestBase.php +++ b/tests/lib/Archive/TestBase.php @@ -139,11 +139,9 @@ public function testMoveRemove(): void { $this->assertFalse($this->instance->fileExists('target.txt')); } public function testRecursive(): void { - $dir = \OC::$SERVERROOT . '/tests/data'; + $dir = \OC::$SERVERROOT . '/tests/data/themes'; $this->instance = $this->getNew(); $this->instance->addRecursive('/dir', $dir); - $this->assertTrue($this->instance->fileExists('/dir/lorem.txt')); - $this->assertTrue($this->instance->fileExists('/dir/data.zip')); - $this->assertTrue($this->instance->fileExists('/dir/data.tar.gz')); + $this->assertTrue($this->instance->fileExists('/dir/abc/apps/files/l10n/zz.json')); } } diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index 1c4bfba202d29..1e65b53f8f960 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -30,36 +30,25 @@ use Test\TestCase; class PublicKeyTokenProviderTest extends TestCase { - /** @var PublicKeyTokenProvider|\PHPUnit\Framework\MockObject\MockObject */ - private $tokenProvider; - /** @var PublicKeyTokenMapper|\PHPUnit\Framework\MockObject\MockObject */ - private $mapper; - /** @var IHasher|\PHPUnit\Framework\MockObject\MockObject */ - private $hasher; - /** @var ICrypto */ - private $crypto; - /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ - private $config; - /** @var IDBConnection|MockObject */ - private IDBConnection $db; - /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ - private $logger; - /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ - private $timeFactory; - /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */ - private $cacheFactory; - /** @var int */ - private $time; - /** @var IEventDispatcher */ - private $eventDispatcher; + private PublicKeyTokenProvider $tokenProvider; + + private PublicKeyTokenMapper&MockObject $mapper; + private IConfig&MockObject $config; + private IDBConnection&MockObject $db; + private LoggerInterface&MockObject $logger; + private ITimeFactory&MockObject $timeFactory; + private ICacheFactory&MockObject $cacheFactory; + + private int $time; + private IHasher $hasher; + private ICrypto $crypto; + private IEventDispatcher $eventDispatcher; #[\Override] protected function setUp(): void { parent::setUp(); $this->mapper = $this->createMock(PublicKeyTokenMapper::class); - $this->hasher = Server::get(IHasher::class); - $this->crypto = Server::get(ICrypto::class); $this->config = $this->createMock(IConfig::class); $this->config->method('getSystemValue') ->willReturnMap([ @@ -76,6 +65,9 @@ protected function setUp(): void { $this->timeFactory->method('getTime') ->willReturn($this->time); $this->cacheFactory = $this->createMock(ICacheFactory::class); + + $this->hasher = Server::get(IHasher::class); + $this->crypto = Server::get(ICrypto::class); $this->eventDispatcher = Server::get(IEventDispatcher::class); $this->tokenProvider = new PublicKeyTokenProvider( @@ -186,6 +178,7 @@ public function testUpdateToken(): void { ->method('updateActivity') ->with($tk, $this->time); $tk->setLastActivity($this->time - 200); + $tk->setToken('token'); $this->config->method('getSystemValueBool') ->willReturnMap([ ['auth.storeCryptedPassword', true, true], @@ -448,6 +441,7 @@ public function testRenewSessionTokenWithPassword(): void { public function testGetToken(): void { $token = new PublicKeyToken(); + $token->setToken('token'); $this->config->method('getSystemValue') ->with('secret') @@ -595,6 +589,9 @@ public function testMarkPasswordInvalidInvalidToken(): void { public function testMarkPasswordInvalid(): void { $token = $this->createMock(PublicKeyToken::class); + $token->expects($this->once()) + ->method('getToken') + ->willReturn('token'); $token->expects($this->once()) ->method('setPasswordInvalid') diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php index e919d0991322c..9c751d487c130 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php @@ -31,53 +31,30 @@ use function reset; class ManagerTest extends TestCase { - /** @var IUser|MockObject */ - private $user; - - /** @var ProviderLoader|MockObject */ - private $providerLoader; - - /** @var IRegistry|MockObject */ - private $providerRegistry; - - /** @var MandatoryTwoFactor|MockObject */ - private $mandatoryTwoFactor; - - /** @var ISession|MockObject */ - private $session; - - /** @var Manager */ - private $manager; - - /** @var IConfig|MockObject */ - private $config; - - /** @var IManager|MockObject */ - private $activityManager; - - /** @var LoggerInterface|MockObject */ - private $logger; - - /** @var IProvider|MockObject */ - private $fakeProvider; - - /** @var IProvider|MockObject */ - private $backupProvider; - - /** @var TokenProvider|MockObject */ - private $tokenProvider; - - /** @var ITimeFactory|MockObject */ - private $timeFactory; - - /** @var IEventDispatcher|MockObject */ - private $dispatcher; + private IUser&MockObject $user; + private ProviderLoader&MockObject $providerLoader; + private IRegistry&MockObject $providerRegistry; + private MandatoryTwoFactor&MockObject $mandatoryTwoFactor; + private ISession&MockObject $session; + private IConfig&MockObject $config; + private IManager&MockObject $activityManager; + private LoggerInterface&MockObject $logger; + private IProvider&MockObject $fakeProvider; + private IProvider&MockObject $backupProvider; + private TokenProvider&MockObject $tokenProvider; + private ITimeFactory&MockObject $timeFactory; + private IEventDispatcher&MockObject $dispatcher; + + private Manager $manager; #[\Override] protected function setUp(): void { parent::setUp(); $this->user = $this->createMock(IUser::class); + $this->user->expects($this->any()) + ->method('getUID') + ->willReturn('user-uid'); $this->providerLoader = $this->createMock(ProviderLoader::class); $this->providerRegistry = $this->createMock(IRegistry::class); $this->mandatoryTwoFactor = $this->createMock(MandatoryTwoFactor::class); @@ -371,15 +348,12 @@ public function testVerifyChallenge(): void { $this->session->expects($this->once()) ->method('set') - ->with(Manager::SESSION_UID_DONE, 'jos'); + ->with(Manager::SESSION_UID_DONE, $this->user->getUID()); $this->session->method('getId') ->willReturn('mysessionid'); $this->activityManager->expects($this->once()) ->method('generateEvent') ->willReturn($event); - $this->user->expects($this->any()) - ->method('getUID') - ->willReturn('jos'); $event->expects($this->once()) ->method('setApp') ->with($this->equalTo('core')) @@ -390,11 +364,11 @@ public function testVerifyChallenge(): void { ->willReturnSelf(); $event->expects($this->once()) ->method('setAuthor') - ->with($this->equalTo('jos')) + ->with($this->equalTo($this->user->getUID())) ->willReturnSelf(); $event->expects($this->once()) ->method('setAffectedUser') - ->with($this->equalTo('jos')) + ->with($this->equalTo($this->user->getUID())) ->willReturnSelf(); $this->fakeProvider ->method('getDisplayName') @@ -413,7 +387,7 @@ public function testVerifyChallenge(): void { ->willReturn(42); $this->config->expects($this->once()) ->method('deleteUserValue') - ->with('jos', 'login_token_2fa', '42'); + ->with($this->user->getUID(), 'login_token_2fa', '42'); $result = $this->manager->verifyChallenge('email', $this->user, $challenge); @@ -447,9 +421,6 @@ public function testVerifyInvalidChallenge(): void { $this->activityManager->expects($this->once()) ->method('generateEvent') ->willReturn($event); - $this->user->expects($this->any()) - ->method('getUID') - ->willReturn('jos'); $event->expects($this->once()) ->method('setApp') ->with($this->equalTo('core')) @@ -460,11 +431,11 @@ public function testVerifyInvalidChallenge(): void { ->willReturnSelf(); $event->expects($this->once()) ->method('setAuthor') - ->with($this->equalTo('jos')) + ->with($this->equalTo($this->user->getUID())) ->willReturnSelf(); $event->expects($this->once()) ->method('setAffectedUser') - ->with($this->equalTo('jos')) + ->with($this->equalTo($this->user->getUID())) ->willReturnSelf(); $this->fakeProvider ->method('getDisplayName') @@ -559,11 +530,8 @@ public function testNeedsSecondFactorWithNoProviderAvailableAnymore(): void { } public function testPrepareTwoFactorLogin(): void { - $this->user->method('getUID') - ->willReturn('ferdinand'); - $calls = [ - ['two_factor_auth_uid', 'ferdinand'], + ['two_factor_auth_uid', $this->user->getUID()], ['two_factor_remember_login', true], ]; $this->session->expects($this->exactly(2)) @@ -586,17 +554,14 @@ public function testPrepareTwoFactorLogin(): void { ->willReturn(1337); $this->config->method('setUserValue') - ->with('ferdinand', 'login_token_2fa', '42', '1337'); + ->with($this->user->getUID(), 'login_token_2fa', '42', '1337'); $this->manager->prepareTwoFactorLogin($this->user, true); } public function testPrepareTwoFactorLoginDontRemember(): void { - $this->user->method('getUID') - ->willReturn('ferdinand'); - $calls = [ - ['two_factor_auth_uid', 'ferdinand'], + ['two_factor_auth_uid', $this->user->getUID()], ['two_factor_remember_login', false], ]; $this->session->expects($this->exactly(2)) @@ -619,7 +584,7 @@ public function testPrepareTwoFactorLoginDontRemember(): void { ->willReturn(1337); $this->config->method('setUserValue') - ->with('ferdinand', 'login_token_2fa', '42', '1337'); + ->with($this->user->getUID(), 'login_token_2fa', '42', '1337'); $this->manager->prepareTwoFactorLogin($this->user, false); } diff --git a/tests/lib/Avatar/GuestAvatarTest.php b/tests/lib/Avatar/GuestAvatarTest.php index aa4c59d9ba76d..c50b4b2066ba7 100644 --- a/tests/lib/Avatar/GuestAvatarTest.php +++ b/tests/lib/Avatar/GuestAvatarTest.php @@ -45,7 +45,6 @@ public function setupGuestAvatar(): void { * the generated image is compared with an expected one. */ public function testGet(): void { - $this->markTestSkipped('TODO: Disable because fails on drone'); $avatar = $this->guestAvatar->getFile(32); self::assertInstanceOf(InMemoryFile::class, $avatar); $expectedFile = file_get_contents( diff --git a/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php index a36416ca9ead6..e595af8e03555 100644 --- a/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php +++ b/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php @@ -186,10 +186,6 @@ public function testProcessNoUser(): void { ->with('UID') ->willReturn('user1'); - $user = $this->createMock(IUser::class); - $user->method('getUID') - ->willReturn(null); - $entry->expects($this->never()) ->method('addAction'); diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php index 1b54a8c946f13..e39ba0b78c62c 100644 --- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php @@ -531,8 +531,8 @@ public function testFrom(string $table1Name, ?string $table1Alias, ?string $tabl public static function dataJoin(): array { return [ [ - 'd1', 'data2', null, null, - ['`d1`' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], + 'd1', 'data2', '', null, + ['`d1`' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '', 'joinCondition' => null]]], '`*PREFIX*data1` `d1` INNER JOIN `*PREFIX*data2` ' ], [ @@ -611,8 +611,8 @@ public function testInnerJoin($fromAlias, $tableName, $tableAlias, $condition, $ public static function dataLeftJoin(): array { return [ [ - 'd1', 'data2', null, null, - ['`d1`' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], + 'd1', 'data2', '', null, + ['`d1`' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '', 'joinCondition' => null]]], '`*PREFIX*data1` `d1` LEFT JOIN `*PREFIX*data2` ' ], [ @@ -661,8 +661,8 @@ public function testLeftJoin($fromAlias, $tableName, $tableAlias, $condition, $e public static function dataRightJoin(): array { return [ [ - 'd1', 'data2', null, null, - ['`d1`' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], + 'd1', 'data2', '', null, + ['`d1`' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '', 'joinCondition' => null]]], '`*PREFIX*data1` `d1` RIGHT JOIN `*PREFIX*data2` ' ], [ @@ -678,17 +678,15 @@ public static function dataRightJoin(): array { ]; } - /** - * - * @param string $fromAlias - * @param string $tableName - * @param string $tableAlias - * @param string $condition - * @param array $expectedQueryPart - * @param string $expectedQuery - */ #[DataProvider('dataRightJoin')] - public function testRightJoin($fromAlias, $tableName, $tableAlias, $condition, $expectedQueryPart, $expectedQuery): void { + public function testRightJoin( + string $fromAlias, + string $tableName, + string $tableAlias, + ?string $condition, + array $expectedQueryPart, + string $expectedQuery, + ): void { $this->queryBuilder->from('data1', 'd1'); $this->queryBuilder->rightJoin( $fromAlias, diff --git a/tests/lib/Files/Mount/RootMountProviderTest.php b/tests/lib/Files/Mount/RootMountProviderTest.php index 8a61dc81034f5..22491285fb008 100644 --- a/tests/lib/Files/Mount/RootMountProviderTest.php +++ b/tests/lib/Files/Mount/RootMountProviderTest.php @@ -85,7 +85,6 @@ public function testObjectStore(): void { $class = new \ReflectionClass($storage); $prop = $class->getProperty('objectStore'); - $prop->setAccessible(true); /** @var S3 $objectStore */ $objectStore = $prop->getValue($storage); $this->assertEquals('nextcloud', $objectStore->getBucket()); diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index 13f14bbc3248b..b397019df930e 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -149,29 +149,17 @@ public function testStreamOpen( // set internal properties of the stream wrapper $stream = new \ReflectionClass(Encryption::class); $encryptionModule = $stream->getProperty('encryptionModule'); - $encryptionModule->setAccessible(true); $encryptionModule->setValue($streamWrapper, $encryptionModuleMock); - $encryptionModule->setAccessible(false); $storage = $stream->getProperty('storage'); - $storage->setAccessible(true); $storage->setValue($streamWrapper, $storageMock); - $storage->setAccessible(false); $file = $stream->getProperty('file'); - $file->setAccessible(true); $file->setValue($streamWrapper, $fileMock); - $file->setAccessible(false); $util = $stream->getProperty('util'); - $util->setAccessible(true); $util->setValue($streamWrapper, $utilMock); - $util->setAccessible(false); $fullPathP = $stream->getProperty('fullPath'); - $fullPathP->setAccessible(true); $fullPathP->setValue($streamWrapper, $fullPath); - $fullPathP->setAccessible(false); $header = $stream->getProperty('header'); - $header->setAccessible(true); $header->setValue($streamWrapper, []); - $header->setAccessible(false); $this->invokePrivate($streamWrapper, 'signed', [true]); $this->invokePrivate($streamWrapper, 'internalPath', [$fullPath]); $this->invokePrivate($streamWrapper, 'uid', ['test']); @@ -182,19 +170,13 @@ public function testStreamOpen( // check internal properties $size = $stream->getProperty('size'); - $size->setAccessible(true); $this->assertSame($expectedSize, $size->getValue($streamWrapper)); - $size->setAccessible(false); $unencryptedSize = $stream->getProperty('unencryptedSize'); - $unencryptedSize->setAccessible(true); $this->assertSame($expectedUnencryptedSize, $unencryptedSize->getValue($streamWrapper)); - $unencryptedSize->setAccessible(false); $readOnly = $stream->getProperty('readOnly'); - $readOnly->setAccessible(true); $this->assertSame($expectedReadOnly, $readOnly->getValue($streamWrapper)); - $readOnly->setAccessible(false); } public static function dataProviderStreamOpen(): array { diff --git a/tests/lib/TaskProcessing/TaskProcessingTest.php b/tests/lib/TaskProcessing/TaskProcessingTest.php index 3bfc586240c9e..bb47bd735b96c 100644 --- a/tests/lib/TaskProcessing/TaskProcessingTest.php +++ b/tests/lib/TaskProcessing/TaskProcessingTest.php @@ -912,7 +912,7 @@ public function testProviderShouldBeRegisteredAndTaskWithFilesFailValidation(): new ServiceRegistration('test', AsyncProvider::class) ]); $user = $this->createMock(IUser::class); - $user->expects($this->any())->method('getUID')->willReturn(null); + $user->expects($this->any())->method('getUID')->willReturn('uid'); $mount = $this->createMock(ICachedMountInfo::class); $mount->expects($this->any())->method('getUser')->willReturn($user); $this->userMountCache->expects($this->any())->method('getMountsForFileId')->willReturn([$mount]); diff --git a/tests/lib/TempManagerTest.php b/tests/lib/TempManagerTest.php index e63ad7d3cd90e..06a43930e919f 100644 --- a/tests/lib/TempManagerTest.php +++ b/tests/lib/TempManagerTest.php @@ -36,12 +36,7 @@ protected function tearDown(): void { parent::tearDown(); } - /** - * @param ?LoggerInterface $logger - * @param ?IConfig $config - * @return TempManager - */ - protected function getManager($logger = null, $config = null) { + protected function getManager(?LoggerInterface $logger = null, ?IConfig $config = null): TempManager { if (!$logger) { $logger = $this->createMock(LoggerInterface::class); } @@ -49,7 +44,7 @@ protected function getManager($logger = null, $config = null) { $config = $this->createMock(IConfig::class); $config->method('getSystemValue') ->with('tempdirectory', null) - ->willReturn('/tmp'); + ->willReturn('/dev/shm'); } $iniGetWrapper = $this->createMock(IniGetWrapper::class); $manager = new TempManager($logger, $config, $iniGetWrapper); @@ -135,8 +130,6 @@ public function testCleanOld(): void { } public function testLogCantCreateFile(): void { - $this->markTestSkipped('TODO: Disable because fails on drone'); - $logger = $this->createMock(LoggerInterface::class); $manager = $this->getManager($logger); chmod($this->baseDir, 0500); @@ -147,8 +140,6 @@ public function testLogCantCreateFile(): void { } public function testLogCantCreateFolder(): void { - $this->markTestSkipped('TODO: Disable because fails on drone'); - $logger = $this->createMock(LoggerInterface::class); $manager = $this->getManager($logger); chmod($this->baseDir, 0500); diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php index ab5c780ec61fd..3244250f2fd5a 100644 --- a/tests/lib/Template/ResourceLocatorTest.php +++ b/tests/lib/Template/ResourceLocatorTest.php @@ -73,7 +73,6 @@ public function testFindNotFound(): void { public function testAppendIfExist(): void { $locator = $this->getResourceLocator('theme'); $method = new \ReflectionMethod($locator, 'appendIfExist'); - $method->setAccessible(true); $method->invoke($locator, __DIR__, basename(__FILE__), 'webroot'); $resource1 = [__DIR__, 'webroot', basename(__FILE__)]; diff --git a/tests/lib/UtilCheckServerTest.php b/tests/lib/UtilCheckServerTest.php index fade2f6d341f5..712235f559996 100644 --- a/tests/lib/UtilCheckServerTest.php +++ b/tests/lib/UtilCheckServerTest.php @@ -148,11 +148,9 @@ public function testDataDirWritable(): void { } /** - * Tests an error is given when the datadir is not writable + * Tests an error is given when the datadir is not readable */ - public function testDataDirNotWritable(): void { - $this->markTestSkipped('TODO: Disable because fails on drone'); - + public function testDataDirNotReadable(): void { chmod($this->datadir, 0300); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, @@ -165,7 +163,7 @@ public function testDataDirNotWritable(): void { * Tests no error is given when the datadir is not writable during setup */ public function testDataDirNotWritableSetup(): void { - chmod($this->datadir, 0300); + chmod($this->datadir, 0500); $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false, 'version' => implode('.', Util::getVersion()) diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml index 11dd78dc8095b..94f8e0a978770 100644 --- a/tests/phpunit-autotest.xml +++ b/tests/phpunit-autotest.xml @@ -18,6 +18,8 @@ Core/ ../apps/ ../apps/user_ldap/tests/Integration + + ../apps/files_external @@ -27,7 +29,7 @@ ../3rdparty ../apps/*/composer ../apps/*/tests - ../apps/files_external/3rdparty + ../apps/files_external ../build ../lib/composer ../tests diff --git a/tests/preseed-config.php b/tests/preseed-config.php index 1fc98a4226ac0..0853b220a653e 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -16,6 +16,7 @@ 'writable' => true, ], ], + 'tempdirectory' => '/dev/shm', ]; if (is_dir(OC::$SERVERROOT . '/apps2')) {