}
public function testVerifyAppSignatureWithoutSignatureData() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$expected = [
'EXCEPTION' => [
'class' => 'OC\IntegrityCheck\Exceptions\InvalidSignatureException',
}
public function testVerifyAppSignatureWithValidSignatureData() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->appLocator
->expects($this->once())
->method('getAppPath')
}
public function testVerifyAppSignatureWithTamperedSignatureData() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->appLocator
->expects($this->once())
->method('getAppPath')
}
public function testVerifyAppSignatureWithTamperedFiles() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->appLocator
->expects($this->once())
->method('getAppPath')
}
public function testVerifyAppWithDifferentScope() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->appLocator
->expects($this->once())
->method('getAppPath')
}
public function testVerifyAppWithDifferentScopeAndAlwaysTrustedCore() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->appLocator
->expects($this->once())
->method('getAppPath')
}
public function testVerifyCoreSignatureWithoutSignatureData() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$expected = [
'EXCEPTION' => [
'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException',
}
public function testVerifyCoreSignatureWithValidSignatureData() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->environmentHelper
->expects($this->any())
->method('getServerRoot')
}
public function testVerifyCoreSignatureWithValidSignatureDataAndNotAlphabeticOrder() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->environmentHelper
->expects($this->any())
->method('getServerRoot')
}
public function testVerifyCoreSignatureWithTamperedSignatureData() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->environmentHelper
->expects($this->any())
->method('getServerRoot')
}
public function testVerifyCoreSignatureWithTamperedFiles() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->environmentHelper
->expects($this->any())
->method('getServerRoot')
}
public function testVerifyCoreWithInvalidCertificate() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->environmentHelper
->expects($this->any())
->method('getServerRoot')
}
public function testVerifyCoreWithDifferentScope() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
$this->environmentHelper
->expects($this->any())
->method('getServerRoot')
$this->checker->runInstanceVerification();
}
+ public function testVerifyAppSignatureWithoutSignatureDataAndCodeCheckerDisabled() {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue('stable'));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(true));
+
+ $expected = [];
+ $this->assertSame($expected, $this->checker->verifyAppSignature('SomeApp'));
+ }
+
+ /**
+ * @return array
+ */
+ public function channelDataProvider() {
+ return [
+ ['stable', true],
+ ['git', false],
+ ];
+ }
+
+ /**
+ * @param string $channel
+ * @param bool $isCodeSigningEnforced
+ * @dataProvider channelDataProvider
+ */
+ public function testIsCodeCheckEnforced($channel, $isCodeSigningEnforced) {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue($channel));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(false));
+
+ $this->assertSame($isCodeSigningEnforced, $this->checker->isCodeCheckEnforced());
+ }
+
+ /**
+ * @param string $channel
+ * @dataProvider channelDataProvider
+ */
+ public function testIsCodeCheckEnforcedWithDisabledConfigSwitch($channel) {
+ $this->environmentHelper
+ ->expects($this->once())
+ ->method('getChannel')
+ ->will($this->returnValue($channel));
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('integrity.check.disabled', false)
+ ->will($this->returnValue(true));
+
+ $result = $this->invokePrivate($this->checker, 'isCodeCheckEnforced');
+ $this->assertSame(false, $result);
+ }
}