/*
   Copyright (c) 2018-2019 Nokia.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

/*
 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
 * platform project (RICP).
*/

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <memory>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include "private/configurationreader.hpp"
#include "private/createlogger.hpp"
#include "private/logger.hpp"
#include "private/tst/databaseconfigurationmock.hpp"
#include "private/tst/gettopsrcdir.hpp"
#include "private/tst/namespaceconfigurationsmock.hpp"
#include "private/tst/systemmock.hpp"

using namespace shareddatalayer;
using namespace shareddatalayer::tst;
using namespace testing;

namespace
{
    class ConfigurationReaderBaseTest: public testing::Test
    {
    public:
        const std::string someKnownInputSource;
        const Directories noDirectories;
        DatabaseConfigurationMock databaseConfigurationMock;
        NamespaceConfigurationsMock namespaceConfigurationsMock;
        std::unique_ptr<ConfigurationReader> configurationReader;
        SystemMock systemMock;
        std::shared_ptr<Logger> logger;

        ConfigurationReaderBaseTest(std::string inputSourceName):
            someKnownInputSource(inputSourceName),
            logger(createLogger(SDL_LOG_PREFIX))
        {
            EXPECT_CALL(databaseConfigurationMock, isEmpty()).WillRepeatedly(Return(true));
            EXPECT_CALL(namespaceConfigurationsMock, isEmpty()).WillRepeatedly(Return(true));
        }

        void expectDbTypeConfigurationCheckAndApply(const std::string& type)
        {
            EXPECT_CALL(databaseConfigurationMock, checkAndApplyDbType(type));
        }

        void expectDBServerAddressConfigurationCheckAndApply(const std::string& address)
        {
            EXPECT_CALL(databaseConfigurationMock, checkAndApplyServerAddress(address));
        }

        void expectSentinelAddressConfigurationCheckAndApply(const std::string& address)
        {
            EXPECT_CALL(databaseConfigurationMock, checkAndApplySentinelAddress(address));
        }

        void expectSentinelMasterNameConfigurationCheckAndApply(const std::string& address)
        {
            EXPECT_CALL(databaseConfigurationMock, checkAndApplySentinelMasterName(address));
        }

        void expectDatabaseConfigurationIsEmpty_returnFalse()
        {
            EXPECT_CALL(databaseConfigurationMock, isEmpty()).
                WillOnce(Return(false));
        }

        void tryToReadDatabaseConfigurationToNonEmptyContainer()
        {
            expectDatabaseConfigurationIsEmpty_returnFalse();
            configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
        }

        void expectNamespaceConfigurationIsEmpty_returnFalse()
        {
            EXPECT_CALL(namespaceConfigurationsMock, isEmpty()).
                WillOnce(Return(false));
        }

        void tryToReadNamespaceConfigurationToNonEmptyContainer()
        {
            expectNamespaceConfigurationIsEmpty_returnFalse();
            configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
        }

        void expectAddNamespaceConfiguration(const std::string&  namespacePrefix, bool useDbBackend,
                                             bool enableNotifications)
        {
            NamespaceConfiguration expectedNamespaceConfiguration{namespacePrefix, useDbBackend,
                                                                  enableNotifications,
                                                                  someKnownInputSource};
            EXPECT_CALL(namespaceConfigurationsMock, addNamespaceConfiguration(expectedNamespaceConfiguration));
        }

        void expectGetEnvironmentString(const char* returnValue)
        {
            EXPECT_CALL(systemMock, getenv(_))
                .WillOnce(Return(returnValue));
        }

        void initializeReaderWithoutDirectories()
        {
            configurationReader.reset(new ConfigurationReader(noDirectories, systemMock, logger));
        }

        void initializeReaderWithSDLconfigFileDirectory()
        {
            configurationReader.reset(new ConfigurationReader({getTopSrcDir() + "/conf"}, systemMock, logger));
        }
    };

    class ConfigurationReaderSDLConfigFileTest: public ConfigurationReaderBaseTest
    {
    public:

        ConfigurationReaderSDLConfigFileTest():
            ConfigurationReaderBaseTest("ConfFileFromSDLrepo")
        {
            expectGetEnvironmentString(nullptr);
            initializeReaderWithSDLconfigFileDirectory();
        }
    };

    class ConfigurationReaderInputStreamTest: public ConfigurationReaderBaseTest
    {
    public:

        ConfigurationReaderInputStreamTest():
            ConfigurationReaderBaseTest("<istream>")
        {
            expectGetEnvironmentString(nullptr);
            initializeReaderWithoutDirectories();
        }

