public void SetsSpecifiedMaxAgeWhenHstsIsUsed() { config.UseHsts = true; const int MaxAgeSeconds = 100; hstsPolicy = new HstsPolicy(TimeSpan.FromSeconds(MaxAgeSeconds)); ApplyPolicy(); AssertHstsMaxAgeIsSet(MaxAgeSeconds); }
public void Setup() { config = new WebServerConfiguration(); context = new FakeWebContext( null, null, Mock.Of <IFileSystem>(), new TimeMachine(), config); hstsPolicy = new HstsPolicy(); }
public void HstsTest() { SslLabsClient client = new SslLabsClient(); Host analysis = client.GetAnalysisBlocking("scotthelme.co.uk", options: AnalyzeOptions.ReturnAll); Assert.IsNotNull(analysis); Assert.AreEqual(AnalysisStatus.READY, analysis.Status, "scotthelme.co.uk analysis was not ready. Wait for the analysis to complete."); Endpoint endpoint = analysis.Endpoints.First(); HstsPolicy hstsPolicy = endpoint.Details.HstsPolicy; Assert.IsTrue(hstsPolicy.MaxAge > 0); Assert.IsTrue(hstsPolicy.Preload); Assert.IsTrue(hstsPolicy.IncludeSubDomains); Assert.AreEqual(HstsStatus.Present, hstsPolicy.Status); List <HstsPreload> hstsPreloads = endpoint.Details.HstsPreloads; Assert.IsTrue(hstsPreloads.Any(s => s.Source == "Chrome")); }