aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/tests')
-rw-r--r--apps/settings/tests/Activity/SecurityFilterTest.php1
-rw-r--r--apps/settings/tests/Activity/SecurityProviderTest.php5
-rw-r--r--apps/settings/tests/Activity/SecuritySettingTest.php1
-rw-r--r--apps/settings/tests/AppInfo/ApplicationTest.php6
-rw-r--r--apps/settings/tests/Controller/AdminSettingsControllerTest.php1
-rw-r--r--apps/settings/tests/Controller/AppSettingsControllerTest.php1
-rw-r--r--apps/settings/tests/Controller/AuthSettingsControllerTest.php13
-rw-r--r--apps/settings/tests/Controller/MailSettingsControllerTest.php2
-rw-r--r--apps/settings/tests/Controller/UsersControllerTest.php24
-rw-r--r--apps/settings/tests/Mailer/NewUserMailHelperTest.php1
-rw-r--r--apps/settings/tests/Settings/Admin/MailTest.php3
-rw-r--r--apps/settings/tests/Settings/Admin/SecurityTest.php7
-rw-r--r--apps/settings/tests/Settings/Admin/SharingTest.php16
-rw-r--r--apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php2
-rw-r--r--apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php4
-rw-r--r--apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php4
-rw-r--r--apps/settings/tests/SetupChecks/LoggingLevelTest.php2
-rw-r--r--apps/settings/tests/SetupChecks/SecurityHeadersTest.php15
-rw-r--r--apps/settings/tests/SetupChecks/TaskProcessingPickupSpeedTest.php73
-rw-r--r--apps/settings/tests/SetupChecks/WellKnownUrlsTest.php2
-rw-r--r--apps/settings/tests/UserMigration/AccountMigratorTest.php4
21 files changed, 123 insertions, 64 deletions
diff --git a/apps/settings/tests/Activity/SecurityFilterTest.php b/apps/settings/tests/Activity/SecurityFilterTest.php
index 22ef03816d3..b07c1e825b4 100644
--- a/apps/settings/tests/Activity/SecurityFilterTest.php
+++ b/apps/settings/tests/Activity/SecurityFilterTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/settings/tests/Activity/SecurityProviderTest.php b/apps/settings/tests/Activity/SecurityProviderTest.php
index 1687f116871..ed9de362a87 100644
--- a/apps/settings/tests/Activity/SecurityProviderTest.php
+++ b/apps/settings/tests/Activity/SecurityProviderTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -49,9 +50,7 @@ class SecurityProviderTest extends TestCase {
];
}
- /**
- * @dataProvider subjectData
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('subjectData')]
public function testParse(string $subject): void {
$lang = 'ru';
$event = $this->createMock(IEvent::class);
diff --git a/apps/settings/tests/Activity/SecuritySettingTest.php b/apps/settings/tests/Activity/SecuritySettingTest.php
index c109a9f7fdf..ca11e38caa8 100644
--- a/apps/settings/tests/Activity/SecuritySettingTest.php
+++ b/apps/settings/tests/Activity/SecuritySettingTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/settings/tests/AppInfo/ApplicationTest.php b/apps/settings/tests/AppInfo/ApplicationTest.php
index 85be8c56178..3e895d87b06 100644
--- a/apps/settings/tests/AppInfo/ApplicationTest.php
+++ b/apps/settings/tests/AppInfo/ApplicationTest.php
@@ -39,7 +39,7 @@ class ApplicationTest extends TestCase {
public function testContainerAppName(): void {
$this->app = new Application();
- $this->assertEquals('settings', $this->container->getAppName());
+ $this->assertEquals('settings', $this->container->get('appName'));
}
public static function dataContainerQuery(): array {
@@ -56,9 +56,7 @@ class ApplicationTest extends TestCase {
];
}
- /**
- * @dataProvider dataContainerQuery
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataContainerQuery')]
public function testContainerQuery(string $service, string $expected): void {
$this->assertTrue($this->container->query($service) instanceof $expected);
}
diff --git a/apps/settings/tests/Controller/AdminSettingsControllerTest.php b/apps/settings/tests/Controller/AdminSettingsControllerTest.php
index 445e3971cf8..fbdc506457b 100644
--- a/apps/settings/tests/Controller/AdminSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AdminSettingsControllerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/settings/tests/Controller/AppSettingsControllerTest.php b/apps/settings/tests/Controller/AppSettingsControllerTest.php
index 5194ca2cc33..392bb7b561d 100644
--- a/apps/settings/tests/Controller/AppSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AppSettingsControllerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2015 ownCloud, Inc.
diff --git a/apps/settings/tests/Controller/AuthSettingsControllerTest.php b/apps/settings/tests/Controller/AuthSettingsControllerTest.php
index bb6068ffe94..d195dbf83d3 100644
--- a/apps/settings/tests/Controller/AuthSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AuthSettingsControllerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -119,7 +120,7 @@ class AuthSettingsControllerTest extends TestCase {
$this->session->expects($this->once())
->method('getId')
- ->will($this->throwException(new SessionNotAvailableException()));
+ ->willThrowException(new SessionNotAvailableException());
$expected = new JSONResponse();
$expected->setStatus(Http::STATUS_SERVICE_UNAVAILABLE);
@@ -136,7 +137,7 @@ class AuthSettingsControllerTest extends TestCase {
$this->tokenProvider->expects($this->once())
->method('getToken')
->with('sessionid')
- ->will($this->throwException(new InvalidTokenException()));
+ ->willThrowException(new InvalidTokenException());
$expected = new JSONResponse();
$expected->setStatus(Http::STATUS_SERVICE_UNAVAILABLE);
@@ -212,9 +213,7 @@ class AuthSettingsControllerTest extends TestCase {
];
}
- /**
- * @dataProvider dataRenameToken
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataRenameToken')]
public function testUpdateRename(string $name, string $newName): void {
$tokenId = 42;
$token = $this->createMock(PublicKeyToken::class);
@@ -252,9 +251,7 @@ class AuthSettingsControllerTest extends TestCase {
];
}
- /**
- * @dataProvider dataUpdateFilesystemScope
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateFilesystemScope')]
public function testUpdateFilesystemScope(bool $filesystem, bool $newFilesystem): void {
$tokenId = 42;
$token = $this->createMock(PublicKeyToken::class);
diff --git a/apps/settings/tests/Controller/MailSettingsControllerTest.php b/apps/settings/tests/Controller/MailSettingsControllerTest.php
index dcb1e3efef4..1bc05ca4718 100644
--- a/apps/settings/tests/Controller/MailSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/MailSettingsControllerTest.php
@@ -79,7 +79,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
];
$this->config->expects($this->exactly(2))
->method('setSystemValues')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php
index d5fe38ad458..0468ce6814c 100644
--- a/apps/settings/tests/Controller/UsersControllerTest.php
+++ b/apps/settings/tests/Controller/UsersControllerTest.php
@@ -235,9 +235,7 @@ class UsersControllerTest extends \Test\TestCase {
return $account;
}
- /**
- * @dataProvider dataTestSetUserSettings
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetUserSettings')]
public function testSetUserSettings(string $email, bool $validEmail, int $expectedStatus): void {
$controller = $this->getController(false, ['saveUserSettings']);
$user = $this->createMock(IUser::class);
@@ -497,9 +495,7 @@ class UsersControllerTest extends \Test\TestCase {
);
}
- /**
- * @dataProvider dataTestSetUserSettingsSubset
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetUserSettingsSubset')]
public function testSetUserSettingsSubset(string $property, string $propertyValue): void {
$controller = $this->getController(false, ['saveUserSettings']);
$user = $this->createMock(IUser::class);
@@ -641,9 +637,7 @@ class UsersControllerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataTestSaveUserSettings
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSaveUserSettings')]
public function testSaveUserSettings(array $data, ?string $oldEmailAddress, ?string $oldDisplayName): void {
$controller = $this->getController();
$user = $this->createMock(IUser::class);
@@ -758,9 +752,7 @@ class UsersControllerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataTestSaveUserSettingsException
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSaveUserSettingsException')]
public function testSaveUserSettingsException(
array $data,
string $oldEmailAddress,
@@ -843,9 +835,7 @@ class UsersControllerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider dataTestGetVerificationCode
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetVerificationCode')]
public function testGetVerificationCode(string $account, string $type, array $dataBefore, array $expectedData, bool $onlyVerificationCode): void {
$message = 'Use my Federated Cloud ID to share with me: user@nextcloud.com';
$signature = 'theSignature';
@@ -940,9 +930,7 @@ class UsersControllerTest extends \Test\TestCase {
$this->assertSame(Http::STATUS_BAD_REQUEST, $result->getStatus());
}
- /**
- * @dataProvider dataTestCanAdminChangeUserPasswords
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCanAdminChangeUserPasswords')]
public function testCanAdminChangeUserPasswords(
bool $encryptionEnabled,
bool $encryptionModuleLoaded,
diff --git a/apps/settings/tests/Mailer/NewUserMailHelperTest.php b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
index 26a2bf5a6b6..55520184fc9 100644
--- a/apps/settings/tests/Mailer/NewUserMailHelperTest.php
+++ b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php
index 37d7cb7d56d..992c7d43dba 100644
--- a/apps/settings/tests/Settings/Admin/MailTest.php
+++ b/apps/settings/tests/Settings/Admin/MailTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -37,7 +38,7 @@ class MailTest extends TestCase {
];
}
- /** @dataProvider dataGetForm */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetForm')]
public function testGetForm(bool $sendmail) {
$finder = $this->createMock(IBinaryFinder::class);
$finder->expects(self::once())
diff --git a/apps/settings/tests/Settings/Admin/SecurityTest.php b/apps/settings/tests/Settings/Admin/SecurityTest.php
index 63b52dd8616..89a6d8c0d88 100644
--- a/apps/settings/tests/Settings/Admin/SecurityTest.php
+++ b/apps/settings/tests/Settings/Admin/SecurityTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -45,9 +46,7 @@ class SecurityTest extends TestCase {
];
}
- /**
- * @dataProvider encryptionSettingsProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('encryptionSettingsProvider')]
public function testGetFormWithOnlyOneBackend(bool $enabled): void {
$this->manager
->expects($this->once())
@@ -75,9 +74,9 @@ class SecurityTest extends TestCase {
}
/**
- * @dataProvider encryptionSettingsProvider
* @param bool $enabled
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('encryptionSettingsProvider')]
public function testGetFormWithMultipleBackends($enabled): void {
$this->manager
->expects($this->once())
diff --git a/apps/settings/tests/Settings/Admin/SharingTest.php b/apps/settings/tests/Settings/Admin/SharingTest.php
index bd1a7a1045b..12ab5c3cada 100644
--- a/apps/settings/tests/Settings/Admin/SharingTest.php
+++ b/apps/settings/tests/Settings/Admin/SharingTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -10,6 +11,7 @@ use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\Constants;
+use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -18,18 +20,22 @@ use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class SharingTest extends TestCase {
+ private Sharing $admin;
+
private IConfig&MockObject $config;
+ private IAppConfig&MockObject $appConfig;
private IL10N&MockObject $l10n;
private IManager&MockObject $shareManager;
private IAppManager&MockObject $appManager;
private IURLGenerator&MockObject $urlGenerator;
private IInitialState&MockObject $initialState;
- private Sharing $admin;
protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
$this->l10n = $this->createMock(IL10N::class);
+
$this->shareManager = $this->createMock(IManager::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
@@ -37,6 +43,7 @@ class SharingTest extends TestCase {
$this->admin = new Sharing(
$this->config,
+ $this->appConfig,
$this->l10n,
$this->shareManager,
$this->appManager,
@@ -47,6 +54,12 @@ class SharingTest extends TestCase {
}
public function testGetFormWithoutExcludedGroups(): void {
+ $this->appConfig
+ ->method('getValueBool')
+ ->willReturnMap([
+ ['core', 'shareapi_allow_federation_on_public_shares', false, false, true],
+ ]);
+
$this->config
->method('getAppValue')
->willReturnMap([
@@ -102,6 +115,7 @@ class SharingTest extends TestCase {
'allowPublicUpload' => true,
'allowResharing' => true,
'allowShareDialogUserEnumeration' => true,
+ 'allowFederationOnPublicShares' => true,
'restrictUserEnumerationToGroup' => false,
'restrictUserEnumerationToPhone' => false,
'restrictUserEnumerationFullMatch' => true,
diff --git a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
index f6f82ab311a..0a0ff4d84af 100644
--- a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
+++ b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
@@ -97,7 +97,7 @@ class AuthtokensTest extends TestCase {
];
$this->initialState->expects($this->exactly(2))
->method('provideInitialState')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
diff --git a/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php b/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php
index a48c6296aff..c20c78c6e16 100644
--- a/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php
+++ b/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php
@@ -54,9 +54,7 @@ class DataDirectoryProtectedTest extends TestCase {
->getMock();
}
- /**
- * @dataProvider dataTestStatusCode
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestStatusCode')]
public function testStatusCode(array $status, string $expected, bool $hasBody): void {
$responses = array_map(function ($state) use ($hasBody) {
$response = $this->createMock(IResponse::class);
diff --git a/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php b/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php
index b57eb852d80..9b4878b45cc 100644
--- a/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php
+++ b/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php
@@ -43,9 +43,7 @@ class ForwardedForHeadersTest extends TestCase {
);
}
- /**
- * @dataProvider dataForwardedForHeadersWorking
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataForwardedForHeadersWorking')]
public function testForwardedForHeadersWorking(array $trustedProxies, string $remoteAddrNotForwarded, string $remoteAddr, string $result): void {
$this->config->expects($this->once())
->method('getSystemValue')
diff --git a/apps/settings/tests/SetupChecks/LoggingLevelTest.php b/apps/settings/tests/SetupChecks/LoggingLevelTest.php
index 9d588a4e486..67224e11e3a 100644
--- a/apps/settings/tests/SetupChecks/LoggingLevelTest.php
+++ b/apps/settings/tests/SetupChecks/LoggingLevelTest.php
@@ -59,7 +59,7 @@ class LoggingLevelTest extends TestCase {
];
}
- /** @dataProvider dataRun */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataRun')]
public function testRun(string|int $value, string $expected): void {
$this->urlGenerator->method('linkToDocs')->willReturn('admin-logging');
diff --git a/apps/settings/tests/SetupChecks/SecurityHeadersTest.php b/apps/settings/tests/SetupChecks/SecurityHeadersTest.php
index e7d87775485..1f75907d427 100644
--- a/apps/settings/tests/SetupChecks/SecurityHeadersTest.php
+++ b/apps/settings/tests/SetupChecks/SecurityHeadersTest.php
@@ -84,7 +84,7 @@ class SecurityHeadersTest extends TestCase {
$result = $this->setupcheck->run();
$this->assertEquals(
- "Some headers are not set correctly on your instance\n- The `X-Content-Type-Options` HTTP header is not set to `nosniff`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n- The `X-XSS-Protection` HTTP header does not contain `1; mode=block`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n",
+ "Some headers are not set correctly on your instance\n- The `X-Content-Type-Options` HTTP header is not set to `nosniff`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n",
$result->getDescription()
);
$this->assertEquals(SetupResult::WARNING, $result->getSeverity());
@@ -94,7 +94,6 @@ class SecurityHeadersTest extends TestCase {
return [
// description => modifiedHeaders
'basic' => [[]],
- 'extra-xss-protection' => [['X-XSS-Protection' => '1; mode=block; report=https://example.com']],
'no-space-in-x-robots' => [['X-Robots-Tag' => 'noindex,nofollow']],
'strict-origin-when-cross-origin' => [['Referrer-Policy' => 'strict-origin-when-cross-origin']],
'referrer-no-referrer-when-downgrade' => [['Referrer-Policy' => 'no-referrer-when-downgrade']],
@@ -107,13 +106,10 @@ class SecurityHeadersTest extends TestCase {
];
}
- /**
- * @dataProvider dataSuccess
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSuccess')]
public function testSuccess(array $headers): void {
$headers = array_merge(
[
- 'X-XSS-Protection' => '1; mode=block',
'X-Content-Type-Options' => 'nosniff',
'X-Robots-Tag' => 'noindex, nofollow',
'X-Frame-Options' => 'SAMEORIGIN',
@@ -140,8 +136,6 @@ class SecurityHeadersTest extends TestCase {
return [
// description => modifiedHeaders
'x-robots-none' => [['X-Robots-Tag' => 'none'], "- The `X-Robots-Tag` HTTP header is not set to `noindex,nofollow`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n"],
- 'xss-protection-1' => [['X-XSS-Protection' => '1'], "- The `X-XSS-Protection` HTTP header does not contain `1; mode=block`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n"],
- 'xss-protection-0' => [['X-XSS-Protection' => '0'], "- The `X-XSS-Protection` HTTP header does not contain `1; mode=block`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n"],
'referrer-origin' => [['Referrer-Policy' => 'origin'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
'referrer-origin-when-cross-origin' => [['Referrer-Policy' => 'origin-when-cross-origin'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
'referrer-unsafe-url' => [['Referrer-Policy' => 'unsafe-url'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
@@ -151,13 +145,10 @@ class SecurityHeadersTest extends TestCase {
];
}
- /**
- * @dataProvider dataFailure
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataFailure')]
public function testFailure(array $headers, string $msg): void {
$headers = array_merge(
[
- 'X-XSS-Protection' => '1; mode=block',
'X-Content-Type-Options' => 'nosniff',
'X-Robots-Tag' => 'noindex, nofollow',
'X-Frame-Options' => 'SAMEORIGIN',
diff --git a/apps/settings/tests/SetupChecks/TaskProcessingPickupSpeedTest.php b/apps/settings/tests/SetupChecks/TaskProcessingPickupSpeedTest.php
new file mode 100644
index 00000000000..6375d9f6e7f
--- /dev/null
+++ b/apps/settings/tests/SetupChecks/TaskProcessingPickupSpeedTest.php
@@ -0,0 +1,73 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCA\Settings\Tests;
+
+use OCA\Settings\SetupChecks\TaskProcessingPickupSpeed;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IL10N;
+use OCP\SetupCheck\SetupResult;
+use OCP\TaskProcessing\IManager;
+use OCP\TaskProcessing\Task;
+use Test\TestCase;
+
+class TaskProcessingPickupSpeedTest extends TestCase {
+ private IL10N $l10n;
+ private ITimeFactory $timeFactory;
+ private IManager $taskProcessingManager;
+
+ private TaskProcessingPickupSpeed $check;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
+ $this->timeFactory = $this->getMockBuilder(ITimeFactory::class)->getMock();
+ $this->taskProcessingManager = $this->getMockBuilder(IManager::class)->getMock();
+
+ $this->check = new TaskProcessingPickupSpeed(
+ $this->l10n,
+ $this->taskProcessingManager,
+ $this->timeFactory,
+ );
+ }
+
+ public function testPass(): void {
+ $tasks = [];
+ for ($i = 0; $i < 100; $i++) {
+ $task = new Task('test', ['test' => 'test'], 'settings', 'user' . $i);
+ $task->setStartedAt(0);
+ if ($i < 15) {
+ $task->setScheduledAt(60 * 5); // 15% get 5mins
+ } else {
+ $task->setScheduledAt(60); // the rest gets 1min
+ }
+ $tasks[] = $task;
+ }
+ $this->taskProcessingManager->method('getTasks')->willReturn($tasks);
+
+ $this->assertEquals(SetupResult::SUCCESS, $this->check->run()->getSeverity());
+ }
+
+ public function testFail(): void {
+ $tasks = [];
+ for ($i = 0; $i < 100; $i++) {
+ $task = new Task('test', ['test' => 'test'], 'settings', 'user' . $i);
+ $task->setStartedAt(0);
+ if ($i < 30) {
+ $task->setScheduledAt(60 * 5); // 30% get 5mins
+ } else {
+ $task->setScheduledAt(60); // the rest gets 1min
+ }
+ $tasks[] = $task;
+ }
+ $this->taskProcessingManager->method('getTasks')->willReturn($tasks);
+
+ $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());
+ }
+}
diff --git a/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php b/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php
index 14473a540ba..d55835d66fc 100644
--- a/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php
+++ b/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php
@@ -96,8 +96,8 @@ class WellKnownUrlsTest extends TestCase {
/**
* Test responses
- * @dataProvider dataTestResponses
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestResponses')]
public function testResponses($responses, string $expectedSeverity): void {
$this->config
->expects($this->once())
diff --git a/apps/settings/tests/UserMigration/AccountMigratorTest.php b/apps/settings/tests/UserMigration/AccountMigratorTest.php
index ded905d226c..b8f8301f777 100644
--- a/apps/settings/tests/UserMigration/AccountMigratorTest.php
+++ b/apps/settings/tests/UserMigration/AccountMigratorTest.php
@@ -85,9 +85,7 @@ class AccountMigratorTest extends TestCase {
);
}
- /**
- * @dataProvider dataImportExportAccount
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataImportExportAccount')]
public function testImportExportAccount(string $userId, array $importData, string $avatarPath, array $importConfig): void {
$user = $this->userManager->createUser($userId, 'topsecretpassword');
$avatarExt = pathinfo($avatarPath, PATHINFO_EXTENSION);