        void readConfigurationAndExpectJsonParserException(const std::istringstream& is)
        {
            const std::string expectedError("error in SDL configuration <istream> at line 7: expected ':'");

            EXPECT_THROW( {
                try
                {
                    configurationReader->readConfigurationFromInputStream(is);
                    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
                    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
                }
                catch (const std::exception& e)
                {
                    EXPECT_EQ(expectedError, e.what());
                    throw;
                }
            }, Exception);
        }

        void readConfigurationAndExpectBadValueException(const std::istringstream& is,
                                                         const std::string& param)
        {
            std::ostringstream os;
            os << "Configuration error in " << someKnownInputSource << ": "
               << "invalid \"" << param << "\": \"bad-value\"";

            EXPECT_THROW( {
                try
                {
                    configurationReader->readConfigurationFromInputStream(is);
                    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
                    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
                }
                catch (const std::exception& e)
                {
                    EXPECT_EQ(os.str(), e.what());
                    throw;
                }
            }, Exception);
        }

        void readConfigurationAndExpectDbTypeException(const std::istringstream& is)
        {
            std::ostringstream os;
            os << "Configuration error in " << someKnownInputSource << ": some error";

            EXPECT_CALL(databaseConfigurationMock, checkAndApplyDbType(_))
                .WillOnce(Throw(Exception("some error")));

            EXPECT_THROW( {
                try
                {
                    configurationReader->readConfigurationFromInputStream(is);
                    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
                }
                catch (const std::exception& e)
                {
                    EXPECT_EQ(os.str(), e.what());
                    throw;
                }
            }, Exception);
        }

        void readConfigurationAndExpectAddressException(const std::istringstream& is,
                                                        const std::string& addressValue)
        {
            std::ostringstream os;
            os << "Configuration error in " << someKnownInputSource << ": "
               << "invalid \"address\": \"" << addressValue << "\" some error";

            EXPECT_CALL(databaseConfigurationMock, checkAndApplyServerAddress(_))
                .WillOnce(Throw(Exception("some error")));

            EXPECT_THROW( {
                try
                {
                    configurationReader->readConfigurationFromInputStream(is);
                    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
                }
                catch (const std::exception& e)
                {
                    EXPECT_EQ(os.str(), e.what());
                    throw;
                }
            }, Exception);
        }

        void readConfigurationAndExpectMissingParameterException(const std::istringstream& is, const std::string& param)
        {
            std::ostringstream os;
            os << "Configuration error in " << someKnownInputSource << ": "
               << "missing \"" << param << "\"";

            EXPECT_THROW( {
                try
                {
                    configurationReader->readConfigurationFromInputStream(is);
                    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
                    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
                }
                catch (const std::exception& e)
                {
                    EXPECT_EQ(os.str(), e.what());
                    throw;
                }
            }, Exception);
        }

        void readConfigurationAndExpectNamespacePrefixValidationException(const std::istringstream& is,
                                                                          const std::string& namespacePrefix)
        {
            std::ostringstream os;
            os << "Configuration error in " << someKnownInputSource << ": "
               << "\"namespacePrefix\": \"" << namespacePrefix << "\""
               << " contains some of these disallowed characters: ,{}";

            EXPECT_THROW( {
                try
                {
                    configurationReader->readConfigurationFromInputStream(is);
                    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
                }
                catch (const std::exception& e)
                {
                    EXPECT_EQ(os.str(), e.what() );
                    throw;
                }
            }, Exception);
        }

        void readConfigurationAndExpectEnableNotificationsValidationException(const std::istringstream& is)
        {
            std::ostringstream os;
            os << "Configuration error in " << someKnownInputSource << ": "
               << "\"enableNotifications\" cannot be true, when \"useDbBackend\" is false";

            EXPECT_THROW( {
                try
                {
                    configurationReader->readConfigurationFromInputStream(is);
                    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
                }
                catch (const std::exception& e)
                {
                    EXPECT_EQ(os.str(), e.what() );
                    throw;
                }
            }, Exception);
        }

    };
}

TEST_F(ConfigurationReaderInputStreamTest, CanReadJSONDatabaseConfiguration)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "database":
            {
                "type": "redis-standalone",
                "servers":
                [
                    {
                        "address": "someKnownDbAddress:65535"
                    }
                ]
            }
        })JSON");
    expectDbTypeConfigurationCheckAndApply("redis-standalone");
    expectDBServerAddressConfigurationCheckAndApply("someKnownDbAddress:65535");
    configurationReader->readConfigurationFromInputStream(is);
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
}

