/** * Test invalid configs */ public function testInvalidConfigs() { $path = __DIR__ . '/../../data/config/invalid'; $files = scandir($path); foreach ($files as $file) { if (!preg_match('/\\.yml$/ui', $file)) { continue; } $config = Yaml::parse(file_get_contents($path . "/" . $file)); try { $result = Validator\ConfigValidator::validate($config); $this->assertFalse($result, sprintf('Config file %s should be invalid', $file)); $this->fail(sprintf('Config file %s should be invalid', $file)); } catch (InvalidConfigurationException $e) { } } }
try { $arguments = getopt("d::", ["data::"]); if (!isset($arguments["data"])) { throw new Exception\UserException(Exception\UserException::ERR_DATA_PARAM); } if (!file_exists($arguments["data"] . "/config.yml")) { throw new Exception\UserException(Exception\UserException::ERR_MISSING_CONFIG); } $config = Yaml::parse(file_get_contents($arguments["data"] . "/config.yml")); if (empty($config)) { print "Could not parse config file"; exit(2); } //@FIXME move to application, refactor with symfony config mapping try { Validator\ConfigValidator::validate($config); } catch (InvalidConfigurationException $e) { throw new Exception\UserException($e->getMessage()); } $action = isset($config['action']) ? $config['action'] : $action; $config = $config['parameters']; if ($action !== 'run') { $logger->setHandlers(array(new NullHandler(Logger::INFO))); } // move encrypted params to non-ecrypted if (isset($config['elastic']['#host'])) { $config['elastic']['host'] = $config['elastic']['#host']; unset($config['elastic']['#host']); } if (isset($config['elastic']['ssh']['keys']['#private'])) { $config['elastic']['ssh']['keys']['private'] = $config['elastic']['ssh']['keys']['#private'];