public EnforceHttpsMiddlewareTests() { next = context => { isNextCalled = true; return(TaskHelper.Done); }; sut = new EnforceHttpsMiddleware(Options.Create(options)); }
public async Task Should_not_redirect_if_not_required() { var httpContext = CreateHttpContext("http"); var sut = new EnforceHttpsMiddleware(next, Options.Create(new MyUrlsOptions { EnforceHTTPS = false })); await sut.Invoke(httpContext); Assert.True(isNextCalled); Assert.Null((string)httpContext.Response.Headers["Location"]); }
public async Task Should_make_permanent_redirect_if_redirect_is_required() { var httpContext = CreateHttpContext(); var sut = new EnforceHttpsMiddleware(next, Options.Create(new MyUrlsOptions { EnforceHTTPS = true })); await sut.Invoke(httpContext); Assert.False(isNextCalled); Assert.Equal("https://squidex.local/path?query=1", httpContext.Response.Headers["Location"]); }