public function testExecute() { $inputInterface = $this->getMock('\\Symfony\\Component\\Console\\Input\\InputInterface'); $outputInterface = $this->getMock('\\Symfony\\Component\\Console\\Output\\OutputInterface'); $inputInterface->expects($this->at(0))->method('getOption')->with('privateKey')->will($this->returnValue('privateKey')); $inputInterface->expects($this->at(1))->method('getOption')->with('certificate')->will($this->returnValue('certificate')); $this->fileAccessHelper->expects($this->at(0))->method('file_get_contents')->with('privateKey')->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')); $this->fileAccessHelper->expects($this->at(1))->method('file_get_contents')->with('certificate')->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')); $this->checker->expects($this->once())->method('writeCoreSignature'); $outputInterface->expects($this->at(0))->method('writeln')->with('Successfully signed "core"'); $this->invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]); }
public function testRunInstanceVerification() { $this->checker = $this->getMockBuilder('\\OC\\IntegrityCheck\\Checker')->setConstructorArgs([$this->environmentHelper, $this->fileAccessHelper, $this->appLocator, $this->config, $this->cacheFactory, $this->appManager])->setMethods(['verifyCoreSignature', 'verifyAppSignature'])->getMock(); $this->checker->expects($this->at(0))->method('verifyCoreSignature'); $this->appLocator->expects($this->at(0))->Method('getAllApps')->will($this->returnValue(['files', 'calendar', 'contacts', 'dav'])); $this->appManager->expects($this->at(0))->method('isShipped')->with('files')->will($this->returnValue(true)); $this->checker->expects($this->at(1))->method('verifyAppSignature')->with('files'); $this->appManager->expects($this->at(1))->method('isShipped')->with('calendar')->will($this->returnValue(false)); $this->appLocator->expects($this->at(1))->method('getAppPath')->with('calendar')->will($this->returnValue('/apps/calendar')); $this->fileAccessHelper->expects($this->at(0))->method('file_exists')->with('/apps/calendar/appinfo/signature.json')->will($this->returnValue(true)); $this->checker->expects($this->at(2))->method('verifyAppSignature')->with('calendar'); $this->appManager->expects($this->at(2))->method('isShipped')->with('contacts')->will($this->returnValue(false)); $this->appLocator->expects($this->at(2))->method('getAppPath')->with('contacts')->will($this->returnValue('/apps/contacts')); $this->fileAccessHelper->expects($this->at(1))->method('file_exists')->with('/apps/contacts/appinfo/signature.json')->will($this->returnValue(false)); $this->appManager->expects($this->at(3))->method('isShipped')->with('dav')->will($this->returnValue(true)); $this->checker->expects($this->at(3))->method('verifyAppSignature')->with('dav'); $this->checker->runInstanceVerification(); }