Beispiel #1
0
        public void MissingOrValidHstsConfig_DoesNotThrowException(string hostJsonContent)
        {
            File.WriteAllText(_hostJsonFile, hostJsonContent);
            var configuration = BuildHostJsonConfiguration();

            HostHstsOptionsSetup setup   = new HostHstsOptionsSetup(configuration);
            HostHstsOptions      options = new HostHstsOptions();
            var ex = Record.Exception(() => setup.Configure(options));

            Assert.Null(ex);
        }
Beispiel #2
0
        public void ValidHstsConfig_BindsToOptions()
        {
            string hostJsonContent = @"{
                                         'version': '2.0',
                                         'http': {
                                             'hsts': {
                                                 'isEnabled': true,
                                                 'maxAge': '10'
                                             }
                                         }
                                     }";

            File.WriteAllText(_hostJsonFile, hostJsonContent);
            var configuration = BuildHostJsonConfiguration();

            HostHstsOptionsSetup setup   = new HostHstsOptionsSetup(configuration);
            HostHstsOptions      options = new HostHstsOptions();

            setup.Configure(options);
            Assert.Equal(options.MaxAge, new TimeSpan(10, 0, 0, 0));
        }