diff options
Diffstat (limited to 'tests/lib/IntegrityCheck/CheckerTest.php')
-rw-r--r-- | tests/lib/IntegrityCheck/CheckerTest.php | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php index 6b6da1cc30c..5858a01203f 100644 --- a/tests/lib/IntegrityCheck/CheckerTest.php +++ b/tests/lib/IntegrityCheck/CheckerTest.php @@ -17,11 +17,14 @@ use OCP\App\IAppManager; use OCP\IAppConfig; use OCP\ICacheFactory; use OCP\IConfig; +use OCP\ServerVersion; use phpseclib\Crypt\RSA; use phpseclib\File\X509; use Test\TestCase; class CheckerTest extends TestCase { + /** @var ServerVersion|\PHPUnit\Framework\MockObject\MockObject */ + private $serverVersion; /** @var EnvironmentHelper|\PHPUnit\Framework\MockObject\MockObject */ private $environmentHelper; /** @var AppLocator|\PHPUnit\Framework\MockObject\MockObject */ @@ -43,6 +46,7 @@ class CheckerTest extends TestCase { protected function setUp(): void { parent::setUp(); + $this->serverVersion = $this->createMock(ServerVersion::class); $this->environmentHelper = $this->createMock(EnvironmentHelper::class); $this->fileAccessHelper = $this->createMock(FileAccessHelper::class); $this->appLocator = $this->createMock(AppLocator::class); @@ -62,6 +66,7 @@ class CheckerTest extends TestCase { ->willReturn(new NullCache()); $this->checker = new Checker( + $this->serverVersion, $this->environmentHelper, $this->fileAccessHelper, $this->appLocator, @@ -149,7 +154,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppSignatureWithoutSignatureData(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -169,7 +174,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppSignatureWithValidSignatureData(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -208,7 +213,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppSignatureWithTamperedSignatureData(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -253,7 +258,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppSignatureWithTamperedFiles(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -314,7 +319,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppSignatureWithTamperedFilesAndAlternatePath(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -374,7 +379,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppWithDifferentScope(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -418,7 +423,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppWithDifferentScopeAndAlwaysTrustedCore(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -639,7 +644,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreSignatureWithoutSignatureData(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -659,7 +664,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreSignatureWithValidSignatureData(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -696,7 +701,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreSignatureWithValidModifiedHtaccessSignatureData(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -759,7 +764,7 @@ class CheckerTest extends TestCase { // occ integrity:sign-core --privateKey=./tests/data/integritycheck/core.key --certificate=./tests/data/integritycheck/core.crt --path=./tests/data/integritycheck/mimetypeListModified self::assertEquals($newFile, file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js')); - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -786,7 +791,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreSignatureWithValidSignatureDataAndNotAlphabeticOrder(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -823,7 +828,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreSignatureWithTamperedSignatureData(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -866,7 +871,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreSignatureWithTamperedFiles(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -924,7 +929,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreWithInvalidCertificate(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -967,7 +972,7 @@ class CheckerTest extends TestCase { } public function testVerifyCoreWithDifferentScope(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -1012,6 +1017,7 @@ class CheckerTest extends TestCase { public function testRunInstanceVerification(): void { $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker') ->setConstructorArgs([ + $this->serverVersion, $this->environmentHelper, $this->fileAccessHelper, $this->appLocator, @@ -1090,7 +1096,7 @@ class CheckerTest extends TestCase { } public function testVerifyAppSignatureWithoutSignatureDataAndCodeCheckerDisabled(): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn('stable'); @@ -1120,7 +1126,7 @@ class CheckerTest extends TestCase { * @dataProvider channelDataProvider */ public function testIsCodeCheckEnforced($channel, $isCodeSigningEnforced): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn($channel); @@ -1138,7 +1144,7 @@ class CheckerTest extends TestCase { * @dataProvider channelDataProvider */ public function testIsCodeCheckEnforcedWithDisabledConfigSwitch($channel): void { - $this->environmentHelper + $this->serverVersion ->expects($this->once()) ->method('getChannel') ->willReturn($channel); |