Exemplo n.º 1
0
        public async Task TcpCheckAttribute_IsInvalidPortValue()
        {
            const string host = "127.0.0.1";
            const int    port = 5672;

            var settings = await SettingsProcessor.ProcessAsync <TestTcpCheckModel>($"{{'HostInfo': {{'HostPort': '{host}:{port}'}} }}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Contains("Failed", message);

            settings = await SettingsProcessor.ProcessAsync <TestTcpCheckModel>($"{{'Host': '{host}', 'Port': 'not a port'}}");

            message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.NotNull(message);
            Assert.Equal($"Check of the 'Host' field value [{host}] is failed: Invalid port value in property 'Port'", message);

            settings = await SettingsProcessor.ProcessAsync <TestTcpCheckModel>($"{{'Host': '{host}', 'Port': '{port}'}}");

            message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Contains("Failed", message);

            settings = await SettingsProcessor.ProcessAsync <TestTcpCheckModel>($"{{'Server': '{host}'}}");

            message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Contains("Failed", message);
        }
Exemplo n.º 2
0
        public async Task AmqpCheckAttribute_IsInvalidConnectionString()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestAmqpCheckModel>(
                "{'ConnStr': 'amqp://*****:*****@localhost:5672', 'Rabbit': {'ConnString': 'rabbit-registration.lykke-service.svc.cluster.local:5672'}}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Contains("Failed", message);
        }
Exemplo n.º 3
0
        public async Task TcpCheckAttribute_WrongPortProperty()
        {
            var settings = await SettingsProcessor.ProcessAsync <WrongTestTcpCheckModel>("{'Host': '127.0.0.1', 'Port': '5672'}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.NotNull(message);
            Assert.Equal("Check of the 'Host' field value [127.0.0.1] is failed: Property 'ServicePort' not found", message);
        }
Exemplo n.º 4
0
        public async Task HttpCheckAttribute_IsEmptyField()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestHttpCheckModel>(
                $"{{'Service': {{'ServiceUrl': '{ServiceUrl}'}}, 'Url': '', 'Port':5672, 'Num': 1234}}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Contains("Empty setting value", message);
        }
Exemplo n.º 5
0
        public async Task HttpCheckAttribute_IsInvalidUrl()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestHttpCheckModel>(
                $"{{'Service': {{'ServiceUrl': 'not_url_at_all'}}, 'Url': '{ServiceUrl}/', 'Port':5672, 'Num': 1234}}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Contains("Failed", message);
        }
Exemplo n.º 6
0
        public async Task HttpCheckAttribute_IsOk()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestHttpCheckModel>(
                $"{{'Service': {{'ServiceUrl': '{ServiceUrl}'}}, 'Url': '{ServiceUrl}', 'Port':5672, 'Num': 1234}}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Null(message);
        }
Exemplo n.º 7
0
        public async Task TcpCheckAttribute_IsInvalidPort()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestTcpCheckModel>(
                "{'HostInfo': {'HostPort': '127.0.0.1:zzz'}, 'Host': '127.0.0.1', 'Port': 5672, 'Server': '127.0.0.1'}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.NotNull(message);
            Assert.Contains("Invalid port", message);
        }
Exemplo n.º 8
0
        public async Task HttpCheckAttribute_IsListOk()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestHttpCheckListModel>(
                $"{{'Services': ['{ServiceUrl}'],'List': ['{ServiceUrl}'],'IList': ['{ServiceUrl}']," +
                $"'RoList': ['{ServiceUrl}'],'RoCollection': ['{ServiceUrl}'],'Enumerable': ['{ServiceUrl}']}}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Null(message);
        }
Exemplo n.º 9
0
        public async Task AmqpCheckAttribute_IsDictionaryOk()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestAmqpCheckDictionaryModel>("{'Rabbits': {'first': {'ConnString': 'amqp://*****:*****@localhost:5672'}}," +
                                                                                               "'IDict': {'first': {'ConnString': 'amqp://*****:*****@localhost:5672'}}," +

                                                                                               "'RoDict': {'first': {'ConnString': 'amqp://*****:*****@localhost:5672'}}}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Null(message);
        }
Exemplo n.º 10
0
        public async Task TcpCheckAttribute_IsDictionaryOk()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestTcpCheckDictionaryModel>("{'Endpoints': {'first': {'HostPort': '127.0.0.1:5672'}}," +
                                                                                              "'IDict': {'first': {'HostPort': '127.0.0.1:5672'}}," +

                                                                                              "'RoDict': {'first': {'HostPort': '127.0.0.1:5672'}}}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Null(message);
        }
Exemplo n.º 11
0
        public async Task HttpCheckAttribute_IsDictionaryOk()
        {
            var settings = await SettingsProcessor.ProcessAsync <TestHttpCheckDictioinaryModel>(
                $"{{'Services': {{'first': {{'ServiceUrl': '{ServiceUrl}'}} }}," +
                $"'IDict': {{'first': {{'ServiceUrl': '{ServiceUrl}'}} }}," +
                $"'RoDict': {{'first': {{'ServiceUrl': '{ServiceUrl}'}} }} }}");

            string message = await SettingsProcessor.CheckDependenciesAsync(settings);

            Assert.Null(message);
        }
Exemplo n.º 12
0
        protected override async Task <TSettings> Load()
        {
            Console.WriteLine($"{DateTime.UtcNow} Reading settings");

            var content = await File.ReadAllTextAsync(_settingsFilePath);

            var processingResult = await SettingsProcessor.ProcessForConfigurationAsync <TSettings>(content);

            var settings = processingResult.Item1;

            SetSettingsConfigurationRoot(processingResult.Item2);

            await SettingsProcessor.CheckDependenciesAsync(settings);

            return(settings);
        }
Exemplo n.º 13
0
        public async Task AmqpCheckAttribute_IsListOk()
        {
            var checkList = new List <(string, string)>
            {
                ("Rabbits", "amqp://*****:*****@localhost:5672"),
                ("List", "amqp://*****:*****@localhost:5672"),
                ("IList", "amqp://*****:*****@localhost:5672"),
                ("RoList", "amqp://*****:*****@localhost:5672"),
                ("RoCollection", "amqp://*****:*****@localhost:5672"),
                ("Enumerable", "amqp://*****:*****@localhost:5672")
            };

            foreach (var pair in checkList)
            {
                var settings = await SettingsProcessor.ProcessAsync <TestAmqpCheckListModel>($"{{'{pair.Item1}': ['{pair.Item2}'] }}");

                string message = await SettingsProcessor.CheckDependenciesAsync(settings);

                Assert.Contains("Failed", message);
            }
        }
Exemplo n.º 14
0
        public async Task TcpCheckAttribute_IsArrayOk()
        {
            var checkList = new List <(string, string)>
            {
                ("Endpoints", "127.0.0.1:5672"),
                ("List", "127.0.0.1:5672"),
                ("IList", "127.0.0.1:5672"),
                ("RoList", "127.0.0.1:5672"),
                ("RoCollection", "127.0.0.1:5672"),
                ("Enumerable", "127.0.0.1:5672")
            };

            foreach (var pair in checkList)
            {
                var settings = await SettingsProcessor.ProcessAsync <TestTcpCheckArrayModel>($"{{'{pair.Item1}': [{{'HostPort': '{pair.Item2}'}}] }}");

                string message = await SettingsProcessor.CheckDependenciesAsync(settings);

                Assert.Contains("Failed", message);
            }
        }