public async void RemoteLoadAsync_InvalidPath() { // Arrange IHostingEnvironment envir = new HostingEnvironment(); ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings(), envir); // Act and Assert InvalidOperationException ex = await Assert.ThrowsAsync <InvalidOperationException>(() => provider.RemoteLoadAsync("foobar\\foobar\\")); }
public async void RemoteLoadAsync_HostTimesout() { // Arrange IHostingEnvironment envir = new HostingEnvironment(); ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings(), envir); // Act and Assert HttpRequestException ex = await Assert.ThrowsAsync <HttpRequestException>(() => provider.RemoteLoadAsync("http://localhost:9999/app/profile")); }
public async void RemoteLoadAsync_ConfigServerReturnsNotOkStatus() { // Arrange var startup = new TestConfigServerStartup("",500); var server = TestServer.Create(startup.Configure); ConfigServerClientSettings settings = new ConfigServerClientSettings(); settings.Name = "myName"; server.BaseAddress = new Uri(settings.Uri); ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(settings, server.CreateClient()); string path = provider.GetConfigServerUri(); // Act and Assert Environment result = await provider.RemoteLoadAsync(path); Assert.NotNull(startup.LastRequest); Assert.Equal("/" + settings.Name + "/" + settings.Environment, startup.LastRequest.Path.Value); Assert.Null(result); }
public async void RemoteLoadAsync_ConfigServerReturnsGood() { // Arrange var environment = @" { 'name': 'testname', 'profiles': ['Production'], 'label': 'testlabel', 'version': 'testversion', 'propertySources': [ { 'name': 'source', 'source': { 'key1': 'value1', 'key2': 10 } } ] }"; var startup = new TestConfigServerStartup(environment, 200); var server = TestServer.Create(startup.Configure); ConfigServerClientSettings settings = new ConfigServerClientSettings(); settings.Name = "myName"; server.BaseAddress = new Uri(settings.Uri); ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(settings, server.CreateClient()); string path = provider.GetConfigServerUri(); // Act and Assert Environment env = await provider.RemoteLoadAsync(path); Assert.NotNull(startup.LastRequest); Assert.Equal("/" + settings.Name + "/" + settings.Environment, startup.LastRequest.Path.Value); Assert.NotNull(env); Assert.Equal("testname", env.Name); Assert.NotNull(env.Profiles); Assert.Equal(1, env.Profiles.Count); Assert.Equal("testlabel", env.Label); Assert.Equal("testversion", env.Version); Assert.NotNull(env.PropertySources); Assert.Equal(1, env.PropertySources.Count); Assert.Equal("source", env.PropertySources[0].Name); Assert.NotNull(env.PropertySources[0].Source); Assert.Equal(2, env.PropertySources[0].Source.Count); Assert.Equal("value1", env.PropertySources[0].Source["key1"]); Assert.Equal((long)10, env.PropertySources[0].Source["key2"]); }
public async void RemoteLoadAsync_HostTimesout() { // Arrange ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(); // Act and Assert Environment env = await provider.RemoteLoadAsync("http://foo.bar:9999/app/profile"); Assert.Null(env); }
public async void RemoteLoadAsync_InvalidPath() { // Arrange ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(); // Act and Assert Environment env = await provider.RemoteLoadAsync("foobar\\foobar\\"); Assert.Null(env); }
public async void RemoteLoadAsync_ConfigServerReturnsGreaterThanEqualBadRequest() { // Arrange IHostingEnvironment envir = new HostingEnvironment(); TestConfigServerStartup.Response = string.Empty; TestConfigServerStartup.ReturnStatus = 500; var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName); var server = new TestServer(builder); ConfigServerClientSettings settings = new ConfigServerClientSettings(); settings.Uri = "http://localhost:8888"; settings.Name = "myName"; server.BaseAddress = new Uri(settings.Uri); ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(settings, server.CreateClient()); string path = provider.GetConfigServerUri(null); // Act and Assert HttpRequestException ex = await Assert.ThrowsAsync <HttpRequestException>(() => provider.RemoteLoadAsync(path)); Assert.NotNull(TestConfigServerStartup.LastRequest); Assert.Equal("/" + settings.Name + "/" + settings.Environment, TestConfigServerStartup.LastRequest.Path.Value); }
public async void RemoteLoadAsync_HostTimesout() { // Arrange ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings()); // Act and Assert HttpRequestException ex = await Assert.ThrowsAsync <HttpRequestException>(() => provider.RemoteLoadAsync(new string[] { "http://localhost:9999/app/profile" }, null)); }
public async void RemoteLoadAsync_InvalidUri() { // Arrange ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings()); // Act and Assert UriFormatException ex = await Assert.ThrowsAsync <UriFormatException>(() => provider.RemoteLoadAsync(new string[] { "foobar\\foobar\\" }, null)); }