public async Task CanRedirectToExternalUrl() { factory.ClientOptions.AllowAutoRedirect = false; var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(new Uri("/externalpath1", UriKind.Relative)).ConfigureAwait(false); Assert.Equal(HttpStatusCode.Found, response.StatusCode); Assert.Equal("http://www.externalpath1.com/", response.Headers.Location.AbsoluteUri); }
public async Task When_ShellUrlIsEntryPoint_ItContainsResponseFromRegisteredRegions() { var shellUri = new Uri(Path, UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(shellUri).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Contains("GET, http://www.path1.com/path1/body, path1, Body", responseHtml, StringComparison.OrdinalIgnoreCase); }
public async Task WhenAnRegionIsOfflineContentIncludesTheRegionsOfflineHtml() { var shellUri = new Uri("path1/article", UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(shellUri).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Contains("path1 region bodyfooter is offline", responseHtml, StringComparison.OrdinalIgnoreCase); }
public async Task WhenAnApplicationIsOfflineItContainsTheApplicationsOfflineMessage() { var shellUri = new Uri("path3", UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(shellUri).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Contains("Path3 is offline", responseHtml, StringComparison.OrdinalIgnoreCase); }
public async Task Should_DevDraftReturnValidContent() { var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(new Uri("https://dev-draft.nationalcareersservice.org.uk/robots.txt", UriKind.Absolute)); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync(); Assert.Equal(MediaTypeNames.Text.Plain, response.Content.Headers.ContentType.MediaType); Assert.Equal( @"User-agent: * Disallow: /", responseHtml); }
public async Task When_ShellUrlIsEntryPoint_ItContainsResponseFromRegisteredRegions() { // Arrange var shellUri = new Uri("path1", UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); // Act var response = await client.GetAsync(shellUri); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync(); // Assert Assert.Contains("GET, http://www.expected-domain.com/expected-path/path1/body, pages, Body", responseHtml, StringComparison.OrdinalIgnoreCase); }
public async Task WhenAnRegionIsOfflineContentIncludesTheRegionsOfflineHtml() { // Arrange var shellUri = new Uri("path3", UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); // Act var response = await client.GetAsync(shellUri); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync(); // Assert Assert.Contains("Path3 is offline", responseHtml, StringComparison.OrdinalIgnoreCase); }
public async Task Should_ReturnValidContent() { var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(new Uri("/sitemap.xml", UriKind.Relative)).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Equal(MediaTypeNames.Application.Xml, response.Content.Headers.ContentType.MediaType); }
public async Task WhenAnApplicationIsOnlineItContainsContentFromAllOnlineRegions() { var shellUri = new Uri("path1", UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(shellUri).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Contains("GET, http://www.path1.com/path1/body, path1, Body", responseHtml, StringComparison.OrdinalIgnoreCase); }
public async Task Should_ReturnValidContent() { var client = factory.CreateClientWithWebHostBuilder(); var response = await client.GetAsync(new Uri("/robots.txt", UriKind.Relative)).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Equal(MediaTypeNames.Text.Plain, response.Content.Headers.ContentType.MediaType); Assert.True(responseHtml.Contains("User-agent:", StringComparison.OrdinalIgnoreCase) || responseHtml.Contains("Disallow:", StringComparison.OrdinalIgnoreCase)); }
public async Task When_ShellSendsPostData_ItsSendItToRegisteredApplication() { // Arrange var shellUri = new Uri("path1/edit?id=1", UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); var expected = "POST, http://www.expected-domain.com/expected-path/edit/body, path1, Body, field1=value1, field2=value2"; using var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("field1", "value1"), new KeyValuePair <string, string>("field2", "value2"), }); // Act var response = await client.PostAsync(shellUri, formContent); response.EnsureSuccessStatusCode(); var actual = await response.Content.ReadAsStringAsync(); // Assert Assert.Contains(expected, actual, StringComparison.OrdinalIgnoreCase); }
public async Task WhenAnApplicationIsOnlineItContainsContentFromAllOnlineRegions() { // Arrange var shellUri = new Uri("pages", UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); var expected = "GET, http://www.expected-domain.com/expected-path/body, pages, Body"; // Act var response = await client.GetAsync(shellUri); response.EnsureSuccessStatusCode(); var actual = await response.Content.ReadAsStringAsync(); // Assert Assert.Contains(expected, actual, StringComparison.OrdinalIgnoreCase); }
public async Task Should_ReturnValidContent() { // Arrange var client = factory.CreateClientWithWebHostBuilder(); using var request = new HttpRequestMessage(HttpMethod.Get, "/health"); request.Headers.Accept.Clear(); request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json)); // Act var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); // Assert Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType.MediaType); }
public async Task When_ShellSendsPostData_ItsSendItToRegisteredApplication() { var path = "path1"; var shellUri = new Uri(string.Concat(path, "/edit?id=1"), UriKind.Relative); var client = factory.CreateClientWithWebHostBuilder(); var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("field1", "value1"), new KeyValuePair <string, string>("field2", "value2"), }); var response = await client.PostAsync(shellUri, formContent).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseHtml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Contains("POST, http://www.path1.com/path1/edit, path1, Body, field1=value1, field2=value2", responseHtml, StringComparison.OrdinalIgnoreCase); formContent.Dispose(); }