Commit fc426565 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix : CheckConfig

 - Ajout d'une option "-d / -docker" qui zap le teste sur la présente du fichier de configuration de service
 - Le test des log teste maintenant l'accès en écriture au dossier "logs"
parent f4b585de
Loading
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@

namespace Oscar\Command;


use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\SchemaValidator;
use Monolog\Logger;
@@ -19,6 +18,7 @@ use Oscar\Service\ConfigurationParser;
use Oscar\Service\OscarConfigurationService;
use Oscar\Service\OscarUserContext;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Parser;
@@ -30,7 +30,9 @@ class OscarCheckConfigCommand extends OscarCommandAbstract
    protected function configure()
    {
        $this
            ->setDescription("Vérification de la configuration");
            ->setDescription("Vérification de la configuration")
            ->addOption('docker', 'd', InputOption::VALUE_NONE, "Mode DOCKER")
        ;
    }

    /**
@@ -80,11 +82,12 @@ class OscarCheckConfigCommand extends OscarCommandAbstract
                $parser = new Parser();
                $paramsPhp = $parser->parse(file_get_contents($fileYml));
                foreach ($paramsPhp as $paramKey => $paramValue) {
                    if (is_array($paramValue))
                    if (is_array($paramValue)) {
                        $io->text(sprintf('  + %s : <bold>%s</bold>', $paramKey, '...'));
                    else
                    } else {
                        $io->text(sprintf('  + %s : <bold>%s</bold>', $paramKey, $paramValue));
                    }
                }
                if ($key == 'ldap') {
                    $io->newLine();
                    $io->write(sprintf('* Stratégie d\'accès <bold>%s</bold>', $paramsPhp['access_strategy']));
@@ -98,7 +101,7 @@ class OscarCheckConfigCommand extends OscarCommandAbstract
                $checkResult = $class->checkAccess();
                if ($checkResult) {
                    $io->write(" <green>OK</green>");
                    if ($checkResult !== TRUE) {
                    if ($checkResult !== true) {
                        $io->writeln(" => " . $checkResult . " person trouvées");
                    }
                } else {
@@ -137,11 +140,12 @@ class OscarCheckConfigCommand extends OscarCommandAbstract
                $parser = new Parser();
                $paramsPhp = $parser->parse(file_get_contents($fileYml));
                foreach ($paramsPhp as $paramKey => $paramValue) {
                    if (is_array($paramValue))
                    if (is_array($paramValue)) {
                        $io->text(sprintf('  + %s : <bold>%s</bold>', $paramKey, '...'));
                    else
                    } else {
                        $io->text(sprintf('  + %s : <bold>%s</bold>', $paramKey, $paramValue));
                    }
                }
                if ($key == 'ldap') {
                    $io->newLine();
                    $io->write(sprintf('* Stratégie d\'accès <bold>%s</bold>', $paramsPhp['access_strategy']));
@@ -155,7 +159,7 @@ class OscarCheckConfigCommand extends OscarCommandAbstract
                $checkResult = $class->checkAccess();
                if ($checkResult) {
                    $io->write(" <green>OK</green>");
                    if ($checkResult !== TRUE) {
                    if ($checkResult !== true) {
                        $io->writeln(" => " . $checkResult . " organisations trouvées");
                    }
                } else {
@@ -180,10 +184,10 @@ class OscarCheckConfigCommand extends OscarCommandAbstract

        $io->title("Vérification de la configuration");


        /** @var OscarConfigurationService $oscarConfig */
        $oscarConfig = $this->getServicemanager()->get(OscarConfigurationService::class);

        $docker = $input->getOption("docker");

        $rootPath = __DIR__ . '/../../../../../';
        $configPath = 'config/autoload/local.php';
@@ -261,10 +265,10 @@ class OscarCheckConfigCommand extends OscarCommandAbstract
        }
        $io->writeln("<green>OK</green>");

        $logPath = $oscarConfig->getLoggerFilePath();
        $io->write(" - Fichier de LOG (<bold>$logPath</bold>) :  ");
        $logPath = $oscarConfig->getLoggerDirPath();
        $io->write(" - Dossier de LOG (<bold>$logPath</bold>) :  ");
        if (!is_writable($logPath)) {
            $io->error("Le fichier de log n'est pas éditable");
            $io->error("Le dossier de log n'est pas éditable");
            return self::FAILURE;
        }
        $io->writeln("<green>OK</green>");
@@ -445,7 +449,7 @@ class OscarCheckConfigCommand extends OscarCommandAbstract

        // On teste la présence du worker
        $oscarWorkerFile = __DIR__ . '/../../../../../config/oscarworker.service';
        if (!file_exists($oscarWorkerFile)) {
        if (!$docker && !file_exists($oscarWorkerFile)) {
            $io->error("Le fichier OscarWorker est absent (config/oscarworker.service)");
            return self::FAILURE;
        }
@@ -490,7 +494,6 @@ class OscarCheckConfigCommand extends OscarCommandAbstract
            $ldap->searchEntries(sprintf($options['default']['accountFilterFormat'], "test"));

            $io->writeln("Connexion au serveur LDAP <green>OK</green>\n");

        } catch (\Exception $e) {
            $io->error(
                "LDAP FAIL, Impossible de se connecter au serveur LDAP : \n Erreur : " . $e
+8 −0
Original line number Diff line number Diff line
@@ -169,6 +169,14 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
        return $this->getOptionalConfiguration('log_path', __DIR__ . '/../../../../../logs/oscar.log');
    }

    /**
     * @return string
     */
    public function getLoggerDirPath(): string
    {
        return $this->getOptionalConfiguration('log_dir', __DIR__ . '/../../../../../logs');
    }

    /**
     * @return string
     */