Пример #1
0
        public void AddConfigServerClientSettings_ChangesDataDictionary()
        {
            // Arrange
            ConfigServerClientSettings settings = new ConfigServerClientSettings
            {
                AccessTokenUri       = "http://foo.bar/",
                ClientId             = "client_id",
                ClientSecret         = "client_secret",
                Enabled              = true,
                Environment          = "environment",
                FailFast             = false,
                Label                = "label",
                Name                 = "name",
                Password             = "******",
                Uri                  = "http://foo.bar/",
                Username             = "******",
                ValidateCertificates = false,
                Token                = "vaulttoken",
                TokenRenewRate       = 1,
                TokenTtl             = 2
            };
            ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(settings);

            // Act and Assert
            provider.AddConfigServerClientSettings();

            Assert.True(provider.TryGet("spring:cloud:config:access_token_uri", out string value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:client_id", out value));
            Assert.Equal("client_id", value);
            Assert.True(provider.TryGet("spring:cloud:config:client_secret", out value));
            Assert.Equal("client_secret", value);
            Assert.True(provider.TryGet("spring:cloud:config:env", out value));
            Assert.Equal("environment", value);
            Assert.True(provider.TryGet("spring:cloud:config:label", out value));
            Assert.Equal("label", value);
            Assert.True(provider.TryGet("spring:cloud:config:name", out value));
            Assert.Equal("name", value);
            Assert.True(provider.TryGet("spring:cloud:config:password", out value));
            Assert.Equal("password", value);
            Assert.True(provider.TryGet("spring:cloud:config:uri", out value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:username", out value));
            Assert.Equal("username", value);

            Assert.True(provider.TryGet("spring:cloud:config:enabled", out value));
            Assert.Equal("True", value);
            Assert.True(provider.TryGet("spring:cloud:config:failFast", out value));
            Assert.Equal("False", value);
            Assert.True(provider.TryGet("spring:cloud:config:validate_certificates", out value));
            Assert.Equal("False", value);
            Assert.True(provider.TryGet("spring:cloud:config:token", out value));
            Assert.Equal("vaulttoken", value);
            Assert.True(provider.TryGet("spring:cloud:config:timeout", out value));
            Assert.Equal("6000", value);
            Assert.True(provider.TryGet("spring:cloud:config:tokenRenewRate", out value));
            Assert.Equal("1", value);
            Assert.True(provider.TryGet("spring:cloud:config:tokenTtl", out value));
            Assert.Equal("2", value);
        }
        public void AddConfigServerClientSettings_ChangesDataDictionary()
        {
            // Arrange
            IHostingEnvironment        env      = new HostingEnvironment();
            ConfigServerClientSettings settings = new ConfigServerClientSettings();

            settings.AccessTokenUri       = "http://foo.bar/";
            settings.ClientId             = "client_id";
            settings.ClientSecret         = "client_secret";
            settings.Enabled              = true;
            settings.Environment          = "environment";
            settings.FailFast             = false;
            settings.Label                = "label";
            settings.Name                 = "name";
            settings.Password             = "******";
            settings.Uri                  = "http://foo.bar/";
            settings.Username             = "******";
            settings.ValidateCertificates = false;
            ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(settings, env);


            // Act and Assert
            provider.AddConfigServerClientSettings();

            string value;

            Assert.True(provider.TryGet("spring:cloud:config:access_token_uri", out value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:client_id", out value));
            Assert.Equal("client_id", value);
            Assert.True(provider.TryGet("spring:cloud:config:client_secret", out value));
            Assert.Equal("client_secret", value);
            Assert.True(provider.TryGet("spring:cloud:config:env", out value));
            Assert.Equal("environment", value);
            Assert.True(provider.TryGet("spring:cloud:config:label", out value));
            Assert.Equal("label", value);
            Assert.True(provider.TryGet("spring:cloud:config:name", out value));
            Assert.Equal("name", value);
            Assert.True(provider.TryGet("spring:cloud:config:password", out value));
            Assert.Equal("password", value);
            Assert.True(provider.TryGet("spring:cloud:config:uri", out value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:username", out value));
            Assert.Equal("username", value);

            Assert.True(provider.TryGet("spring:cloud:config:enabled", out value));
            Assert.Equal("True", value);
            Assert.True(provider.TryGet("spring:cloud:config:failFast", out value));
            Assert.Equal("False", value);
            Assert.True(provider.TryGet("spring:cloud:config:validate_certificates", out value));
            Assert.Equal("False", value);
        }
        public void AddConfigServerClientSettings_ChangesDataDictionary()
        {
            // Arrange
            ConfigServerClientSettings settings = new ConfigServerClientSettings();

            settings.Enabled              = true;
            settings.Environment          = "environment";
            settings.FailFast             = false;
            settings.Label                = "label";
            settings.Name                 = "name";
            settings.Password             = "******";
            settings.Uri                  = "http://foo.bar/";
            settings.Username             = "******";
            settings.ValidateCertificates = false;
            settings.Token                = "vaulttoken";
            ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(settings);

            // Act and Assert
            provider.AddConfigServerClientSettings();

            string value;

            Assert.True(provider.TryGet("spring:cloud:config:env", out value));
            Assert.Equal("environment", value);
            Assert.True(provider.TryGet("spring:cloud:config:label", out value));
            Assert.Equal("label", value);
            Assert.True(provider.TryGet("spring:cloud:config:name", out value));
            Assert.Equal("name", value);
            Assert.True(provider.TryGet("spring:cloud:config:password", out value));
            Assert.Equal("password", value);
            Assert.True(provider.TryGet("spring:cloud:config:uri", out value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:username", out value));
            Assert.Equal("username", value);

            Assert.True(provider.TryGet("spring:cloud:config:enabled", out value));
            Assert.Equal("True", value);
            Assert.True(provider.TryGet("spring:cloud:config:failFast", out value));
            Assert.Equal("False", value);
            Assert.True(provider.TryGet("spring:cloud:config:validate_certificates", out value));
            Assert.Equal("False", value);
            Assert.True(provider.TryGet("spring:cloud:config:token", out value));
            Assert.Equal("vaulttoken", value);
            Assert.True(provider.TryGet("spring:cloud:config:timeout", out value));
            Assert.Equal("6000", value);
        }
        public void AddConfigServerClientSettings_ChangesDataDictionary()
        {
            // Arrange
            var settings = new ConfigServerClientSettings
            {
                AccessTokenUri       = "https://foo.bar/",
                ClientId             = "client_id",
                ClientSecret         = "client_secret",
                Enabled              = true,
                Environment          = "environment",
                FailFast             = false,
                Label                = "label",
                Name                 = "name",
                Password             = "******",
                Uri                  = "https://foo.bar/",
                Username             = "******",
                ValidateCertificates = false,
                Token                = "vaulttoken",
                TokenRenewRate       = 1,
                TokenTtl             = 2,
                RetryMultiplier      = 1.1
            };

            var provider       = new ConfigServerConfigurationProvider(settings);
            var initialCulture = GetAndSetCurrentCulture(new CultureInfo("ru-RU"));

            try
            {
                // Act and Assert
                provider.AddConfigServerClientSettings();

                Assert.True(provider.TryGet("spring:cloud:config:access_token_uri", out var value));
                Assert.Equal("https://foo.bar/", value);
                Assert.True(provider.TryGet("spring:cloud:config:client_id", out value));
                Assert.Equal("client_id", value);
                Assert.True(provider.TryGet("spring:cloud:config:client_secret", out value));
                Assert.Equal("client_secret", value);
                Assert.True(provider.TryGet("spring:cloud:config:env", out value));
                Assert.Equal("environment", value);
                Assert.True(provider.TryGet("spring:cloud:config:label", out value));
                Assert.Equal("label", value);
                Assert.True(provider.TryGet("spring:cloud:config:name", out value));
                Assert.Equal("name", value);
                Assert.True(provider.TryGet("spring:cloud:config:password", out value));
                Assert.Equal("password", value);
                Assert.True(provider.TryGet("spring:cloud:config:uri", out value));
                Assert.Equal("https://foo.bar/", value);
                Assert.True(provider.TryGet("spring:cloud:config:username", out value));
                Assert.Equal("username", value);

                Assert.True(provider.TryGet("spring:cloud:config:enabled", out value));
                Assert.Equal("True", value);
                Assert.True(provider.TryGet("spring:cloud:config:failFast", out value));
                Assert.Equal("False", value);
                Assert.True(provider.TryGet("spring:cloud:config:validate_certificates", out value));
                Assert.Equal("False", value);
                Assert.True(provider.TryGet("spring:cloud:config:token", out value));
                Assert.Equal("vaulttoken", value);
                Assert.True(provider.TryGet("spring:cloud:config:timeout", out value));
                Assert.Equal("6000", value);
                Assert.True(provider.TryGet("spring:cloud:config:tokenRenewRate", out value));
                Assert.Equal("1", value);
                Assert.True(provider.TryGet("spring:cloud:config:tokenTtl", out value));
                Assert.Equal("2", value);
                Assert.True(provider.TryGet("spring:cloud:config:discovery:enabled", out value));
                Assert.Equal("False", value);
                Assert.True(provider.TryGet("spring:cloud:config:discovery:serviceId", out value));
                Assert.Equal(ConfigServerClientSettings.DEFAULT_CONFIGSERVER_SERVICEID, value);
                Assert.True(provider.TryGet("spring:cloud:config:retry:multiplier", out value));
                Assert.Equal("1.1", value);
            }
            finally
            {
                GetAndSetCurrentCulture(initialCulture);
            }
        }
        public void AddConfigServerClientSettings_ChangesDataDictionary()
        {
            // Arrange
            ConfigServerClientSettings settings = new ConfigServerClientSettings();
            settings.AccessTokenUri = "http://foo.bar/";
            settings.ClientId = "client_id";
            settings.ClientSecret = "client_secret";
            settings.Enabled = true;
            settings.Environment = "environment";
            settings.FailFast = false;
            settings.Label = "label";
            settings.Name = "name";
            settings.Password = "******";
            settings.Uri = "http://foo.bar/";
            settings.Username = "******";
            settings.ValidateCertificates = false;
            ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider();


            // Act and Assert
            provider.AddConfigServerClientSettings(settings);

            string value;
            Assert.True(provider.TryGet("spring:cloud:config:access_token_uri", out value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:client_id", out value));
            Assert.Equal("client_id", value);
            Assert.True(provider.TryGet("spring:cloud:config:client_secret", out value));
            Assert.Equal("client_secret", value);
            Assert.True(provider.TryGet("spring:cloud:config:env", out value));
            Assert.Equal("environment", value);
            Assert.True(provider.TryGet("spring:cloud:config:label", out value));
            Assert.Equal("label", value);
            Assert.True(provider.TryGet("spring:cloud:config:name", out value));
            Assert.Equal("name", value);
            Assert.True(provider.TryGet("spring:cloud:config:password", out value));
            Assert.Equal("password", value);
            Assert.True(provider.TryGet("spring:cloud:config:uri", out value));
            Assert.Equal("http://foo.bar/", value);
            Assert.True(provider.TryGet("spring:cloud:config:username", out value));
            Assert.Equal("username", value);

            Assert.True(provider.TryGet("spring:cloud:config:enabled", out value));
            Assert.Equal("True", value);
            Assert.True(provider.TryGet("spring:cloud:config:failFast", out value));
            Assert.Equal("False", value);
            Assert.True(provider.TryGet("spring:cloud:config:validate_certificates", out value));
            Assert.Equal("False", value);

        }