TEST_F(ConfigurationReaderInputStreamTest, CanReadJSONDatabaseConfigurationWithMultipleServerAddresses)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "database":
            {
                "type": "redis-cluster",
                "servers":
                [
                    {
                        "address": "10.20.30.40:50000"
                    },
                    {
                        "address": "10.20.30.50:50001"
                    }
                ]
            }
        })JSON");

    expectDbTypeConfigurationCheckAndApply("redis-cluster");
    expectDBServerAddressConfigurationCheckAndApply("10.20.30.40:50000");
    expectDBServerAddressConfigurationCheckAndApply("10.20.30.50:50001");
    configurationReader->readConfigurationFromInputStream(is);
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
}

TEST_F(ConfigurationReaderInputStreamTest, CanReadJSONDatabaseConfigurationWithMultipleReadOperations)
{
    InSequence dummy;
    std::istringstream isOne(R"JSON(
        {
            "database":
            {
                "type": "redis-cluster",
                "servers":
                [
                    {
                        "address": "10.20.30.40:50000"
                    }
                ]
            }
        })JSON");
    std::istringstream isTwo(R"JSON(
        {
            "database":
            {
                "type": "redis-cluster",
                "servers":
                [
                    {
                        "address": "10.20.30.50:50001"
                    }
                ]
            }
        })JSON");

    expectDbTypeConfigurationCheckAndApply("redis-cluster");
    expectDBServerAddressConfigurationCheckAndApply("10.20.30.40:50000");
    expectDbTypeConfigurationCheckAndApply("redis-cluster");
    expectDBServerAddressConfigurationCheckAndApply("10.20.30.50:50001");
    configurationReader->readConfigurationFromInputStream(isOne);
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
    configurationReader->readConfigurationFromInputStream(isTwo);
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowMisingMandatoryDatabaseTypeParameter)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "database":
            {
                "servers":
                [
                    {
                        "address": "10.20.30.50:50001"
                    }
                ]
            }
        })JSON");

    readConfigurationAndExpectMissingParameterException(is, "type");
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowMisingMandatoryDatabaseServersArray)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "database":
            {
                "type": "redis-standalone"
            }
        })JSON");

    expectDbTypeConfigurationCheckAndApply("redis-standalone");
    readConfigurationAndExpectMissingParameterException(is, "servers");
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowMisingMandatoryDatabaseServerAddressParameter)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "database":
            {
                "type": "redis-standalone",
                "servers":
                [
                    {
                    }
                ]
            }
        })JSON");

    expectDbTypeConfigurationCheckAndApply("redis-standalone");
    readConfigurationAndExpectMissingParameterException(is, "address");
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowDatabaseConfigurationDbTypeError)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "database":
            {
                "type": "someBadType",
                "servers":
                [
                    {
                        "address": "10.20.30.50:50001"
                    }
                ]
            }
        })JSON");

    readConfigurationAndExpectDbTypeException(is);
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowDatabaseConfigurationAddressError)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "database":
            {
                "type": "redis-standalone",
                "servers":
                [
                    {
                        "address": "someBadAddress"
                    }
                ]
            }
        })JSON");

    expectDbTypeConfigurationCheckAndApply("redis-standalone");
    readConfigurationAndExpectAddressException(is, "someBadAddress");
}

TEST_F(ConfigurationReaderInputStreamTest, CanHandleJSONWithoutAnyConfiguration)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
        })JSON");

    EXPECT_CALL(databaseConfigurationMock, checkAndApplyServerAddress(_))
        .Times(0);
    EXPECT_CALL(namespaceConfigurationsMock, addNamespaceConfiguration(_))
        .Times(0);
    configurationReader->readConfigurationFromInputStream(is);
}

TEST_F(ConfigurationReaderInputStreamTest, CanReadJSONSharedDataLayerConfiguration)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "someKnownNamespacePrefix",
                    "useDbBackend": true,
                    "enableNotifications": true
                },
                {
                    "namespacePrefix": "anotherKnownNamespace",
                    "useDbBackend": false,
                    "enableNotifications": false
                }
            ]
        })JSON");

    expectAddNamespaceConfiguration("anotherKnownNamespace", false, false);
    expectAddNamespaceConfiguration("someKnownNamespacePrefix", true, true);
    configurationReader->readConfigurationFromInputStream(is);
    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
}

TEST_F(ConfigurationReaderInputStreamTest, CanReadJSONSharedDataLayerConfigurationWithMultipleReadOperations)
{
    InSequence dummy;
    std::istringstream isOne(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "someKnownNamespacePrefix",
                    "useDbBackend": true,
                    "enableNotifications": true
                }
            ]
        })JSON");

    std::istringstream isTwo(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "anotherKnownNamespace",
                    "useDbBackend": false,
                    "enableNotifications": false
                }
            ]
        })JSON");

    expectAddNamespaceConfiguration("someKnownNamespacePrefix", true, true);
    expectAddNamespaceConfiguration("anotherKnownNamespace", false, false);
    configurationReader->readConfigurationFromInputStream(isOne);
    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
    configurationReader->readConfigurationFromInputStream(isTwo);
    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
}

