test: Fix tests/lib/Security/

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/52851/head
Joas Schilling 12 months ago
parent c5cd7ef9b9
commit f474b5b3a9
No known key found for this signature in database
GPG Key ID: F72FA5B49FFA96B0
  1. 4
      tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php
  2. 2
      tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
  3. 9
      tests/lib/Security/CertificateManagerTest.php
  4. 2
      tests/lib/Security/CredentialsManagerTest.php
  5. 2
      tests/lib/Security/CryptoTest.php
  6. 11
      tests/lib/Security/HasherTest.php
  7. 2
      tests/lib/Security/Ip/BruteforceAllowListTest.php
  8. 2
      tests/lib/Security/Ip/RemoteAddressTest.php
  9. 2
      tests/lib/Security/Normalizer/IpAddressTest.php
  10. 4
      tests/lib/Security/RemoteHostValidatorIntegrationTest.php
  11. 2
      tests/lib/Security/RemoteHostValidatorTest.php
  12. 6
      tests/lib/Security/SecureRandomTest.php
  13. 2
      tests/lib/Security/TrustedDomainHelperTest.php

@ -36,7 +36,7 @@ class MemoryCacheBackendTest extends TestCase {
$this->cacheFactory
->expects($this->once())
->method('createDistributed')
->with('OC\Security\Bruteforce\Backend\MemoryCacheBackend')
->with(MemoryCacheBackend::class)
->willReturn($this->cache);
$this->backend = new MemoryCacheBackend(
@ -55,7 +55,7 @@ class MemoryCacheBackendTest extends TestCase {
$this->assertSame(0, $this->backend->getAttempts('10.10.10.10/32', 0));
}
public function dataGetAttempts(): array {
public static function dataGetAttempts(): array {
return [
[0, null, null, 4],
[100, null, null, 2],

@ -28,7 +28,7 @@ class SessionStorageTest extends \Test\TestCase {
/**
* @return array
*/
public function getTokenDataProvider() {
public static function getTokenDataProvider(): array {
return [
[
'',

@ -100,10 +100,7 @@ class CertificateManagerTest extends \Test\TestCase {
$this->certificateManager->addCertificate('InvalidCertificate', 'invalidCertificate');
}
/**
* @return array
*/
public function dangerousFileProvider() {
public static function dangerousFileProvider(): array {
return [
['.htaccess'],
['../../foo.txt'],
@ -153,7 +150,7 @@ class CertificateManagerTest extends \Test\TestCase {
/** @var CertificateManager | \PHPUnit\Framework\MockObject\MockObject $certificateManager */
$certificateManager = $this->getMockBuilder('OC\Security\CertificateManager')
->setConstructorArgs([$view, $config, $this->createMock(LoggerInterface::class), $this->random])
->setMethods(['getFilemtimeOfCaBundle', 'getCertificateBundle'])
->onlyMethods(['getFilemtimeOfCaBundle', 'getCertificateBundle'])
->getMock();
$certificateManager->expects($this->any())->method('getFilemtimeOfCaBundle')
@ -181,7 +178,7 @@ class CertificateManagerTest extends \Test\TestCase {
);
}
public function dataTestNeedRebundling() {
public static function dataTestNeedRebundling(): array {
return [
//values: CaBundleMtime, targetBundleMtime, targetBundleExists, expected

@ -50,7 +50,7 @@ class CredentialsManagerTest extends \Test\TestCase {
$this->assertSame($secretsRev, $received);
}
public function credentialsProvider(): array {
public static function credentialsProvider(): array {
return [
[
'alice',

@ -13,7 +13,7 @@ namespace Test\Security;
use OC\Security\Crypto;
class CryptoTest extends \Test\TestCase {
public function defaultEncryptionProvider() {
public static function defaultEncryptionProvider(): array {
return [
['Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'],
[''],

@ -17,10 +17,7 @@ use OCP\IConfig;
* Class HasherTest
*/
class HasherTest extends \Test\TestCase {
/**
* @return array
*/
public function versionHashProvider() {
public static function versionHashProvider(): array {
return [
['asf32äà$$a.|3', null],
['asf32äà$$a.|3|5', null],
@ -30,7 +27,7 @@ class HasherTest extends \Test\TestCase {
];
}
public function hashProviders70_71(): array {
public static function hashProviders70_71(): array {
return [
// Valid SHA1 strings
['password', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', true],
@ -66,7 +63,7 @@ class HasherTest extends \Test\TestCase {
];
}
public function hashProviders72(): array {
public static function hashProviders72(): array {
return [
// Valid ARGON2 hashes
['password', '2|$argon2i$v=19$m=1024,t=2,p=2$T3JGcEkxVFNOVktNSjZUcg$4/hyLtSejxNgAuzSFFV/HLM3qRQKBwEtKw61qPN4zWA', true],
@ -83,7 +80,7 @@ class HasherTest extends \Test\TestCase {
];
}
public function hashProviders73(): array {
public static function hashProviders73(): array {
return [
// Valid ARGON2ID hashes
['password', '2|$argon2id$v=19$m=65536,t=4,p=1$TEtIMnhUczliQzI0Y01WeA$BpMUDrApy25iagIogUAnlc0rNTPJmGs8lOEeVHujJ9Q', true],

@ -42,7 +42,7 @@ class BruteforceAllowListTest extends TestCase {
);
}
public function dataIsBypassListed(): array {
public static function dataIsBypassListed(): array {
return [
[
'10.10.10.10',

@ -44,7 +44,7 @@ class RemoteAddressTest extends \Test\TestCase {
/**
* @return array<string, mixed, bool>
*/
public function dataProvider(): array {
public static function dataProvider(): array {
return [
// No IP (ie. CLI)
['', ['192.168.1.2/24'], true],

@ -13,7 +13,7 @@ use OC\Security\Normalizer\IpAddress;
use Test\TestCase;
class IpAddressTest extends TestCase {
public function subnetDataProvider() {
public static function subnetDataProvider(): array {
return [
[
'64.233.191.254',

@ -37,7 +37,7 @@ class RemoteHostValidatorIntegrationTest extends TestCase {
);
}
public function localHostsData(): array {
public static function localHostsData(): array {
return [
['[::1]'],
['[::]'],
@ -101,7 +101,7 @@ class RemoteHostValidatorIntegrationTest extends TestCase {
self::assertTrue($isValid);
}
public function externalAddressesData():array {
public static function externalAddressesData():array {
return [
['8.8.8.8'],
['8.8.4.4'],

@ -44,7 +44,7 @@ class RemoteHostValidatorTest extends TestCase {
);
}
public function dataValid(): array {
public static function dataValid(): array {
return [
['nextcloud.com', true],
['com.one-.nextcloud-one.com', false],

@ -13,7 +13,7 @@ namespace Test\Security;
use OC\Security\SecureRandom;
class SecureRandomTest extends \Test\TestCase {
public function stringGenerationProvider() {
public static function stringGenerationProvider(): array {
return [
[1, 1],
[128, 128],
@ -24,7 +24,7 @@ class SecureRandomTest extends \Test\TestCase {
];
}
public static function charCombinations() {
public static function charCombinations(): array {
return [
['CHAR_LOWER', '[a-z]'],
['CHAR_UPPER', '[A-Z]'],
@ -76,7 +76,7 @@ class SecureRandomTest extends \Test\TestCase {
$this->assertSame(1, $matchesRegex);
}
public static function invalidLengths() {
public static function invalidLengths(): array {
return [
[0],
[-1],

@ -63,7 +63,7 @@ class TrustedDomainHelperTest extends \Test\TestCase {
/**
* @return array
*/
public function trustedDomainDataProvider() {
public static function trustedDomainDataProvider(): array {
$trustedHostTestList = [
'host.one.test',
'host.two.test',

Loading…
Cancel
Save