public void HttpSelfHostConfiguration_Settings_PropagateToBinding() { // Arrange HttpBinding binding = new HttpBinding(); binding.ConfigureTransportBindingElement = ConfigureTransportBindingElement; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost") { MaxBufferSize = 10, MaxReceivedMessageSize = 11, ReceiveTimeout = new TimeSpan(1, 0, 0), SendTimeout = new TimeSpan(1, 0, 0), TransferMode = TransferMode.StreamedResponse, HostNameComparisonMode = HostNameComparisonMode.WeakWildcard }; // Act config.ConfigureBinding(binding); // Assert Assert.Equal(10, binding.MaxBufferSize); Assert.Equal(11, binding.MaxReceivedMessageSize); Assert.Equal(new TimeSpan(1, 0, 0), binding.ReceiveTimeout); Assert.Equal(new TimeSpan(1, 0, 0), binding.SendTimeout); Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode); Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode); Assert.Equal(Net.AuthenticationSchemes.Ntlm, binding.CreateBindingElements().Find <HttpTransportBindingElement>().AuthenticationScheme); }
public void HttpSelfHostConfiguration_UserNamePasswordValidator_PropagatesToBinding( string address, HttpBindingSecurityMode mode ) { // Arrange HttpBinding binding = new HttpBinding(); UserNamePasswordValidator validator = new Mock <UserNamePasswordValidator>().Object; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UserNamePasswordValidator = validator }; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); // Assert Assert.NotNull(parameters); ServiceCredentials serviceCredentials = parameters.Find <ServiceCredentials>(); Assert.NotNull(serviceCredentials); Assert.Equal( HttpClientCredentialType.Basic, binding.Security.Transport.ClientCredentialType ); Assert.Equal(mode, binding.Security.Mode); }
public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithX509CertificateValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { X509CertificateValidator = new Mock <X509CertificateValidator>().Object }; config.ClientCredentialType = clientCredentialType; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }
public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithUsernamePasswordValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UserNamePasswordValidator = new CustomUsernamePasswordValidator() }; config.ClientCredentialType = clientCredentialType; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }
public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithX509CertificateValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange GC.KeepAlive(mode); // Mark parameter as used. See xUnit1026, [Theory] method doesn't use all parameters. HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { X509CertificateValidator = new Mock <X509CertificateValidator>().Object }; config.ClientCredentialType = clientCredentialType; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }
public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithUsernamePasswordValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange GC.KeepAlive(mode); // Mark parameter as used. See xUnit1026, [Theory] method doesn't use all parameters. HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UserNamePasswordValidator = new CustomUsernamePasswordValidator() }; config.ClientCredentialType = clientCredentialType; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }
public void HttpSelfHostConfiguration_ClientCredentialType_PropagatesToHttpBinding(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { ClientCredentialType = clientCredentialType }; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); Assert.Equal(clientCredentialType, binding.Security.Transport.ClientCredentialType); Assert.Equal(mode, binding.Security.Mode); }
public void HttpSelfHostConfiguration_WrongClientCredentialType_WithX509CertificateValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { X509CertificateValidator = new Mock <X509CertificateValidator>().Object }; config.ClientCredentialType = clientCredentialType; Assert.Throws <InvalidOperationException>(() => { // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }); }
public void HttpSelfHostConfiguration_WrongClientCredentialType_WithUsernamePasswordValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UserNamePasswordValidator = new CustomUsernamePasswordValidator() }; config.ClientCredentialType = clientCredentialType; Assert.Throws <InvalidOperationException>(() => { // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }); }
public void HttpSelfHostConfiguration_UseWindowsAuth_PropagatesToHttpBinding(string address, HttpBindingSecurityMode mode) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UseWindowsAuthentication = true }; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); // Assert Assert.NotNull(parameters); ServiceCredentials serviceCredentials = parameters.Find <ServiceCredentials>(); Assert.NotNull(serviceCredentials); Assert.Equal(HttpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType); Assert.Equal(mode, binding.Security.Mode); }
public void HttpSelfHostConfiguration_Settings_PropagateToBinding() { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost") { MaxBufferSize = 10, MaxReceivedMessageSize = 11, TransferMode = TransferMode.StreamedResponse, HostNameComparisonMode = HostNameComparisonMode.WeakWildcard }; // Act config.ConfigureBinding(binding); // Assert Assert.Equal(10, binding.MaxBufferSize); Assert.Equal(11, binding.MaxReceivedMessageSize); Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode); Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode); }
public void HttpSelfHostConfiguration_UserNamePasswordValidator_PropagatesToBinding(string address, HttpBindingSecurityMode mode) { // Arrange HttpBinding binding = new HttpBinding(); UserNamePasswordValidator validator = new Mock<UserNamePasswordValidator>().Object; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UserNamePasswordValidator = validator }; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); // Assert Assert.NotNull(parameters); ServiceCredentials serviceCredentials = parameters.Find<ServiceCredentials>(); Assert.NotNull(serviceCredentials); Assert.Equal(HttpClientCredentialType.Basic, binding.Security.Transport.ClientCredentialType); Assert.Equal(mode, binding.Security.Mode); }
public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithX509CertificateValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { X509CertificateValidator = new Mock<X509CertificateValidator>().Object }; config.ClientCredentialType = clientCredentialType; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }
public void HttpSelfHostConfiguration_WrongClientCredentialType_WithX509CertificateValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { X509CertificateValidator = new Mock<X509CertificateValidator>().Object }; config.ClientCredentialType = clientCredentialType; Assert.Throws<InvalidOperationException>(() => { // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }); }
public void HttpSelfHostConfiguration_WrongClientCredentialType_WithUsernamePasswordValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UserNamePasswordValidator = new CustomUsernamePasswordValidator() }; config.ClientCredentialType = clientCredentialType; Assert.Throws<InvalidOperationException>(() => { // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); }); }
public void HttpSelfHostConfiguration_Settings_PropagateToBinding() { // Arrange HttpBinding binding = new HttpBinding(); binding.ConfigureTransportBindingElement = ConfigureTransportBindingElement; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost") { MaxBufferSize = 10, MaxReceivedMessageSize = 11, ReceiveTimeout = new TimeSpan(1, 0, 0), SendTimeout = new TimeSpan(1, 0, 0), TransferMode = TransferMode.StreamedResponse, HostNameComparisonMode = HostNameComparisonMode.WeakWildcard }; // Act config.ConfigureBinding(binding); // Assert Assert.Equal(10, binding.MaxBufferSize); Assert.Equal(11, binding.MaxReceivedMessageSize); Assert.Equal(new TimeSpan(1, 0, 0), binding.ReceiveTimeout); Assert.Equal(new TimeSpan(1, 0, 0), binding.SendTimeout); Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode); Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode); Assert.Equal(Net.AuthenticationSchemes.Ntlm, binding.CreateBindingElements().Find<HttpTransportBindingElement>().AuthenticationScheme); }
public void HttpSelfHostConfiguration_UseWindowsAuth_PropagatesToHttpBinding(string address, HttpBindingSecurityMode mode) { // Arrange HttpBinding binding = new HttpBinding(); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UseWindowsAuthentication = true }; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); // Assert Assert.NotNull(parameters); ServiceCredentials serviceCredentials = parameters.Find<ServiceCredentials>(); Assert.NotNull(serviceCredentials); Assert.Equal(HttpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType); Assert.Equal(mode, binding.Security.Mode); }