TEST_F(ConfigurationReaderInputStreamTest, CanReadJSONSharedDataLayerConfigurationWithEmptyNamespacePrefixValue)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "",
                    "useDbBackend": false,
                    "enableNotifications": false
                }
            ]
        })JSON");

    expectAddNamespaceConfiguration("", false, false);
    configurationReader->readConfigurationFromInputStream(is);
    configurationReader->readNamespaceConfigurations(namespaceConfigurationsMock);
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowJSONSyntaxError)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "abc"
                }
            ]
        })JSON");

    readConfigurationAndExpectJsonParserException(is);
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowParameterUseDbBackendBadValue)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "someKnownNamespacePrefix",
                    "useDbBackend": "bad-value",
                    "enableNotifications": false
                }
            ]
        })JSON");

    readConfigurationAndExpectBadValueException(is, "useDbBackend");
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowParameterEnableNotificationsBadValue)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "someKnownNamespacePrefix",
                    "useDbBackend": true,
                    "enableNotifications": "bad-value"
                }
            ]
        })JSON");

    readConfigurationAndExpectBadValueException(is, "enableNotifications");
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowMisingMandatoryNamespacePrefixParameter)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "useDbBackend": true,
                    "enableNotifications": true
                }
            ]
        })JSON");

    readConfigurationAndExpectMissingParameterException(is, "namespacePrefix");
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowMisingMandatoryUseDbBackendParameter)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "someKnownNamespacePrefix",
                    "enableNotifications": true
                }
            ]
        })JSON");

    readConfigurationAndExpectMissingParameterException(is, "useDbBackend");
}

TEST_F(ConfigurationReaderInputStreamTest, CanCatchAndThrowMisingMandatoryEnableNotificationsParameter)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "someKnownNamespacePrefix",
                    "useDbBackend": true
                }
            ]
        })JSON");

    readConfigurationAndExpectMissingParameterException(is, "enableNotifications");
}

TEST_F(ConfigurationReaderInputStreamTest, CanThrowValidationErrorForNamespacePrefixWithDisallowedCharacters)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "a,b{c}",
                    "useDbBackend": true,
                    "enableNotifications": true
                }
            ]
        })JSON");

    readConfigurationAndExpectNamespacePrefixValidationException(is, "a,b{c}");
}

TEST_F(ConfigurationReaderInputStreamTest, CanThrowValidationErrorForEnableNotificationsWithNoDbBackend)
{
    InSequence dummy;
    std::istringstream is(R"JSON(
        {
            "sharedDataLayer":
            [
                {
                    "namespacePrefix": "someKnownNamespacePrefix",
                    "useDbBackend": false,
                    "enableNotifications": true
                }
            ]
        })JSON");

    readConfigurationAndExpectEnableNotificationsValidationException(is);
}

TEST_F(ConfigurationReaderInputStreamTest, WillNotReadDatabaseConfigurationToNonEmptyContainer)
{
    EXPECT_EXIT(tryToReadDatabaseConfigurationToNonEmptyContainer(),
        KilledBySignal(SIGABRT), "ABORT.*configurationreader\\.cpp");
}

TEST_F(ConfigurationReaderInputStreamTest, WillNotReadNamespaceConfigurationToNonEmptyContainer)
{
    EXPECT_EXIT(tryToReadNamespaceConfigurationToNonEmptyContainer(),
        KilledBySignal(SIGABRT), "ABORT.*configurationreader\\.cpp");
}

class ConfigurationReaderEnvironmentVariableTest: public ConfigurationReaderBaseTest
{
public:
    std::string dbHostEnvVariableValue;
    std::string dbPortEnvVariableValue;
    std::string sentinelPortEnvVariableValue;
    std::string sentinelMasterNameEnvVariableValue;
    std::istringstream is{R"JSON(
        {
            "database":
            {
                "type": "redis-cluster",
                "servers":
                [
                    {
                        "address": "10.20.30.40:50000"
                    },
                    {
                        "address": "10.20.30.50:50001"
                    }
                ]
            }
        })JSON"};

    ConfigurationReaderEnvironmentVariableTest():
        ConfigurationReaderBaseTest(DB_HOST_ENV_VAR_NAME)
    {
    }

