public void WhenIncludesSubDomains_GeneratesCorrectValue() { // Arrange var settings = new HstsSettings(); // Act var result = settings.GenerateResponseValue(); // Assert Assert.AreEqual(result, "max-age=2419200 ; includeSubDomains", result); // Verify }
public async void WhenHeaderIsAlreadySetAndOverrideIsSet_SetTheHeader() { // Arrange const string presetHeader = "max-age=1"; var settings = new HstsSettings { OverwriteExisting = true }; _stubResponse.Headers.Add(HstsHeaderName, new[] { presetHeader }); var middleware = new HstsMiddleware(null, settings); // Act await middleware.Invoke(_mockContext.Object); _stubResponse.InvokeOnSendingHeaders(); // Assert Assert.AreEqual(settings.GenerateResponseValue(), _mockContext.Object.Response.Headers[HstsHeaderName]); }
/// <summary> /// Adds the Http Strict Transport Security (HSTS) header using the specified settings /// </summary> /// <param name="builder">The current OWIN App Builder</param> /// <param name="settings">The settings to apply to the HSTS header</param> public static void UseHttpStrictTransportSecurity(this IAppBuilder builder, HstsSettings settings) { builder.Use <HstsMiddleware>(settings); }
/// <summary> /// Adds the Http Strict Transport Security (HSTS) header using the specified settings /// </summary> /// <param name="builder">The current OWIN App Builder</param> /// <param name="settings">The settings to apply to the HSTS header</param> public static void UseHttpStrictTransportSecurity(this IAppBuilder builder, HstsSettings settings) { builder.Use<HstsMiddleware>(settings); }