From 92a74654c40b575270be81441ee50b7b56d868c4 Mon Sep 17 00:00:00 2001 From: Roman Lumetsberger Date: Mon, 22 Mar 2021 10:04:21 +0100 Subject: [PATCH] change ini parser mode to raw to allow exlamation marks --- src/ConfigurationParser/ConfigurationParser.php | 2 +- tests/ConfigurationParser/ConfigurationParserTest.php | 4 ++-- .../SystemConfigurationParserTest.php | 10 +++++----- tests/ConfigurationParser/resources/general.cfg | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ConfigurationParser/ConfigurationParser.php b/src/ConfigurationParser/ConfigurationParser.php index d0f168e..2e1f1e9 100644 --- a/src/ConfigurationParser/ConfigurationParser.php +++ b/src/ConfigurationParser/ConfigurationParser.php @@ -22,7 +22,7 @@ public function __construct(string $fileName) if (!file_exists($fileName)) { throw new ConfigurationException(sprintf('Configuration file %s does not exist', $fileName)); } - $this->config = new \Config_Lite($fileName); + $this->config = new \Config_Lite($fileName,null,INI_SCANNER_RAW ); } /** diff --git a/tests/ConfigurationParser/ConfigurationParserTest.php b/tests/ConfigurationParser/ConfigurationParserTest.php index 60fe840..7555266 100644 --- a/tests/ConfigurationParser/ConfigurationParserTest.php +++ b/tests/ConfigurationParser/ConfigurationParserTest.php @@ -29,8 +29,8 @@ protected function setUp(): void public function testConfigurationIsReadFromFile() { $configuration = new ConfigurationParser(self::TEST_CONFIG_FILE); - $this->assertEquals('test', $configuration->get('TEST1', 'test')); - $this->assertEquals('test4', $configuration->get('TEST3', 'test4')); + $this->assertEquals('\'test\'', $configuration->get('TEST1', 'test')); + $this->assertEquals('\'test4\'', $configuration->get('TEST3', 'test4')); } public function testConfigurationThrowsExceptionIfFileDoesNotExist() diff --git a/tests/ConfigurationParser/SystemConfigurationParserTest.php b/tests/ConfigurationParser/SystemConfigurationParserTest.php index 2c891f4..f298706 100644 --- a/tests/ConfigurationParser/SystemConfigurationParserTest.php +++ b/tests/ConfigurationParser/SystemConfigurationParserTest.php @@ -76,7 +76,7 @@ public function regularValues() ['BINARIES', 'REBOOT', '/sbin/reboot'], ['BINARIES', 'NTPDATE', '/usr/sbin/ntpdate'], ['BINARIES', 'AWK', '/usr/bin/awk'], - ['MINISERVER1', 'PASS', 'test12345'], + ['MINISERVER1', 'PASS', 'test12345!'], ['MINISERVER1', 'IPADDRESS', '192.168.0.0'], ['MINISERVER1', 'ADMIN', 'Admin'], ['MINISERVER1', 'ENCRYPTRESPONSE', null], @@ -189,11 +189,11 @@ public function testLoadsMiniserverInformation() $this->assertFalse($miniserverByName->isSecureGateway()); $this->assertFalse($miniserverByName->isUseCloudDns()); $this->assertSame('Admin', $miniserverByName->getAdminUsername()); - $this->assertSame('test12345', $miniserverByName->getAdminPassword()); - $this->assertSame('Admin:test12345', $miniserverByName->getCredentials()); + $this->assertSame('test12345!', $miniserverByName->getAdminPassword()); + $this->assertSame('Admin:test12345!', $miniserverByName->getCredentials()); $this->assertSame('Admin', $miniserverByName->getAdminUsername(true)); - $this->assertSame('test12345', $miniserverByName->getAdminPassword(true)); - $this->assertSame('Admin:test12345', $miniserverByName->getCredentials(true)); + $this->assertSame('test12345!', $miniserverByName->getAdminPassword(true)); + $this->assertSame('Admin:test12345!', $miniserverByName->getCredentials(true)); $this->assertSame('', $miniserverByName->getCloudUrl()); $this->assertEquals(80, $miniserverByName->getPort()); } diff --git a/tests/ConfigurationParser/resources/general.cfg b/tests/ConfigurationParser/resources/general.cfg index bd5708e..48ee7c9 100644 --- a/tests/ConfigurationParser/resources/general.cfg +++ b/tests/ConfigurationParser/resources/general.cfg @@ -55,7 +55,7 @@ NTPDATE=/usr/sbin/ntpdate AWK=/usr/bin/awk [MINISERVER1] -PASS=test12345 +PASS=test12345! IPADDRESS=192.168.0.0 ADMIN=Admin ENCRYPTRESPONSE=