    void readEnvironmentConfigurationAndExpectConfigurationErrorException()
    {
        std::ostringstream os;
        os << "Configuration error in " << someKnownInputSource << ": some error";

        EXPECT_CALL(databaseConfigurationMock, checkAndApplyDbType(_))
            .WillOnce(Throw(Exception("some error")));

        EXPECT_THROW( {
            try
            {
                EXPECT_CALL(systemMock, getenv(_))
                    .Times(4)
                    .WillOnce(Return(dbHostEnvVariableValue.c_str()))
                    .WillOnce(Return(nullptr));
                initializeReaderWithoutDirectories();
                configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
            }
            catch (const std::exception& e)
            {
                EXPECT_EQ(os.str(), e.what());
                throw;
            }
        }, Exception);
    }
};

TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationCanOverrideJSONDatabaseConfiguration)
{
    InSequence dummy;
    dbHostEnvVariableValue = "unknownAddress.local";
    expectGetEnvironmentString(dbHostEnvVariableValue.c_str());
    dbPortEnvVariableValue = "12345";
    expectGetEnvironmentString(dbPortEnvVariableValue.c_str());
    expectGetEnvironmentString(nullptr); //SENTINEL_PORT_ENV_VAR_NAME
    expectGetEnvironmentString(nullptr); //SENTINEL_MASTER_NAME_ENV_VAR_NAME

    expectDbTypeConfigurationCheckAndApply("redis-standalone");
    expectDBServerAddressConfigurationCheckAndApply("unknownAddress.local:12345");
    initializeReaderWithSDLconfigFileDirectory();
    configurationReader->readConfigurationFromInputStream(is);
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
}

TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationWithoutPortIsAccepted)
{
    InSequence dummy;
    dbHostEnvVariableValue = "server.local";
    expectGetEnvironmentString(dbHostEnvVariableValue.c_str());
    expectGetEnvironmentString(nullptr); //DB_PORT_ENV_VAR_NAME
    expectGetEnvironmentString(nullptr); //SENTINEL_PORT_ENV_VAR_NAME
    expectGetEnvironmentString(nullptr); //SENTINEL_MASTER_NAME_ENV_VAR_NAME

    expectDbTypeConfigurationCheckAndApply("redis-standalone");
    expectDBServerAddressConfigurationCheckAndApply("server.local");
    initializeReaderWithoutDirectories();
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
}

TEST_F(ConfigurationReaderEnvironmentVariableTest, EmptyEnvironmentVariableThrows)
{
    dbHostEnvVariableValue = "";
    readEnvironmentConfigurationAndExpectConfigurationErrorException();
}

TEST_F(ConfigurationReaderEnvironmentVariableTest, IllegalCharacterInEnvironmentVariableThrows)
{
    dbHostEnvVariableValue = "@";
    readEnvironmentConfigurationAndExpectConfigurationErrorException();
}

TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationAcceptIPv6Address)
{
    InSequence dummy;
    dbHostEnvVariableValue = "[2001::123]:12345";
    expectGetEnvironmentString(dbHostEnvVariableValue.c_str());
    expectGetEnvironmentString(nullptr); //DB_PORT_ENV_VAR_NAME
    expectGetEnvironmentString(nullptr); //SENTINEL_PORT_ENV_VAR_NAME
    expectGetEnvironmentString(nullptr); //SENTINEL_MASTER_NAME_ENV_VAR_NAME

    expectDbTypeConfigurationCheckAndApply("redis-standalone");
    expectDBServerAddressConfigurationCheckAndApply("[2001::123]:12345");
    initializeReaderWithoutDirectories();
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
}

TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationWithSentinel)
{
    InSequence dummy;
    dbHostEnvVariableValue = "sentinelAddress.local";
    expectGetEnvironmentString(dbHostEnvVariableValue.c_str());
    dbPortEnvVariableValue = "1111";
    expectGetEnvironmentString(dbPortEnvVariableValue.c_str());
    sentinelPortEnvVariableValue = "2222";
    expectGetEnvironmentString(sentinelPortEnvVariableValue.c_str());
    sentinelMasterNameEnvVariableValue = "mymaster";
    expectGetEnvironmentString(sentinelMasterNameEnvVariableValue.c_str());

    expectDbTypeConfigurationCheckAndApply("redis-sentinel");
    expectSentinelAddressConfigurationCheckAndApply("sentinelAddress.local:2222");
    expectSentinelMasterNameConfigurationCheckAndApply(sentinelMasterNameEnvVariableValue);
    initializeReaderWithoutDirectories();
    configurationReader->readDatabaseConfiguration(databaseConfigurationMock);
}
