public void ValidCustomHttpHeadersConfig_BindsToOptions() { string hostJsonContent = @"{ 'version': '2.0', 'extensions': { 'http': { 'customHeaders': { 'X-Content-Type-Options': 'nosniff' } } } }"; File.WriteAllText(_hostJsonFile, hostJsonContent); var configuration = BuildHostJsonConfiguration(); CustomHttpHeadersOptionsSetup setup = new CustomHttpHeadersOptionsSetup(configuration); CustomHttpHeadersOptions options = new CustomHttpHeadersOptions(); setup.Configure(options); Assert.Equal(new Dictionary <string, string>() { { "X-Content-Type-Options", "nosniff" } }, options); }
public void MissingOrValidCustomHttpHeadersConfig_DoesNotThrowException(string hostJsonContent) { File.WriteAllText(_hostJsonFile, hostJsonContent); var configuration = BuildHostJsonConfiguration(); CustomHttpHeadersOptionsSetup setup = new CustomHttpHeadersOptionsSetup(configuration); CustomHttpHeadersOptions options = new CustomHttpHeadersOptions(); var ex = Record.Exception(() => setup.Configure(options)); Assert.Null(ex); }