/** * @expectedException \OCA\Files_external\NotFoundException */ public function testNonExistingStorage() { $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism'); $storage = new StorageConfig(255); $storage->setMountPoint('mountpoint'); $storage->setBackend($backend); $storage->setAuthMechanism($authMechanism); $this->service->updateStorage($storage); }
public function testUpdateStorageMountPoint() { $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism'); $storage = new StorageConfig(); $storage->setMountPoint('mountpoint'); $storage->setBackend($backend); $storage->setAuthMechanism($authMechanism); $storage->setBackendOptions(['password' => 'testPassword']); $savedStorage = $this->service->addStorage($storage); $newAuthMechanism = $this->backendService->getAuthMechanism('identifier:\\Other\\Auth\\Mechanism'); $updatedStorage = new StorageConfig($savedStorage->getId()); $updatedStorage->setMountPoint('mountpoint2'); $updatedStorage->setBackend($backend); $updatedStorage->setAuthMechanism($newAuthMechanism); $updatedStorage->setBackendOptions(['password' => 'password2']); $this->service->updateStorage($updatedStorage); $savedStorage = $this->service->getStorage($updatedStorage->getId()); $this->assertEquals('/mountpoint2', $savedStorage->getMountPoint()); $this->assertEquals($newAuthMechanism, $savedStorage->getAuthMechanism()); $this->assertEquals('password2', $savedStorage->getBackendOption('password')); }
/** * Update storage to the configuration * * @param StorageConfig $updatedStorage storage attributes * * @return StorageConfig storage config * @throws NotFoundException if the given storage does not exist in the config */ public function updateStorage(StorageConfig $updatedStorage) { $updatedStorage->setApplicableUsers([$this->getUser()->getUID()]); return parent::updateStorage($updatedStorage); }