Skip to content

Commit

Permalink
Add unit test for dotnet#3657
Browse files Browse the repository at this point in the history
  • Loading branch information
imcarolwang committed Jun 12, 2019
1 parent ec33be5 commit 238e469
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using Infrastructure.Common;
using Xunit;

namespace System.ServiceModel.NetTcp.Tests
{
public static class SecurityModeTransportWithMessageCredentialTest
{
[WcfFact]
public static void Init_TransportWithMessageCredentialSecurityMode()
{
NetTcpBinding binding = new NetTcpBinding(SecurityMode.TransportWithMessageCredential);
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
BindingElementCollection bindingElements = binding.CreateBindingElements();
SecurityBindingElement secutityBindingElement = bindingElements.Find<SecurityBindingElement>();

Assert.StrictEqual(binding.Security.Mode, SecurityMode.TransportWithMessageCredential);
Assert.True(secutityBindingElement != null, "SecurityBindingElement should not be null.");

Assert.True(binding.Security.Message.AlgorithmSuite == SecurityAlgorithmSuite.Default, "AlgorithmSuite should be Default.");
Assert.True(binding.Security.Message.ClientCredentialType == MessageCredentialType.UserName, "ClientCredentialType should be UserName.");

binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
Assert.True(binding.Security.Message.ClientCredentialType == MessageCredentialType.Certificate, "ClientCredentialType should be Certifiacte.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.


using System;
using System.Security.Authentication.ExtendedProtection;
using System.ServiceModel.Channels;
using Infrastructure.Common;
using Xunit;
Expand All @@ -21,5 +21,9 @@ public static void Ctor_Default_Properties()
// Validate only a non-null TcpConnectionPoolSetting.
// Its own default values are validated in that type's test methods
Assert.True(element.ConnectionPoolSettings != null, "ConnectionPoolSettings should not be null.");

// Validate a non-null ExtendedProtectionPolicy.
Assert.True(element.ExtendedProtectionPolicy != null, "ExtendedProtectionPolicy should not be null.");

}
}

0 comments on commit 238e469

Please sign in to comment.