diff options
Diffstat (limited to 'tests/lib/Security')
26 files changed, 113 insertions, 113 deletions
diff --git a/tests/lib/Security/Bruteforce/ThrottlerTest.php b/tests/lib/Security/Bruteforce/ThrottlerTest.php index 69d20cccd3a..a94f1849c8a 100644 --- a/tests/lib/Security/Bruteforce/ThrottlerTest.php +++ b/tests/lib/Security/Bruteforce/ThrottlerTest.php @@ -183,7 +183,7 @@ class ThrottlerTest extends TestCase { */ public function testIsIpWhiteListedWithEnabledProtection($ip, $whitelists, - $isWhiteListed) { + $isWhiteListed): void { $this->isIpWhiteListedHelper( $ip, $whitelists, @@ -201,7 +201,7 @@ class ThrottlerTest extends TestCase { */ public function testIsIpWhiteListedWithDisabledProtection($ip, $whitelists, - $isWhiteListed) { + $isWhiteListed): void { $this->isIpWhiteListedHelper( $ip, $whitelists, diff --git a/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php b/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php index edc0c613655..39dd7a95890 100644 --- a/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php +++ b/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php @@ -15,7 +15,7 @@ use OCP\Security\CSP\AddContentSecurityPolicyEvent; use Test\TestCase; class AddContentSecurityPolicyEventTest extends TestCase { - public function testAddEvent() { + public function testAddEvent(): void { $cspManager = $this->createMock(ContentSecurityPolicyManager::class); $policy = $this->createMock(ContentSecurityPolicy::class); $event = new AddContentSecurityPolicyEvent($cspManager); diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php index dc0fe7c8340..63a5565e7fa 100644 --- a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php +++ b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php @@ -28,12 +28,12 @@ class ContentSecurityPolicyManagerTest extends TestCase { $this->contentSecurityPolicyManager = new ContentSecurityPolicyManager($this->dispatcher); } - public function testAddDefaultPolicy() { + public function testAddDefaultPolicy(): void { $this->contentSecurityPolicyManager->addDefaultPolicy(new \OCP\AppFramework\Http\ContentSecurityPolicy()); $this->addToAssertionCount(1); } - public function testGetDefaultPolicyWithPolicies() { + public function testGetDefaultPolicyWithPolicies(): void { $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $policy->addAllowedFontDomain('mydomain.com'); $policy->addAllowedImageDomain('anotherdomain.de'); @@ -64,7 +64,7 @@ class ContentSecurityPolicyManagerTest extends TestCase { $this->assertSame($expectedStringPolicy, $this->contentSecurityPolicyManager->getDefaultPolicy()->buildPolicy()); } - public function testGetDefaultPolicyWithPoliciesViaEvent() { + public function testGetDefaultPolicyWithPoliciesViaEvent(): void { $this->dispatcher->addListener(AddContentSecurityPolicyEvent::class, function (AddContentSecurityPolicyEvent $e) { $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $policy->addAllowedFontDomain('mydomain.com'); diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php index 54c8fe832cc..3765311155a 100644 --- a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php +++ b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php @@ -33,7 +33,7 @@ class ContentSecurityPolicyNonceManagerTest extends TestCase { ); } - public function testGetNonce() { + public function testGetNonce(): void { $secret = base64_encode('secret'); $tokenValue = base64_encode('secret' ^ 'value_') . ':' . $secret; $token = $this->createMock(CsrfToken::class); @@ -52,7 +52,7 @@ class ContentSecurityPolicyNonceManagerTest extends TestCase { $this->assertSame($secret, $this->nonceManager->getNonce()); } - public function testGetNonceServerVar() { + public function testGetNonceServerVar(): void { $token = 'SERVERNONCE'; $this->request ->method('__isset') diff --git a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php index 8b92848341c..98eddf602ee 100644 --- a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php +++ b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php @@ -23,7 +23,7 @@ class CsrfTokenGeneratorTest extends \Test\TestCase { $this->csrfTokenGenerator = new \OC\Security\CSRF\CsrfTokenGenerator($this->random); } - public function testGenerateTokenWithCustomNumber() { + public function testGenerateTokenWithCustomNumber(): void { $this->random ->expects($this->once()) ->method('generate') @@ -32,7 +32,7 @@ class CsrfTokenGeneratorTest extends \Test\TestCase { $this->assertSame('abc', $this->csrfTokenGenerator->generateToken(3)); } - public function testGenerateTokenWithDefault() { + public function testGenerateTokenWithDefault(): void { $this->random ->expects($this->once()) ->method('generate') diff --git a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php index 8c19bc6e82d..47f873bfe13 100644 --- a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php +++ b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php @@ -31,7 +31,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { ); } - public function testGetTokenWithExistingToken() { + public function testGetTokenWithExistingToken(): void { $this->storageInterface ->expects($this->once()) ->method('hasToken') @@ -45,7 +45,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { $this->assertEquals($expected, $this->csrfTokenManager->getToken()); } - public function testGetTokenWithExistingTokenKeepsOnSecondRequest() { + public function testGetTokenWithExistingTokenKeepsOnSecondRequest(): void { $this->storageInterface ->expects($this->once()) ->method('hasToken') @@ -61,7 +61,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { $this->assertSame($token, $this->csrfTokenManager->getToken()); } - public function testGetTokenWithoutExistingToken() { + public function testGetTokenWithoutExistingToken(): void { $this->storageInterface ->expects($this->once()) ->method('hasToken') @@ -79,7 +79,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { $this->assertEquals($expected, $this->csrfTokenManager->getToken()); } - public function testRefreshToken() { + public function testRefreshToken(): void { $this->tokenGenerator ->expects($this->once()) ->method('generateToken') @@ -93,7 +93,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { $this->assertEquals($expected, $this->csrfTokenManager->refreshToken()); } - public function testRemoveToken() { + public function testRemoveToken(): void { $this->storageInterface ->expects($this->once()) ->method('removeToken'); @@ -101,7 +101,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { $this->csrfTokenManager->removeToken(); } - public function testIsTokenValidWithoutToken() { + public function testIsTokenValidWithoutToken(): void { $this->storageInterface ->expects($this->once()) ->method('hasToken') @@ -111,7 +111,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { $this->assertSame(false, $this->csrfTokenManager->isTokenValid($token)); } - public function testIsTokenValidWithWrongToken() { + public function testIsTokenValidWithWrongToken(): void { $this->storageInterface ->expects($this->once()) ->method('hasToken') @@ -125,7 +125,7 @@ class CsrfTokenManagerTest extends \Test\TestCase { $this->assertSame(false, $this->csrfTokenManager->isTokenValid($token)); } - public function testIsTokenValidWithValidToken() { + public function testIsTokenValidWithValidToken(): void { $a = 'abc'; $b = 'def'; $xorB64 = 'BQcF'; diff --git a/tests/lib/Security/CSRF/CsrfTokenTest.php b/tests/lib/Security/CSRF/CsrfTokenTest.php index c6f9aaa5be7..9ecbbe9f23a 100644 --- a/tests/lib/Security/CSRF/CsrfTokenTest.php +++ b/tests/lib/Security/CSRF/CsrfTokenTest.php @@ -11,20 +11,20 @@ declare(strict_types=1); namespace Test\Security\CSRF; class CsrfTokenTest extends \Test\TestCase { - public function testGetEncryptedValue() { + public function testGetEncryptedValue(): void { $csrfToken = new \OC\Security\CSRF\CsrfToken('MyCsrfToken'); $this->assertSame(33, strlen($csrfToken->getEncryptedValue())); $this->assertSame(':', $csrfToken->getEncryptedValue()[16]); } - public function testGetEncryptedValueStaysSameOnSecondRequest() { + public function testGetEncryptedValueStaysSameOnSecondRequest(): void { $csrfToken = new \OC\Security\CSRF\CsrfToken('MyCsrfToken'); $tokenValue = $csrfToken->getEncryptedValue(); $this->assertSame($tokenValue, $csrfToken->getEncryptedValue()); $this->assertSame($tokenValue, $csrfToken->getEncryptedValue()); } - public function testGetDecryptedValue() { + public function testGetDecryptedValue(): void { $a = 'abc'; $b = 'def'; $xorB64 = 'BQcF'; diff --git a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php index 8e5c8b8e481..f8386124626 100644 --- a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php +++ b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php @@ -44,7 +44,7 @@ class SessionStorageTest extends \Test\TestCase { * @dataProvider getTokenDataProvider * */ - public function testGetTokenWithEmptyToken($token) { + public function testGetTokenWithEmptyToken($token): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Session does not contain a requesttoken'); @@ -56,7 +56,7 @@ class SessionStorageTest extends \Test\TestCase { $this->sessionStorage->getToken(); } - public function testGetTokenWithValidToken() { + public function testGetTokenWithValidToken(): void { $this->session ->expects($this->once()) ->method('get') @@ -65,7 +65,7 @@ class SessionStorageTest extends \Test\TestCase { $this->assertSame('MyFancyCsrfToken', $this->sessionStorage->getToken()); } - public function testSetToken() { + public function testSetToken(): void { $this->session ->expects($this->once()) ->method('set') @@ -73,7 +73,7 @@ class SessionStorageTest extends \Test\TestCase { $this->sessionStorage->setToken('TokenToSet'); } - public function testRemoveToken() { + public function testRemoveToken(): void { $this->session ->expects($this->once()) ->method('remove') @@ -81,7 +81,7 @@ class SessionStorageTest extends \Test\TestCase { $this->sessionStorage->removeToken(); } - public function testHasTokenWithExistingToken() { + public function testHasTokenWithExistingToken(): void { $this->session ->expects($this->once()) ->method('exists') @@ -90,7 +90,7 @@ class SessionStorageTest extends \Test\TestCase { $this->assertSame(true, $this->sessionStorage->hasToken()); } - public function testHasTokenWithoutExistingToken() { + public function testHasTokenWithoutExistingToken(): void { $this->session ->expects($this->once()) ->method('exists') @@ -99,7 +99,7 @@ class SessionStorageTest extends \Test\TestCase { $this->assertSame(false, $this->sessionStorage->hasToken()); } - public function testSetSession() { + public function testSetSession(): void { $session = $this->createMock(ISession::class); $session ->expects($this->once()) diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php index e123ebeda25..14036b3dd3b 100644 --- a/tests/lib/Security/CertificateManagerTest.php +++ b/tests/lib/Security/CertificateManagerTest.php @@ -76,7 +76,7 @@ class CertificateManagerTest extends \Test\TestCase { $this->assertEquals($expected, $actual); } - public function testListCertificates() { + public function testListCertificates(): void { // Test empty certificate bundle $this->assertSame([], $this->certificateManager->listCertificates()); @@ -93,7 +93,7 @@ class CertificateManagerTest extends \Test\TestCase { } - public function testAddInvalidCertificate() { + public function testAddInvalidCertificate(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Certificate could not get parsed.'); @@ -115,21 +115,21 @@ class CertificateManagerTest extends \Test\TestCase { * @dataProvider dangerousFileProvider * @param string $filename */ - public function testAddDangerousFile($filename) { + public function testAddDangerousFile($filename): void { $this->expectException(InvalidPathException::class); $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/expiredCertificate.crt'), $filename); } - public function testRemoveDangerousFile() { + public function testRemoveDangerousFile(): void { $this->assertFalse($this->certificateManager->removeCertificate('../../foo.txt')); } - public function testRemoveExistingFile() { + public function testRemoveExistingFile(): void { $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); $this->assertTrue($this->certificateManager->removeCertificate('GoodCertificate')); } - public function testGetCertificateBundle() { + public function testGetCertificateBundle(): void { $this->assertSame('/files_external/rootcerts.crt', $this->certificateManager->getCertificateBundle()); } @@ -145,7 +145,7 @@ class CertificateManagerTest extends \Test\TestCase { $targetBundleMtime, $targetBundleExists, $expected - ) { + ): void { $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $config = $this->createMock(IConfig::class); diff --git a/tests/lib/Security/CertificateTest.php b/tests/lib/Security/CertificateTest.php index 6f4e736263b..8b084ca41b3 100644 --- a/tests/lib/Security/CertificateTest.php +++ b/tests/lib/Security/CertificateTest.php @@ -32,7 +32,7 @@ class CertificateTest extends \Test\TestCase { } - public function testBogusData() { + public function testBogusData(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Certificate could not get parsed.'); @@ -41,36 +41,36 @@ class CertificateTest extends \Test\TestCase { } - public function testCertificateStartingWithFileReference() { + public function testCertificateStartingWithFileReference(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Certificate could not get parsed.'); new Certificate('file://'.__DIR__ . '/../../data/certificates/goodCertificate.crt', 'bar'); } - public function testGetName() { + public function testGetName(): void { $this->assertSame('GoodCertificate', $this->goodCertificate->getName()); $this->assertSame('BadCertificate', $this->invalidCertificate->getName()); } - public function testGetCommonName() { + public function testGetCommonName(): void { $this->assertSame('security.owncloud.com', $this->goodCertificate->getCommonName()); $this->assertSame(null, $this->invalidCertificate->getCommonName()); } - public function testGetOrganization() { + public function testGetOrganization(): void { $this->assertSame('ownCloud Security', $this->goodCertificate->getOrganization()); $this->assertSame('Internet Widgits Pty Ltd', $this->invalidCertificate->getOrganization()); } - public function testGetIssueDate() { + public function testGetIssueDate(): void { $expected = new \DateTime('2015-08-27 20:03:42 GMT'); $this->assertEquals($expected->getTimestamp(), $this->goodCertificate->getIssueDate()->getTimestamp()); $expected = new \DateTime('2015-08-27 20:19:13 GMT'); $this->assertEquals($expected->getTimestamp(), $this->invalidCertificate->getIssueDate()->getTimestamp()); } - public function testGetExpireDate() { + public function testGetExpireDate(): void { $expected = new \DateTime('2025-08-24 20:03:42 GMT'); $this->assertEquals($expected->getTimestamp(), $this->goodCertificate->getExpireDate()->getTimestamp()); $expected = new \DateTime('2025-08-24 20:19:13 GMT'); @@ -79,19 +79,19 @@ class CertificateTest extends \Test\TestCase { $this->assertEquals($expected->getTimestamp(), $this->expiredCertificate->getExpireDate()->getTimestamp()); } - public function testIsExpired() { + public function testIsExpired(): void { $this->assertSame(false, $this->goodCertificate->isExpired()); $this->assertSame(false, $this->invalidCertificate->isExpired()); $this->assertSame(true, $this->expiredCertificate->isExpired()); } - public function testGetIssuerName() { + public function testGetIssuerName(): void { $this->assertSame('security.owncloud.com', $this->goodCertificate->getIssuerName()); $this->assertSame(null, $this->invalidCertificate->getIssuerName()); $this->assertSame(null, $this->expiredCertificate->getIssuerName()); } - public function testGetIssuerOrganization() { + public function testGetIssuerOrganization(): void { $this->assertSame('ownCloud Security', $this->goodCertificate->getIssuerOrganization()); $this->assertSame('Internet Widgits Pty Ltd', $this->invalidCertificate->getIssuerOrganization()); $this->assertSame('Internet Widgits Pty Ltd', $this->expiredCertificate->getIssuerOrganization()); diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php index d9272627e5b..ce60a2f62a2 100644 --- a/tests/lib/Security/CredentialsManagerTest.php +++ b/tests/lib/Security/CredentialsManagerTest.php @@ -20,7 +20,7 @@ class CredentialsManagerTest extends \Test\TestCase { /** * @dataProvider credentialsProvider */ - public function testWithDB($userId, $identifier) { + public function testWithDB($userId, $identifier): void { $credentialsManager = Server::get(ICredentialsManager::class); $secrets = 'Open Sesame'; diff --git a/tests/lib/Security/CryptoTest.php b/tests/lib/Security/CryptoTest.php index b65a9a36985..ef96f8d5ddb 100644 --- a/tests/lib/Security/CryptoTest.php +++ b/tests/lib/Security/CryptoTest.php @@ -32,13 +32,13 @@ class CryptoTest extends \Test\TestCase { /** * @dataProvider defaultEncryptionProvider */ - public function testDefaultEncrypt($stringToEncrypt) { + public function testDefaultEncrypt($stringToEncrypt): void { $ciphertext = $this->crypto->encrypt($stringToEncrypt); $this->assertEquals($stringToEncrypt, $this->crypto->decrypt($ciphertext)); } - public function testWrongPassword() { + public function testWrongPassword(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('HMAC does not match.'); @@ -47,14 +47,14 @@ class CryptoTest extends \Test\TestCase { $this->crypto->decrypt($ciphertext, 'A wrong password!'); } - public function testLaterDecryption() { + public function testLaterDecryption(): void { $stringToEncrypt = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'; $encryptedString = '44a35023cca2e7a6125e06c29fc4b2ad9d8a33d0873a8b45b0de4ef9284f260c6c46bf25dc62120644c59b8bafe4281ddc47a70c35ae6c29ef7a63d79eefacc297e60b13042ac582733598d0a6b4de37311556bb5c480fd2633de4e6ebafa868c2d1e2d80a5d24f9660360dba4d6e0c8|lhrFgK0zd9U160Wo|a75e57ab701f9124e1113543fd1dc596f21e20d456a0d1e813d5a8aaec9adcb11213788e96598b67fe9486a9f0b99642c18296d0175db44b1ae426e4e91080ee'; $this->assertEquals($stringToEncrypt, $this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd')); } - public function testWrongIV() { + public function testWrongIV(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('HMAC does not match.'); @@ -63,7 +63,7 @@ class CryptoTest extends \Test\TestCase { } - public function testWrongParameters() { + public function testWrongParameters(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Authenticated ciphertext could not be decoded.'); @@ -71,14 +71,14 @@ class CryptoTest extends \Test\TestCase { $this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd'); } - public function testLegacy() { + public function testLegacy(): void { $cipherText = 'e16599188e3d212f5c7f17fdc2abca46|M1WfLAxbcAmITeD6|509457885d6ca5e6c3bfd3741852687a7f2bffce197f8d5ae97b65818b15a1b7f616b68326ff312371540f4ca8ac55f8e2de4aa13aab3474bd3431e51214e3ee'; $password = 'mypass'; $this->assertSame('legacy test', $this->crypto->decrypt($cipherText, $password)); } - public function testVersion2CiphertextDecryptsToCorrectPlaintext() { + public function testVersion2CiphertextDecryptsToCorrectPlaintext(): void { $this->assertSame( 'This is a plaintext value that will be encrypted with version 2. Which addresses the reduced permutations on the IV.', $this->crypto->decrypt( @@ -88,7 +88,7 @@ class CryptoTest extends \Test\TestCase { ); } - public function testVersion3CiphertextDecryptsToCorrectPlaintext() { + public function testVersion3CiphertextDecryptsToCorrectPlaintext(): void { $this->assertSame( 'Another plaintext value that will be encrypted with version 3. It addresses the related key issue. Old ciphertexts should be decrypted properly, but only use the better version for encryption.', $this->crypto->decrypt( diff --git a/tests/lib/Security/Events/GenerateSecurePasswordEventTest.php b/tests/lib/Security/Events/GenerateSecurePasswordEventTest.php index 29002a90488..e589f20f62c 100644 --- a/tests/lib/Security/Events/GenerateSecurePasswordEventTest.php +++ b/tests/lib/Security/Events/GenerateSecurePasswordEventTest.php @@ -14,19 +14,19 @@ use OCP\Security\PasswordContext; class GenerateSecurePasswordEventTest extends \Test\TestCase { - public function testDefaultProperties() { + public function testDefaultProperties(): void { $event = new GenerateSecurePasswordEvent(); $this->assertNull($event->getPassword()); $this->assertEquals(PasswordContext::ACCOUNT, $event->getContext()); } - public function testSettingPassword() { + public function testSettingPassword(): void { $event = new GenerateSecurePasswordEvent(); $event->setPassword('example'); $this->assertEquals('example', $event->getPassword()); } - public function testSettingContext() { + public function testSettingContext(): void { $event = new GenerateSecurePasswordEvent(PasswordContext::SHARING); $this->assertEquals(PasswordContext::SHARING, $event->getContext()); } diff --git a/tests/lib/Security/Events/ValidatePasswordPolicyEventTest.php b/tests/lib/Security/Events/ValidatePasswordPolicyEventTest.php index 8a7bc3b2f29..272f34e31aa 100644 --- a/tests/lib/Security/Events/ValidatePasswordPolicyEventTest.php +++ b/tests/lib/Security/Events/ValidatePasswordPolicyEventTest.php @@ -14,14 +14,14 @@ use OCP\Security\PasswordContext; class ValidatePasswordPolicyEventTest extends \Test\TestCase { - public function testDefaultProperties() { + public function testDefaultProperties(): void { $password = 'example'; $event = new ValidatePasswordPolicyEvent($password); $this->assertEquals($password, $event->getPassword()); $this->assertEquals(PasswordContext::ACCOUNT, $event->getContext()); } - public function testSettingContext() { + public function testSettingContext(): void { $event = new ValidatePasswordPolicyEvent('example', PasswordContext::SHARING); $this->assertEquals(PasswordContext::SHARING, $event->getContext()); } diff --git a/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php b/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php index 3c964972238..1fe01e26280 100644 --- a/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php +++ b/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php @@ -14,7 +14,7 @@ use OCP\Security\FeaturePolicy\AddFeaturePolicyEvent; use Test\TestCase; class AddFeaturePolicyEventTest extends TestCase { - public function testAddEvent() { + public function testAddEvent(): void { $manager = $this->createMock(FeaturePolicyManager::class); $policy = $this->createMock(FeaturePolicy::class); $event = new AddFeaturePolicyEvent($manager); diff --git a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php index 7110effb261..7386aa023a9 100644 --- a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php +++ b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php @@ -27,12 +27,12 @@ class FeaturePolicyManagerTest extends TestCase { $this->manager = new FeaturePolicyManager($this->dispatcher); } - public function testAddDefaultPolicy() { + public function testAddDefaultPolicy(): void { $this->manager->addDefaultPolicy(new FeaturePolicy()); $this->addToAssertionCount(1); } - public function testGetDefaultPolicyWithPoliciesViaEvent() { + public function testGetDefaultPolicyWithPoliciesViaEvent(): void { $this->dispatcher->addListener(AddFeaturePolicyEvent::class, function (AddFeaturePolicyEvent $e) { $policy = new FeaturePolicy(); $policy->addAllowedMicrophoneDomain('mydomain.com'); diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php index f51b4ee39db..41cad7f323f 100644 --- a/tests/lib/Security/HasherTest.php +++ b/tests/lib/Security/HasherTest.php @@ -122,7 +122,7 @@ class HasherTest extends \Test\TestCase { $this->hasher = new Hasher($this->config); } - public function testHash() { + public function testHash(): void { $hash = $this->hasher->hash('String To Hash'); $this->assertNotNull($hash); } @@ -130,7 +130,7 @@ class HasherTest extends \Test\TestCase { /** * @dataProvider versionHashProvider */ - public function testSplitHash($hash, $expected) { + public function testSplitHash($hash, $expected): void { $relativePath = self::invokePrivate($this->hasher, 'splitHash', [$hash]); $this->assertSame($expected, $relativePath); } @@ -139,7 +139,7 @@ class HasherTest extends \Test\TestCase { /** * @dataProvider hashProviders70_71 */ - public function testVerify($password, $hash, $expected) { + public function testVerify($password, $hash, $expected): void { $this->config ->expects($this->any()) ->method('getSystemValue') @@ -157,7 +157,7 @@ class HasherTest extends \Test\TestCase { /** * @dataProvider hashProviders72 */ - public function testVerifyArgon2i($password, $hash, $expected) { + public function testVerifyArgon2i($password, $hash, $expected): void { if (!\defined('PASSWORD_ARGON2I')) { $this->markTestSkipped('Need ARGON2 support to test ARGON2 hashes'); } @@ -169,7 +169,7 @@ class HasherTest extends \Test\TestCase { /** * @dataProvider hashProviders73 */ - public function testVerifyArgon2id(string $password, string $hash, bool $expected) { + public function testVerifyArgon2id(string $password, string $hash, bool $expected): void { if (!\defined('PASSWORD_ARGON2ID')) { $this->markTestSkipped('Need ARGON2ID support to test ARGON2ID hashes'); } @@ -178,7 +178,7 @@ class HasherTest extends \Test\TestCase { $this->assertSame($expected, $result); } - public function testUpgradeHashBlowFishToArgon2() { + public function testUpgradeHashBlowFishToArgon2(): void { if (!\defined('PASSWORD_ARGON2I')) { $this->markTestSkipped('Need ARGON2 support to test ARGON2 hashes'); } @@ -203,7 +203,7 @@ class HasherTest extends \Test\TestCase { $this->assertFalse(password_needs_rehash($relativePath['hash'], $newAlg, [])); } - public function testUsePasswordDefaultArgon2iVerify() { + public function testUsePasswordDefaultArgon2iVerify(): void { if (!\defined('PASSWORD_ARGON2I')) { $this->markTestSkipped('Need ARGON2 support to test ARGON2 hashes'); } @@ -227,7 +227,7 @@ class HasherTest extends \Test\TestCase { $this->assertTrue(password_verify($message, $relativePath['hash'])); } - public function testDoNotUsePasswordDefaultArgon2idVerify() { + public function testDoNotUsePasswordDefaultArgon2idVerify(): void { if (!\defined('PASSWORD_ARGON2ID')) { $this->markTestSkipped('Need ARGON2ID support to test ARGON2ID hashes'); } @@ -245,7 +245,7 @@ class HasherTest extends \Test\TestCase { $this->assertNull($newHash); } - public function testHashUsePasswordDefault() { + public function testHashUsePasswordDefault(): void { if (!\defined('PASSWORD_ARGON2I')) { $this->markTestSkipped('Need ARGON2 support to test ARGON2 hashes'); } @@ -265,7 +265,7 @@ class HasherTest extends \Test\TestCase { $this->assertEquals(PASSWORD_BCRYPT, $info['algo']); } - public function testValidHash() { + public function testValidHash(): void { $hash = '3|$argon2id$v=19$m=65536,t=4,p=1$czFCSjk3LklVdXppZ2VCWA$li0NgdXe2/jwSRxgteGQPWlzJU0E0xdtfHbCbrpych0'; $isValid = $this->hasher->validate($hash); @@ -273,7 +273,7 @@ class HasherTest extends \Test\TestCase { $this->assertTrue($isValid); } - public function testValidGeneratedHash() { + public function testValidGeneratedHash(): void { $message = 'secret'; $hash = $this->hasher->hash($message); @@ -282,7 +282,7 @@ class HasherTest extends \Test\TestCase { $this->assertTrue($isValid); } - public function testInvalidHash() { + public function testInvalidHash(): void { $invalidHash = 'someInvalidHash'; $isValid = $this->hasher->validate($invalidHash); diff --git a/tests/lib/Security/IdentityProof/KeyTest.php b/tests/lib/Security/IdentityProof/KeyTest.php index 19dc02e2ad1..572bfbea619 100644 --- a/tests/lib/Security/IdentityProof/KeyTest.php +++ b/tests/lib/Security/IdentityProof/KeyTest.php @@ -22,11 +22,11 @@ class KeyTest extends TestCase { $this->key = new Key('public', 'private'); } - public function testGetPrivate() { + public function testGetPrivate(): void { $this->assertSame('private', $this->key->getPrivate()); } - public function testGetPublic() { + public function testGetPublic(): void { $this->assertSame('public', $this->key->getPublic()); } } diff --git a/tests/lib/Security/IdentityProof/ManagerTest.php b/tests/lib/Security/IdentityProof/ManagerTest.php index bb5b01d563c..722555efe01 100644 --- a/tests/lib/Security/IdentityProof/ManagerTest.php +++ b/tests/lib/Security/IdentityProof/ManagerTest.php @@ -79,7 +79,7 @@ class ManagerTest extends TestCase { } } - public function testGetKeyWithExistingKey() { + public function testGetKeyWithExistingKey(): void { $user = $this->createMock(IUser::class); $user ->expects($this->once()) @@ -122,7 +122,7 @@ class ManagerTest extends TestCase { $this->assertEquals($expected, $this->manager->getKey($user)); } - public function testGetKeyWithNotExistingKey() { + public function testGetKeyWithNotExistingKey(): void { $user = $this->createMock(IUser::class); $user ->expects($this->once()) @@ -177,7 +177,7 @@ class ManagerTest extends TestCase { $this->assertEquals($expected, $this->manager->getKey($user)); } - public function testGenerateKeyPair() { + public function testGenerateKeyPair(): void { $manager = $this->getManager(); $data = 'MyTestData'; @@ -189,7 +189,7 @@ class ManagerTest extends TestCase { $this->assertSame(2048, $details['bits']); } - public function testGetSystemKey() { + public function testGetSystemKey(): void { $manager = $this->getManager(['retrieveKey']); /** @var Key|\PHPUnit\Framework\MockObject\MockObject $key */ @@ -206,7 +206,7 @@ class ManagerTest extends TestCase { - public function testGetSystemKeyFailure() { + public function testGetSystemKeyFailure(): void { $this->expectException(\RuntimeException::class); $manager = $this->getManager(['retrieveKey']); diff --git a/tests/lib/Security/IdentityProof/SignerTest.php b/tests/lib/Security/IdentityProof/SignerTest.php index 8b8d93e6b9a..6dc73c072e4 100644 --- a/tests/lib/Security/IdentityProof/SignerTest.php +++ b/tests/lib/Security/IdentityProof/SignerTest.php @@ -90,7 +90,7 @@ gQIDAQAB ); } - public function testSign() { + public function testSign(): void { $user = $this->createMock(IUser::class); $user->method('getCloudId') ->willReturn('foo@example.com'); @@ -123,7 +123,7 @@ gQIDAQAB $this->assertEquals($expects, $result); } - public function testVerifyValid() { + public function testVerifyValid(): void { $data = [ 'message' => [ 'data' => [ @@ -151,7 +151,7 @@ gQIDAQAB $this->assertTrue($this->signer->verify($data)); } - public function testVerifyInvalid() { + public function testVerifyInvalid(): void { $data = [ 'message' => [ 'data' => [ @@ -179,7 +179,7 @@ gQIDAQAB $this->assertFalse($this->signer->verify($data)); } - public function testVerifyInvalidData() { + public function testVerifyInvalidData(): void { $data = [ ]; diff --git a/tests/lib/Security/Normalizer/IpAddressTest.php b/tests/lib/Security/Normalizer/IpAddressTest.php index ae6b5cbc9ca..55cb149309a 100644 --- a/tests/lib/Security/Normalizer/IpAddressTest.php +++ b/tests/lib/Security/Normalizer/IpAddressTest.php @@ -60,11 +60,11 @@ class IpAddressTest extends TestCase { * @param string $input * @param string $expected */ - public function testGetSubnet($input, $expected) { + public function testGetSubnet($input, $expected): void { $this->assertSame($expected, (new IpAddress($input))->getSubnet()); } - public function testToString() { + public function testToString(): void { $this->assertSame('127.0.0.1', (string)(new IpAddress('127.0.0.1'))); } } diff --git a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php index 27799ce4af5..24e3ab1a209 100644 --- a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php +++ b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php @@ -53,7 +53,7 @@ class MemoryCacheBackendTest extends TestCase { ); } - public function testGetAttemptsWithNoAttemptsBefore() { + public function testGetAttemptsWithNoAttemptsBefore(): void { $this->cache ->expects($this->once()) ->method('get') @@ -63,7 +63,7 @@ class MemoryCacheBackendTest extends TestCase { $this->assertSame(0, $this->memoryCache->getAttempts('Method', 'User')); } - public function testGetAttempts() { + public function testGetAttempts(): void { $this->timeFactory ->expects($this->once()) ->method('getTime') @@ -84,7 +84,7 @@ class MemoryCacheBackendTest extends TestCase { $this->assertSame(3, $this->memoryCache->getAttempts('Method', 'User')); } - public function testRegisterAttemptWithNoAttemptsBefore() { + public function testRegisterAttemptWithNoAttemptsBefore(): void { $this->timeFactory ->expects($this->once()) ->method('getTime') @@ -106,7 +106,7 @@ class MemoryCacheBackendTest extends TestCase { $this->memoryCache->registerAttempt('Method', 'User', 100); } - public function testRegisterAttempt() { + public function testRegisterAttempt(): void { $this->timeFactory ->expects($this->once()) ->method('getTime') diff --git a/tests/lib/Security/RateLimiting/LimiterTest.php b/tests/lib/Security/RateLimiting/LimiterTest.php index 332f26b81d0..92600e22de8 100644 --- a/tests/lib/Security/RateLimiting/LimiterTest.php +++ b/tests/lib/Security/RateLimiting/LimiterTest.php @@ -31,7 +31,7 @@ class LimiterTest extends TestCase { } - public function testRegisterAnonRequestExceeded() { + public function testRegisterAnonRequestExceeded(): void { $this->expectException(\OC\Security\RateLimiting\Exception\RateLimitExceededException::class); $this->expectExceptionMessage('Rate limit exceeded'); @@ -47,7 +47,7 @@ class LimiterTest extends TestCase { $this->limiter->registerAnonRequest('MyIdentifier', 100, 100, '127.0.0.1'); } - public function testRegisterAnonRequestSuccess() { + public function testRegisterAnonRequestSuccess(): void { $this->backend ->expects($this->once()) ->method('getAttempts') @@ -69,7 +69,7 @@ class LimiterTest extends TestCase { } - public function testRegisterUserRequestExceeded() { + public function testRegisterUserRequestExceeded(): void { $this->expectException(\OC\Security\RateLimiting\Exception\RateLimitExceededException::class); $this->expectExceptionMessage('Rate limit exceeded'); @@ -91,7 +91,7 @@ class LimiterTest extends TestCase { $this->limiter->registerUserRequest('MyIdentifier', 100, 100, $user); } - public function testRegisterUserRequestSuccess() { + public function testRegisterUserRequestSuccess(): void { /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */ $user = $this->createMock(IUser::class); $user diff --git a/tests/lib/Security/SecureRandomTest.php b/tests/lib/Security/SecureRandomTest.php index 6e5f3587630..08d33d4a1b3 100644 --- a/tests/lib/Security/SecureRandomTest.php +++ b/tests/lib/Security/SecureRandomTest.php @@ -43,7 +43,7 @@ class SecureRandomTest extends \Test\TestCase { /** * @dataProvider stringGenerationProvider */ - public function testGetLowStrengthGeneratorLength($length, $expectedLength) { + public function testGetLowStrengthGeneratorLength($length, $expectedLength): void { $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); @@ -52,7 +52,7 @@ class SecureRandomTest extends \Test\TestCase { /** * @dataProvider stringGenerationProvider */ - public function testMediumLowStrengthGeneratorLength($length, $expectedLength) { + public function testMediumLowStrengthGeneratorLength($length, $expectedLength): void { $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); @@ -61,14 +61,14 @@ class SecureRandomTest extends \Test\TestCase { /** * @dataProvider stringGenerationProvider */ - public function testUninitializedGenerate($length, $expectedLength) { + public function testUninitializedGenerate($length, $expectedLength): void { $this->assertEquals($expectedLength, strlen($this->rng->generate($length))); } /** * @dataProvider charCombinations */ - public function testScheme($charName, $chars) { + public function testScheme($charName, $chars): void { $generator = $this->rng; $scheme = constant('OCP\Security\ISecureRandom::' . $charName); $randomString = $generator->generate(100, $scheme); @@ -86,7 +86,7 @@ class SecureRandomTest extends \Test\TestCase { /** * @dataProvider invalidLengths */ - public function testInvalidLengths($length) { + public function testInvalidLengths($length): void { $this->expectException(\LengthException::class); $generator = $this->rng; $generator->generate($length); diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php index 3dbaf376b52..656b7a77206 100644 --- a/tests/lib/Security/TrustedDomainHelperTest.php +++ b/tests/lib/Security/TrustedDomainHelperTest.php @@ -32,7 +32,7 @@ class TrustedDomainHelperTest extends \Test\TestCase { * @param string $testDomain * @param bool $result */ - public function testIsTrustedUrl($trustedDomains, $testDomain, $result) { + public function testIsTrustedUrl($trustedDomains, $testDomain, $result): void { $this->config->method('getSystemValue') ->willReturnMap([ ['overwritehost', '', ''], @@ -49,7 +49,7 @@ class TrustedDomainHelperTest extends \Test\TestCase { * @param string $testDomain * @param bool $result */ - public function testIsTrustedDomain($trustedDomains, $testDomain, $result) { + public function testIsTrustedDomain($trustedDomains, $testDomain, $result): void { $this->config->method('getSystemValue') ->willReturnMap([ ['overwritehost', '', ''], @@ -134,7 +134,7 @@ class TrustedDomainHelperTest extends \Test\TestCase { ]; } - public function testIsTrustedDomainOverwriteHost() { + public function testIsTrustedDomainOverwriteHost(): void { $this->config->method('getSystemValue') ->with('overwritehost') ->willReturn('myproxyhost'); diff --git a/tests/lib/Security/VerificationToken/VerificationTokenTest.php b/tests/lib/Security/VerificationToken/VerificationTokenTest.php index f8573478fa5..7123cc8b013 100644 --- a/tests/lib/Security/VerificationToken/VerificationTokenTest.php +++ b/tests/lib/Security/VerificationToken/VerificationTokenTest.php @@ -52,13 +52,13 @@ class VerificationTokenTest extends TestCase { ); } - public function testTokenUserUnknown() { + public function testTokenUserUnknown(): void { $this->expectException(InvalidTokenException::class); $this->expectExceptionCode(InvalidTokenException::USER_UNKNOWN); $this->token->check('encryptedToken', null, 'fingerprintToken', 'foobar'); } - public function testTokenUserUnknown2() { + public function testTokenUserUnknown2(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -69,7 +69,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar'); } - public function testTokenNotFound() { + public function testTokenNotFound(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -85,7 +85,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar'); } - public function testTokenDecryptionError() { + public function testTokenDecryptionError(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -112,7 +112,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar'); } - public function testTokenInvalidFormat() { + public function testTokenInvalidFormat(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -139,7 +139,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar'); } - public function testTokenExpired() { + public function testTokenExpired(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -173,7 +173,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar'); } - public function testTokenExpiredByLogin() { + public function testTokenExpiredByLogin(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -207,7 +207,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar', true); } - public function testTokenMismatch() { + public function testTokenMismatch(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -241,7 +241,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar'); } - public function testTokenSuccess() { + public function testTokenSuccess(): void { $user = $this->createMock(IUser::class); $user->expects($this->atLeastOnce()) ->method('isEnabled') @@ -273,7 +273,7 @@ class VerificationTokenTest extends TestCase { $this->token->check('barfoo', $user, 'fingerprintToken', 'foobar'); } - public function testCreate() { + public function testCreate(): void { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('getUID') |