Recently, I came up with unit tests for checking some redirect rules of my ASP.NET Core 2.1 application:
[Fact(DisplayName = "lowercase path")]
public async Task LowercaseRedirect()
{
var result = await this.Client.GetAsync("/BLOG/");
Assert.EndsWith("/blog/", result.RequestMessage.RequestUri.PathAndQuery, StringComparison.InvariantCulture);
}
[Fact(DisplayName = "add missing slash")]
public async Task SlashRedirect()
{
var result = await this.Client.GetAsync("/blog");
Assert.EndsWith("/blog/", result.RequestMessage.RequestUri.PathAndQuery, StringComparison.InvariantCulture);
}
FYI: I am currently injecting the WebApplicationFactory<TEntryPoint> into my test class, which I use to create my HttpClient.
But now I am curious how to check if the https redirect is working. Any ideas how to accomplish that? Thanks in advance :)