mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
test: Fix tests/lib/Security/
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
c5cd7ef9b9
commit
f474b5b3a9
13 changed files with 22 additions and 28 deletions
|
|
@ -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…
Reference in a new issue