Esempio n. 1
0
 /**
  * @test
  */
 public function shouldThrowExceptionBecauseOfTooManyRules()
 {
     $this->setExpectedException('\\Exception');
     $table = (new TableFactory())->build(Table::TABLE_MANGLE);
     $chain = new Chain('test', Table::TABLE_MANGLE, 'none');
     $chain->appendRule(new Rule('INPUT', 'tcp'));
     $chain->appendRule(new Rule('DROP', 'tcp'));
     $table->createChain($chain);
 }
Esempio n. 2
0
 /**
  * @param Chain $chain
  * @return string
  * @throws \Exception
  */
 public function createChain(Chain $chain)
 {
     $this->chains[$chain->getName()] = $chain;
     $rulesCounter = count($chain->getRulesList());
     $command = new Command($this->name);
     if (1 < $rulesCounter) {
         throw new \Exception('Maximum number Rules on creation is 1.');
     } else {
         if (1 === $rulesCounter) {
             $command->setOptions((string) current($chain->getRulesList()));
         }
     }
     return $command->createChain($chain->getName());
 }