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(); }
/** * Verify the core code of the instance as well as all applicable applications * and store the results. */ public function runInstanceVerification() { $this->verifyCoreSignature(); $appIds = $this->appLocator->getAllApps(); foreach ($appIds as $appId) { // If an application is shipped a valid signature is required $isShipped = $this->appManager->isShipped($appId); $appNeedsToBeChecked = false; if ($isShipped) { $appNeedsToBeChecked = true; } elseif ($this->fileAccessHelper->file_exists($this->appLocator->getAppPath($appId) . '/appinfo/signature.json')) { // Otherwise only if the application explicitly ships a signature.json file $appNeedsToBeChecked = true; } if ($appNeedsToBeChecked) { $this->verifyAppSignature($appId); } } }
public function testGetAllApps() { $this->assertSame(\OC_App::getAllApps(), $this->locator->getAllApps()); }