Ejemplo n.º 1
0
 /**
  * @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);
 }
Ejemplo n.º 2
0
 /**
  * Verify the signature of core. Returns an array with the following content:
  * [
  * 	'FILE_MISSING' =>
  * 	[
  * 		'filename' => [
  * 			'expected' => 'expectedSHA512',
  * 			'current' => 'currentSHA512',
  * 		],
  * 	],
  * 	'EXTRA_FILE' =>
  * 	[
  * 		'filename' => [
  * 			'expected' => 'expectedSHA512',
  * 			'current' => 'currentSHA512',
  * 		],
  * 	],
  * 	'INVALID_HASH' =>
  * 	[
  * 		'filename' => [
  * 			'expected' => 'expectedSHA512',
  * 			'current' => 'currentSHA512',
  * 		],
  * 	],
  * ]
  *
  * Array may be empty in case no problems have been found.
  *
  * @return array
  */
 public function verifyCoreSignature()
 {
     try {
         $result = $this->verify($this->environmentHelper->getServerRoot() . '/core/signature.json', $this->environmentHelper->getServerRoot(), 'core');
     } catch (\Exception $e) {
         $result = ['EXCEPTION' => ['class' => get_class($e), 'message' => $e->getMessage()]];
     }
     $this->storeResults('core', $result);
     return $result;
 }
Ejemplo n.º 3
0
    public function testVerifyCoreWithDifferentScope()
    {
        $this->environmentHelper->expects($this->any())->method('getServerRoot')->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'));
        $signatureDataFile = '{
    "hashes": {
        "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112",
        "subfolder\\/file.txt": "410738545fb623c0a5c8a71f561e48ea69e3ada0981a455e920a5ae9bf17c6831ae654df324f9328ff8453de179276ae51931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6DI\\/ipWvfrF7CEy6I\\/kP1InY\\/vMDjQjeDnJ\\/VrXIWXO\\r\\nyZvHXVaN\\/m+1RlETsH7YO\\/QmxRue9ZHN3gvvWtmpCeA95sfpepOk7UcHxHZYyQbF\\r\\n49\\/au8j+5tsr4A83xzsT1JbcKRxkAaQ7WDJpOnE5O1+H0fB+BaLakTg6XX9d4Fo7\\r\\n7Gin7hVWX7pL+JIyxMzME3LhfI61+CRcqZQIrpyaafUziPQbWIPfEs7h8tCOWyvW\\r\\nUO8ZLervYCB3j44ivkrxPlcBklDCqqKKBzDP9dYOtS\\/P4RB1NkHA9+NTvmBpTonS\\r\\nSFXdg9fFMD7VfjDE3Vnk+8DWkVH5wBYowTAD7w9Wuzr7DumiAULexnP\\/Y7xwxLv7\\r\\n4B+pXTAcRK0zECDEaX3npS8xWzrB\\r\\n-----END CERTIFICATE-----"
}';
        $this->fileAccessHelper->expects($this->at(0))->method('file_get_contents')->with(\OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json')->will($this->returnValue($signatureDataFile));
        $this->fileAccessHelper->expects($this->at(1))->method('file_get_contents')->with(\OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt')->will($this->returnValue(file_get_contents(__DIR__ . '/../../data/integritycheck/root.crt')));
        $expected = ['EXCEPTION' => ['class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Certificate is not valid for required scope. (Requested: core, current: CN=SomeApp)']];
        $this->assertSame($expected, $this->checker->verifyCoreSignature());
    }
 public function testGetChannel()
 {
     $this->assertSame(\OC_Util::getChannel(), $this->environmentHelper->getChannel());
 }
Ejemplo n.º 5
0
 public function testGetServerRoot()
 {
     $factory = new EnvironmentHelper();
     $this->assertSame(\OC::$SERVERROOT, $factory->getServerRoot());
 }