public async void WhenSettingSecurityHeaders_WhenGivenAcontext_TheXContentTypeOptionsHeaderIsSet() { var defaultHttpContext = new DefaultHttpContext(); await SecurityHeadersHelper.SetSecurityHeaders(defaultHttpContext); Assert.NotNull(defaultHttpContext.Response.Headers); Assert.NotEmpty(defaultHttpContext.Response.Headers); Assert.True(defaultHttpContext.Response.Headers.TryGetValue("X-Content-Type-Options", out StringValues headerValue)); Assert.Equal("nosniff", headerValue); }
public async void WhenSettingSecurityHeaders_WhenGivenAnIncorrectType_ThenExceptionIsThrown() { int notAContext = 1; await Assert.ThrowsAsync <ArgumentException>(async() => await SecurityHeadersHelper.SetSecurityHeaders(notAContext)); }
public async void WhenSettingSecurityHeaders_WhenGivenANullContext_ThenExceptionIsThrown() { await Assert.ThrowsAsync <ArgumentNullException>(async() => await SecurityHeadersHelper.SetSecurityHeaders(null)); }