public async Task Start() { this._client.ReceiveBufferSize = 65536; this._client.SendBufferSize = 65536; this._listener.AddConnection(this); try { this._stream = new NegotiateStream(this._client.GetStream()); ExtendedProtectionPolicy policy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); NetworkCredential nc = new NetworkCredential(); await this._stream.AuthenticateAsServerAsync(nc, ProtectionLevel.EncryptAndSign, TokenImpersonationLevel.Identification); await this.Read(); } catch (AuthenticationException ex) { Console.WriteLine(ex.ToString()); } catch (ObjectDisposedException ex) { Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { this.Dispose(); } }
public virtual Task AuthenticateAsServerAsync( NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel) { throw new NotImplementedException(); }
// // // internal void ValidateCreateContext(string package, NetworkCredential credential, string servicePrincipalName, ExtendedProtectionPolicy policy, ProtectionLevel protectionLevel, TokenImpersonationLevel impersonationLevel) { if (policy != null) { if (!AuthenticationManager.OSSupportsExtendedProtection) { if (policy.PolicyEnforcement == PolicyEnforcement.Always) { throw new PlatformNotSupportedException(SR.GetString(SR.security_ExtendedProtection_NoOSSupport)); } } else { // One of these must be set if EP is turned on if (policy.CustomChannelBinding == null && policy.CustomServiceNames == null) { throw new ArgumentException(SR.GetString(SR.net_auth_must_specify_extended_protection_scheme), "policy"); } } _ExtendedProtectionPolicy = policy; } else { _ExtendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); } ValidateCreateContext(package, true, credential, servicePrincipalName, _ExtendedProtectionPolicy.CustomChannelBinding, protectionLevel, impersonationLevel); }
internal SecurityProtocolFactory(SecurityProtocolFactory factory) : this() { if (factory == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(factory)); } this.actAsInitiator = factory.actAsInitiator; this.addTimestamp = factory.addTimestamp; this.detectReplays = factory.detectReplays; this.incomingAlgorithmSuite = factory.incomingAlgorithmSuite; this.maxCachedNonces = factory.maxCachedNonces; this.maxClockSkew = factory.maxClockSkew; this.outgoingAlgorithmSuite = factory.outgoingAlgorithmSuite; this.replayWindow = factory.replayWindow; this.channelSupportingTokenAuthenticatorSpecification = new Collection <SupportingTokenAuthenticatorSpecification>(new List <SupportingTokenAuthenticatorSpecification>(factory.channelSupportingTokenAuthenticatorSpecification)); this.scopedSupportingTokenAuthenticatorSpecification = new Dictionary <string, ICollection <SupportingTokenAuthenticatorSpecification> >(factory.scopedSupportingTokenAuthenticatorSpecification); this.standardsManager = factory.standardsManager; this.timestampValidityDuration = factory.timestampValidityDuration; // this.auditLogLocation = factory.auditLogLocation; this.suppressAuditFailure = factory.suppressAuditFailure; // this.serviceAuthorizationAuditLevel = factory.serviceAuthorizationAuditLevel; // this.messageAuthenticationAuditLevel = factory.messageAuthenticationAuditLevel; if (factory.securityBindingElement != null) { this.securityBindingElement = (SecurityBindingElement)factory.securityBindingElement.Clone(); } this.securityTokenManager = factory.securityTokenManager; this.privacyNoticeUri = factory.privacyNoticeUri; this.privacyNoticeVersion = factory.privacyNoticeVersion; this.endpointFilterTable = factory.endpointFilterTable; this.extendedProtectionPolicy = factory.extendedProtectionPolicy; this.nonceCache = factory.nonceCache; }
private ExtendedProtectionPolicy SelectExtendedProtectionPolicy(HttpListenerRequest request) { ExtendedProtectionPolicy extendedProtectionPolicy = null; ExtendedProtectionPolicy policy2; try { HttpChannelListener listener; if (base.TryLookupUri(request.Url, request.HttpMethod, base.HostNameComparisonMode, out listener)) { extendedProtectionPolicy = listener.ExtendedProtectionPolicy; } else { extendedProtectionPolicy = ChannelBindingUtility.DisabledPolicy; } policy2 = extendedProtectionPolicy; } catch (Exception exception) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error); throw; } return(policy2); }
ExtendedProtectionPolicy SelectExtendedProtectionPolicy(HttpListenerRequest request) { ExtendedProtectionPolicy result = null; try { HttpChannelListener channelListener; if (base.TryLookupUri(request.Url, request.HttpMethod, this.HostNameComparisonMode, request.IsWebSocketRequest, out channelListener)) { result = channelListener.ExtendedProtectionPolicy; } else { //if the listener isn't found, then the auth scheme will be anonymous //(see SelectAuthenticationScheme function) and will fall through to the //404 Not Found code path, so it doesn't really matter what we return from here... result = ChannelBindingUtility.DisabledPolicy; } return(result); } catch (Exception e) { DiagnosticUtility.TraceHandledException(e, TraceEventType.Error); throw; } }
internal void ValidateCreateContext( string package, NetworkCredential credential, string servicePrincipalName, ExtendedProtectionPolicy policy, ProtectionLevel protectionLevel, TokenImpersonationLevel impersonationLevel) { if (policy != null) { // One of these must be set if EP is turned on if (policy.CustomChannelBinding == null && policy.CustomServiceNames == null) { throw new ArgumentException(SR.net_auth_must_specify_extended_protection_scheme, nameof(policy)); } _extendedProtectionPolicy = policy; } else { _extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); } ValidateCreateContext(package, true, credential, servicePrincipalName, _extendedProtectionPolicy.CustomChannelBinding, protectionLevel, impersonationLevel); }
public HttpTransportSecurity() { _clientCredentialType = DefaultClientCredentialType; _proxyCredentialType = DefaultProxyCredentialType; Realm = DefaultRealm; _extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy; }
protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned) : base(elementToBeCloned) { AllowCookies = elementToBeCloned.AllowCookies; AuthenticationScheme = elementToBeCloned.AuthenticationScheme; BypassProxyOnLocal = elementToBeCloned.BypassProxyOnLocal; _decompressionEnabled = elementToBeCloned._decompressionEnabled; _hostNameComparisonMode = elementToBeCloned._hostNameComparisonMode; _inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings; KeepAliveEnabled = elementToBeCloned.KeepAliveEnabled; _maxBufferSize = elementToBeCloned._maxBufferSize; _maxBufferSizeInitialized = elementToBeCloned._maxBufferSizeInitialized; _maxPendingAccepts = elementToBeCloned._maxPendingAccepts; _method = elementToBeCloned._method; Proxy = elementToBeCloned.Proxy; ProxyAddress = elementToBeCloned.ProxyAddress; _proxyAuthenticationScheme = elementToBeCloned._proxyAuthenticationScheme; _realm = elementToBeCloned._realm; _requestInitializationTimeout = elementToBeCloned._requestInitializationTimeout; _transferMode = elementToBeCloned._transferMode; UnsafeConnectionNtlmAuthentication = elementToBeCloned.UnsafeConnectionNtlmAuthentication; _useDefaultWebProxy = elementToBeCloned._useDefaultWebProxy; _webSocketSettings = elementToBeCloned._webSocketSettings.Clone(); _extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy; MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory; }
public virtual Task AuthenticateAsServerAsync( NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel) { return(Task.Factory.FromAsync((callback, state) => BeginAuthenticateAsServer(credential, policy, requiredProtectionLevel, requiredImpersonationLevel, callback, state), EndAuthenticateAsClient, null)); }
/// <summary> /// Called by servers to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified server credentials, authentication options, and extended protection policy. /// </summary> /// <param name="credential">The NetworkCredential that is used to establish the identity of the client.</param> /// <param name="policy">The ExtendedProtectionPolicy that is used for extended protection.</param> /// <param name="requiredProtectionLevel">One of the ProtectionLevel values, indicating the security services for the stream.</param> /// <param name="requiredImpersonationLevel">One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.</param> public VaserKerberosServer(NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel) { _credential = credential; _requiredProtectionLevel = requiredProtectionLevel; _requiredImpersonationLevel = requiredImpersonationLevel; _policy = policy; }
public TcpTransportSecurity() { _clientCredentialType = DefaultClientCredentialType; _protectionLevel = DefaultProtectionLevel; _extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy; _sslProtocols = TransportDefaults.SslProtocols; }
//does not validate the ExtendedProtectionPolicy.CustomServiceNames collections on the policies public static bool AreEqual(ExtendedProtectionPolicy policy1, ExtendedProtectionPolicy policy2) { Debug.Assert(policy1 != null, "policy1 param cannot be null"); Debug.Assert(policy2 != null, "policy2 param cannot be null"); if (policy1.PolicyEnforcement == PolicyEnforcement.Never && policy2.PolicyEnforcement == PolicyEnforcement.Never) { return(true); } if (policy1.PolicyEnforcement != policy2.PolicyEnforcement) { return(false); } if (policy1.ProtectionScenario != policy2.ProtectionScenario) { return(false); } if (policy1.CustomChannelBinding != policy2.CustomChannelBinding) { return(false); } return(true); }
internal SecurityProtocolFactory(SecurityProtocolFactory factory) : this() { if (factory == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("factory"); } _actAsInitiator = factory._actAsInitiator; _addTimestamp = factory._addTimestamp; _detectReplays = factory._detectReplays; _incomingAlgorithmSuite = factory._incomingAlgorithmSuite; _maxCachedNonces = factory._maxCachedNonces; _maxClockSkew = factory._maxClockSkew; _outgoingAlgorithmSuite = factory._outgoingAlgorithmSuite; _replayWindow = factory._replayWindow; _channelSupportingTokenAuthenticatorSpecification = new Collection <SupportingTokenAuthenticatorSpecification>(new List <SupportingTokenAuthenticatorSpecification>(factory._channelSupportingTokenAuthenticatorSpecification)); _scopedSupportingTokenAuthenticatorSpecification = new Dictionary <string, ICollection <SupportingTokenAuthenticatorSpecification> >(factory._scopedSupportingTokenAuthenticatorSpecification); _standardsManager = factory._standardsManager; _timestampValidityDuration = factory._timestampValidityDuration; _auditLogLocation = factory._auditLogLocation; _suppressAuditFailure = factory._suppressAuditFailure; _serviceAuthorizationAuditLevel = factory._serviceAuthorizationAuditLevel; _messageAuthenticationAuditLevel = factory._messageAuthenticationAuditLevel; if (factory._securityBindingElement != null) { _securityBindingElement = (SecurityBindingElement)factory._securityBindingElement.Clone(); } _securityTokenManager = factory._securityTokenManager; _privacyNoticeUri = factory._privacyNoticeUri; _privacyNoticeVersion = factory._privacyNoticeVersion; _extendedProtectionPolicy = factory._extendedProtectionPolicy; _nonceCache = factory._nonceCache; }
public void Constructor_PolicyEnforcement_MembersAreSet() { var extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); Assert.Equal(PolicyEnforcement.Never, extendedProtectionPolicy.PolicyEnforcement); Assert.Equal(ProtectionScenario.TransportSelected, extendedProtectionPolicy.ProtectionScenario); }
protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned) : base(elementToBeCloned) { this.allowCookies = elementToBeCloned.allowCookies; this.authenticationScheme = elementToBeCloned.authenticationScheme; this.bypassProxyOnLocal = elementToBeCloned.bypassProxyOnLocal; this.decompressionEnabled = elementToBeCloned.decompressionEnabled; this.hostNameComparisonMode = elementToBeCloned.hostNameComparisonMode; this.inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings; this.keepAliveEnabled = elementToBeCloned.keepAliveEnabled; this.maxBufferSize = elementToBeCloned.maxBufferSize; this.maxBufferSizeInitialized = elementToBeCloned.maxBufferSizeInitialized; this.maxPendingAccepts = elementToBeCloned.maxPendingAccepts; this.method = elementToBeCloned.method; this.proxyAddress = elementToBeCloned.proxyAddress; this.proxyAuthenticationScheme = elementToBeCloned.proxyAuthenticationScheme; this.realm = elementToBeCloned.realm; this.requestInitializationTimeout = elementToBeCloned.requestInitializationTimeout; this.transferMode = elementToBeCloned.transferMode; this.unsafeConnectionNtlmAuthentication = elementToBeCloned.unsafeConnectionNtlmAuthentication; this.useDefaultWebProxy = elementToBeCloned.useDefaultWebProxy; this.webSocketSettings = elementToBeCloned.webSocketSettings.Clone(); this.webProxy = elementToBeCloned.webProxy; this.extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy; if (elementToBeCloned.anonymousUriPrefixMatcher != null) { this.anonymousUriPrefixMatcher = new HttpAnonymousUriPrefixMatcher(elementToBeCloned.anonymousUriPrefixMatcher); } this.MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory; }
public void HttpTransportSecurity_DisableTransportAuthentication() { ExtendedProtectionPolicy policy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); HttpTransportSecurity security = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Basic, ProxyCredentialType = HttpProxyCredentialType.Basic, Realm = "MyRealm", ExtendedProtectionPolicy = policy }; HttpTransportBindingElement binding = new HttpTransportBindingElement(); // first configure it security.ConfigureTransportAuthentication(binding); Assert.AreEqual(AuthenticationSchemes.Basic, binding.AuthenticationScheme, "AuthenticationScheme failed to init"); Assert.AreEqual(AuthenticationSchemes.Basic, binding.ProxyAuthenticationScheme, "ProxyAuthenticationScheme failed to init"); Assert.AreEqual("MyRealm", binding.Realm, "Realm failed to init"); Assert.AreEqual(policy, binding.ExtendedProtectionPolicy, "ExtendedProtectionPolicy failed to init"); // then disable it security.DisableTransportAuthentication(binding); Assert.AreEqual(AuthenticationSchemes.Anonymous, binding.AuthenticationScheme, "AuthenticationScheme failed to init"); Assert.AreEqual(AuthenticationSchemes.Anonymous, binding.ProxyAuthenticationScheme, "ProxyAuthenticationScheme failed to init"); Assert.AreEqual(string.Empty, binding.Realm, "Realm failed to init"); Assert.AreEqual(policy, binding.ExtendedProtectionPolicy, "ExtendedProtectionPolicy failed to init"); }
internal KerberosReceiverSecurityToken( byte[] request, string id, bool doAuthenticate, string valueTypeUri, ChannelBinding channelBinding, ExtendedProtectionPolicy extendedProtectionPolicy) { if (request == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("request")); } if (id == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("id")); } this.id = id; this.request = request; this.valueTypeUri = valueTypeUri; this.channelBinding = channelBinding; this.extendedProtectionPolicy = extendedProtectionPolicy; if (doAuthenticate) { Initialize(null, channelBinding, extendedProtectionPolicy); } }
internal override void WriteTo(XmlWriter xml) { if (xml == null) { return; } if (this.policyHelper != null) { xml.WriteElementString("PolicyEnforcement", this.policyHelper.PolicyEnforcement.ToString()); xml.WriteElementString("ProtectionScenario", this.policyHelper.ProtectionScenario.ToString()); xml.WriteStartElement("ServiceNameCollection"); if (this.policyHelper.ServiceNameCollection != null && this.policyHelper.ServiceNameCollection.Count > 0) { foreach (string serviceName in this.policyHelper.ServiceNameCollection) { xml.WriteElementString("ServiceName", serviceName); } } xml.WriteFullEndElement(); if (this.isServer) { this.channelBindingUsed = this.policyHelper.ShouldAddChannelBindingToASC(); } else { this.channelBindingUsed = this.policyHelper.ChannelBinding != null; } xml.WriteElementString("ChannelBindingUsed", this.channelBindingUsed.ToString()); if (this.channelBinding != null && this.policyHelper.PolicyEnforcement != PolicyEnforcement.Never && this.channelBindingUsed == true) { ExtendedProtectionPolicy extendedProtection = new ExtendedProtectionPolicy(policyHelper.PolicyEnforcement, channelBinding); xml.WriteElementString("ChannelBindingData", GetBase64EncodedChannelBindingData(extendedProtection)); } } else { // This is the case for KerberosRequestorSecurityToken where policyHelper is null. if (this.channelBinding != null) { xml.WriteElementString("ChannelBindingUsed", "true"); // We do not know the PolicyEnforcement value here on the client side and we can not pass Never //as ExtendedProtectionPolicy constructor would throw on PolicyEnforcement.Never ExtendedProtectionPolicy extendedProtection = new ExtendedProtectionPolicy(PolicyEnforcement.WhenSupported, channelBinding); xml.WriteElementString("ChannelBindingData", GetBase64EncodedChannelBindingData(extendedProtection)); } else { xml.WriteElementString("ChannelBindingUsed", "false"); xml.WriteElementString("ChannelBindingData", null); } } }
public void ExtendedProtectionPolicy_SetCustomChannelBinding_ThrowsObjectDisposedException() { using (var listener = new HttpListener()) { var protectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Always, new CustomChannelBinding()); AssertExtensions.Throws <ArgumentException>("value", "CustomChannelBinding", () => listener.ExtendedProtectionPolicy = protectionPolicy); } }
public virtual void AuthenticateAsServer(NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel) { if (!ComNetOS.IsWin2K) { throw new PlatformNotSupportedException(SR.GetString("Win2000Required")); } this._NegoState.ValidateCreateContext(this._Package, credential, string.Empty, policy, requiredProtectionLevel, requiredImpersonationLevel); this._NegoState.ProcessAuthentication(null); }
public TcpTransportBindingElement() : base() { this.listenBacklog = TcpTransportDefaults.GetListenBacklog(); this.portSharingEnabled = TcpTransportDefaults.PortSharingEnabled; this.teredoEnabled = TcpTransportDefaults.TeredoEnabled; this.connectionPoolSettings = new TcpConnectionPoolSettings(); this.extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy; }
public void ExtendedProtectionPolicy_NoCustomServiceNamesAndNoCustomChannelBinding_ToString() { var extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Always); string expectedResult = $"ProtectionScenario={extendedProtectionPolicy.ProtectionScenario}; PolicyEnforcement={PolicyEnforcement.Always}; CustomChannelBinding=<null>; ServiceNames=<null>"; string result = extendedProtectionPolicy.ToString(); Assert.Equal(expectedResult, result); }
internal void ValidateCreateContext(string package, NetworkCredential credential, string servicePrincipalName, ExtendedProtectionPolicy policy, ProtectionLevel protectionLevel, TokenImpersonationLevel impersonationLevel) { throw new PlatformNotSupportedException(); }
internal string GetBase64EncodedChannelBindingData(ExtendedProtectionPolicy extendedProtectionPolicy) { MemoryStream ms = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(ms, extendedProtectionPolicy); byte[] channelBindingData = ms.GetBuffer(); return(Convert.ToBase64String(channelBindingData, Base64FormattingOptions.None)); }
protected TcpTransportBindingElement(TcpTransportBindingElement elementToBeCloned) : base(elementToBeCloned) { this.listenBacklog = elementToBeCloned.listenBacklog; this.isListenBacklogSet = elementToBeCloned.isListenBacklogSet; this.portSharingEnabled = elementToBeCloned.portSharingEnabled; this.teredoEnabled = elementToBeCloned.teredoEnabled; this.connectionPoolSettings = elementToBeCloned.connectionPoolSettings.Clone(); this.extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy; }
public void ExtendedProtectionPolicy_Properties() { var customChannelBindingParam = new MockCustomChannelBinding(); var extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Always, customChannelBindingParam); Assert.Null(extendedProtectionPolicy.CustomServiceNames); Assert.Equal(PolicyEnforcement.Always, extendedProtectionPolicy.PolicyEnforcement); Assert.Equal(ProtectionScenario.TransportSelected, extendedProtectionPolicy.ProtectionScenario); Assert.Equal(customChannelBindingParam, extendedProtectionPolicy.CustomChannelBinding); }
public void Constructor_CollectionParam() { var paramValue = new List <string> { "Test1", "Test2" }; var expectedServiceNameCollection = new ServiceNameCollection(paramValue); var extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Always, ProtectionScenario.TransportSelected, paramValue); Assert.Equal(2, extendedProtectionPolicy.CustomServiceNames.Count); Assert.Equal(expectedServiceNameCollection, extendedProtectionPolicy.CustomServiceNames); }
public static void ExtendedProtectionPolicy_Propagates_To_TransportBindingElement() { var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); var epp = new ExtendedProtectionPolicy(PolicyEnforcement.Always); binding.Security.Transport.ExtendedProtectionPolicy = epp; var be = binding.CreateBindingElements(); var htbe = be.Find <HttpTransportBindingElement>(); Assert.Equal(epp, htbe.ExtendedProtectionPolicy); }
public HttpListener() { prefixes = new HttpListenerPrefixCollection(this); registry = new Hashtable(); connections = Hashtable.Synchronized(new Hashtable()); ctx_queue = new ArrayList(); wait_queue = new ArrayList(); auth_schemes = AuthenticationSchemes.Anonymous; defaultServiceNames = new ServiceNameStore(); extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); }
public void ConvertTo_PositiveTests() { ExtendedProtectionPolicy policy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); InstanceDescriptor instanceDescriptor = converter.ConvertTo(null, CultureInfo.InvariantCulture, policy, typeof(InstanceDescriptor)) as InstanceDescriptor; ExtendedProtectionPolicy instanceResult = instanceDescriptor.Invoke() as ExtendedProtectionPolicy; Assert.NotNull(instanceDescriptor); Assert.NotNull(instanceResult); Assert.Equal(PolicyEnforcement.Never, instanceResult.PolicyEnforcement); Assert.Equal(policy.ProtectionScenario, instanceResult.ProtectionScenario); Assert.Null(instanceResult.CustomServiceNames); Assert.Equal(string.Empty, converter.ConvertTo(null, CultureInfo.InvariantCulture, null, typeof(string)) as string); Assert.Equal(policy.ToString(), converter.ConvertTo(null, CultureInfo.InvariantCulture, policy, typeof(string)) as string); }
public void ConvertTo_NegativeTests(Type destinationType) { ExtendedProtectionPolicy policy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); Assert.Throws<NotSupportedException>(() => converter.ConvertTo(null, CultureInfo.InvariantCulture, policy, destinationType)); }