/** * Figure out which resources we have available and subscribe to them * * @param EventInterface $event */ public function subscribe(EventInterface $event) { $resources = Resource::getAllResources(); if ($this->params['additionalResources']) { $resources = array_merge($resources, $this->params['additionalResources']); } $events = []; foreach ($resources as $resource) { $events[$resource] = ['checkAccess' => 500]; } $manager = $event->getManager(); $manager->addCallbacks($event->getHandler(), $events); }
public function testMethodsReturnsArrays() { $this->assertInternalType('array', Resource::getReadOnlyResources()); $this->assertInternalType('array', Resource::getReadWriteResources()); $this->assertInternalType('array', Resource::getAllResources()); }
/** * Ask user which specific resources the public key should have access to * * @param InputInterface $input * @param OutputInterface $output * @return array */ private function askForSpecificResources(InputInterface $input, OutputInterface $output) { $resources = Resource::getAllResources(); sort($resources); $question = new ChoiceQuestion('Which resources should the public key have access to? (comma-separated) ', $resources); $question->setMultiselect(true); return $this->getHelper('question')->ask($input, $output, $question); }
/** * @covers ImboCli\Command\AddPublicKey::execute * @covers ImboCli\Command\AddPublicKey::askForAnotherAclRule * @covers ImboCli\Command\AddPublicKey::askForCustomResources */ public function testPromtpsForListOfCustomResourcesIfOptionIsSelected() { $allResources = Resource::getAllResources(); sort($allResources); $this->adapter->expects($this->once())->method('addAccessRule')->with('foo', ['resources' => ['foo.read', 'bar.write'], 'users' => '*']); $this->adapter->expects($this->once())->method('addKeyPair')->with('foo', 'bar'); $helper = $this->command->getHelper('question'); $helper->setInputStream($this->getInputStream(['4', 'foo.read,bar.write', '*', 'n'])); $commandTester = new CommandTester($this->command); $commandTester->execute(['publicKey' => 'foo', 'privateKey' => 'bar']); }