diff options
Diffstat (limited to 'tests/lib/AppFramework/Middleware')
6 files changed, 42 insertions, 122 deletions
diff --git a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php index 0abbd9c614c..7dcb28a2af4 100644 --- a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php @@ -54,9 +54,7 @@ class NotModifiedMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataModified - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataModified')] public function testMiddleware(?string $etag, string $etagHeader, ?\DateTime $lastModified, string $lastModifiedHeader, bool $notModifiedSet): void { $this->request->method('getHeader') ->willReturnCallback(function (string $name) use ($etagHeader, $lastModifiedHeader) { diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php index 4d190ce6ba6..e5c6a417a4b 100644 --- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php @@ -61,9 +61,7 @@ class OCSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataAfterException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')] public function testAfterExceptionOCSv1(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void { $controller = $this->createMock($controller); $this->request @@ -92,9 +90,7 @@ class OCSMiddlewareTest extends \Test\TestCase { $this->assertSame(Http::STATUS_OK, $result->getStatus()); } - /** - * @dataProvider dataAfterException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')] public function testAfterExceptionOCSv2(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void { $controller = $this->createMock($controller); $this->request @@ -121,9 +117,7 @@ class OCSMiddlewareTest extends \Test\TestCase { $this->assertSame($code, $result->getStatus()); } - /** - * @dataProvider dataAfterException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')] public function testAfterExceptionOCSv2SubFolder(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void { $controller = $this->createMock($controller); $this->request @@ -167,9 +161,7 @@ class OCSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataAfterController - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterController')] public function testAfterController(string $controller, Response $response, bool $converted, int $convertedOCSStatus = 0): void { $controller = $this->createMock($controller); $OCSMiddleware = new OCSMiddleware($this->request); diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php index b17dc9434ef..e87ee7fd565 100644 --- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php @@ -67,9 +67,7 @@ class PublicShareMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataShareApi - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataShareApi')] public function testBeforeControllerShareApiDisabled(string $shareApi, string $shareLinks): void { $controller = $this->createMock(PublicShareController::class); diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php index f9ada6a93e2..c325ae638fb 100644 --- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php @@ -53,9 +53,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataSetCORSAPIHeader - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSetCORSAPIHeader')] public function testSetCORSAPIHeader(string $method): void { $request = new Request( [ @@ -98,9 +96,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataNoOriginHeaderNoCORSHEADER - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoOriginHeaderNoCORSHEADER')] public function testNoOriginHeaderNoCORSHEADER(string $method): void { $request = new Request( [], @@ -122,9 +118,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataCorsIgnoredIfWithCredentialsHeaderPresent - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCorsIgnoredIfWithCredentialsHeaderPresent')] public function testCorsIgnoredIfWithCredentialsHeaderPresent(string $method): void { $this->expectException(SecurityException::class); @@ -154,9 +148,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataNoCORSOnAnonymousPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCORSOnAnonymousPublicPage')] public function testNoCORSOnAnonymousPublicPage(string $method): void { $request = new Request( [], @@ -188,9 +180,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataCORSShouldNeverAllowCookieAuth - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldNeverAllowCookieAuth')] public function testCORSShouldNeverAllowCookieAuth(string $method): void { $request = new Request( [], @@ -220,9 +210,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataCORSShouldRelogin - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldRelogin')] public function testCORSShouldRelogin(string $method): void { $request = new Request( ['server' => [ @@ -251,9 +239,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataCORSShouldFailIfPasswordLoginIsForbidden - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldFailIfPasswordLoginIsForbidden')] public function testCORSShouldFailIfPasswordLoginIsForbidden(string $method): void { $this->expectException(SecurityException::class); @@ -284,9 +270,7 @@ class CORSMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataCORSShouldNotAllowCookieAuth - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCORSShouldNotAllowCookieAuth')] public function testCORSShouldNotAllowCookieAuth(string $method): void { $this->expectException(SecurityException::class); diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php index a109ac839c4..90e801ca471 100644 --- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php @@ -91,9 +91,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase { $this->middleware->beforeController($this->controller, __FUNCTION__); } - /** - * @dataProvider dataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')] public function testAnnotation($backend, $lastConfirm, $currentTime, $exception): void { $this->reflector->reflect($this->controller, __FUNCTION__); @@ -126,9 +124,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase { $this->assertSame($exception, $thrown); } - /** - * @dataProvider dataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')] public function testAttribute($backend, $lastConfirm, $currentTime, $exception): void { $this->reflector->reflect($this->controller, __FUNCTION__); diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 670e1cc7ca5..0c6fc21357d 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -195,9 +195,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataNoCSRFRequiredPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')] public function testSetNavigationEntry(string $method): void { $this->navigationManager->expects($this->once()) ->method('setActiveEntry') @@ -245,9 +243,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ); } - /** - * @dataProvider dataNoCSRFRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequired')] public function testAjaxNotAdminCheck(string $method): void { $this->ajaxExceptionStatus( $method, @@ -256,9 +252,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ); } - /** - * @dataProvider dataPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')] public function testAjaxStatusCSRFCheck(string $method): void { $this->ajaxExceptionStatus( $method, @@ -267,9 +261,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ); } - /** - * @dataProvider dataNoCSRFRequiredPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')] public function testAjaxStatusAllGood(string $method): void { $this->ajaxExceptionStatus( $method, @@ -288,9 +280,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ); } - /** - * @dataProvider dataNoCSRFRequiredPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')] public function testNoChecks(string $method): void { $this->request->expects($this->never()) ->method('passesCSRFCheck') @@ -329,9 +319,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { } - /** - * @dataProvider dataPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')] public function testCsrfCheck(string $method): void { $this->expectException(CrossSiteRequestForgeryException::class); @@ -345,9 +333,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->middleware->beforeController($this->controller, $method); } - /** - * @dataProvider dataNoCSRFRequiredPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')] public function testNoCsrfCheck(string $method): void { $this->request->expects($this->never()) ->method('passesCSRFCheck') @@ -357,9 +343,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->middleware->beforeController($this->controller, $method); } - /** - * @dataProvider dataPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')] public function testPassesCsrfCheck(string $method): void { $this->request->expects($this->once()) ->method('passesCSRFCheck') @@ -372,9 +356,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->middleware->beforeController($this->controller, $method); } - /** - * @dataProvider dataPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPage')] public function testFailCsrfCheck(string $method): void { $this->expectException(CrossSiteRequestForgeryException::class); @@ -389,9 +371,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->middleware->beforeController($this->controller, $method); } - /** - * @dataProvider dataPublicPageStrictCookieRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPublicPageStrictCookieRequired')] public function testStrictCookieRequiredCheck(string $method): void { $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\StrictCookieMissingException::class); @@ -405,9 +385,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->middleware->beforeController($this->controller, $method); } - /** - * @dataProvider dataNoCSRFRequiredPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPage')] public function testNoStrictCookieRequiredCheck(string $method): void { $this->request->expects($this->never()) ->method('passesStrictCookieCheck') @@ -417,9 +395,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->middleware->beforeController($this->controller, $method); } - /** - * @dataProvider dataNoCSRFRequiredPublicPageStrictCookieRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredPublicPageStrictCookieRequired')] public function testPassesStrictCookieRequiredCheck(string $method): void { $this->request ->expects($this->once()) @@ -445,12 +421,12 @@ class SecurityMiddlewareTest extends \Test\TestCase { } /** - * @dataProvider dataCsrfOcsController * @param string $controllerClass * @param bool $hasOcsApiHeader * @param bool $hasBearerAuth * @param bool $exception */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCsrfOcsController')] public function testCsrfOcsController(string $controllerClass, bool $hasOcsApiHeader, bool $hasBearerAuth, bool $exception): void { $this->request ->method('getHeader') @@ -477,30 +453,22 @@ class SecurityMiddlewareTest extends \Test\TestCase { } } - /** - * @dataProvider dataNoAdminRequiredNoCSRFRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequired')] public function testLoggedInCheck(string $method): void { $this->securityCheck($method, 'isLoggedIn'); } - /** - * @dataProvider dataNoAdminRequiredNoCSRFRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequired')] public function testFailLoggedInCheck(string $method): void { $this->securityCheck($method, 'isLoggedIn', true); } - /** - * @dataProvider dataNoCSRFRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequired')] public function testIsAdminCheck(string $method): void { $this->securityCheck($method, 'isAdminUser'); } - /** - * @dataProvider dataNoCSRFRequiredSubAdminRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')] public function testIsNotSubAdminCheck(string $method): void { $this->reader->reflect($this->controller, $method); $sec = $this->getMiddleware(true, false, false); @@ -509,9 +477,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $sec->beforeController($this->controller, $method); } - /** - * @dataProvider dataNoCSRFRequiredSubAdminRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')] public function testIsSubAdminCheck(string $method): void { $this->reader->reflect($this->controller, $method); $sec = $this->getMiddleware(true, false, true); @@ -520,9 +486,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @dataProvider dataNoCSRFRequiredSubAdminRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')] public function testIsSubAdminAndAdminCheck(string $method): void { $this->reader->reflect($this->controller, $method); $sec = $this->getMiddleware(true, true, true); @@ -531,16 +495,12 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @dataProvider dataNoCSRFRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequired')] public function testFailIsAdminCheck(string $method): void { $this->securityCheck($method, 'isAdminUser', true); } - /** - * @dataProvider dataNoAdminRequiredNoCSRFRequiredPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequiredPublicPage')] public function testRestrictedAppLoggedInPublicPage(string $method): void { $middleware = $this->getMiddleware(true, false, false); $this->reader->reflect($this->controller, $method); @@ -557,9 +517,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @dataProvider dataNoAdminRequiredNoCSRFRequiredPublicPage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequiredPublicPage')] public function testRestrictedAppNotLoggedInPublicPage(string $method): void { $middleware = $this->getMiddleware(false, false, false); $this->reader->reflect($this->controller, $method); @@ -576,9 +534,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->addToAssertionCount(1); } - /** - * @dataProvider dataNoAdminRequiredNoCSRFRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequired')] public function testRestrictedAppLoggedIn(string $method): void { $middleware = $this->getMiddleware(true, false, false, false); $this->reader->reflect($this->controller, $method); @@ -675,9 +631,9 @@ class SecurityMiddlewareTest extends \Test\TestCase { } /** - * @dataProvider exceptionProvider * @param SecurityException $exception */ + #[\PHPUnit\Framework\Attributes\DataProvider('exceptionProvider')] public function testAfterExceptionReturnsTemplateResponse(SecurityException $exception): void { $this->request = new Request( [ @@ -711,9 +667,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->assertTrue($response instanceof JSONResponse); } - /** - * @dataProvider dataExAppRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExAppRequired')] public function testExAppRequired(string $method): void { $middleware = $this->getMiddleware(true, false, false); $this->reader->reflect($this->controller, $method); @@ -732,9 +686,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $middleware->beforeController($this->controller, $method); } - /** - * @dataProvider dataExAppRequired - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExAppRequired')] public function testExAppRequiredError(string $method): void { $middleware = $this->getMiddleware(true, false, false, false); $this->reader->reflect($this->controller, $method); |