forked from dotnet/wcf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding primary scenario test for Issue dotnet#366
* Added a property in BridgeClientCertificateManager to hold the thumbprint of the ClientCertificate so that a test case can get it. * Test sets the DnsEndpointIdentity to "localhost" which means this will only work when the Bridge and the test run on the same machine. * Hong has a PR that adds a resource to the Bridge that will return the server Identity. I will update this PR to use that Resource once her PR is merged, before I merge this one. * Test currently fails due to Issue dotnet#458, added ActiveIssue
- Loading branch information
1 parent
63878df
commit d3fe641
Showing
6 changed files
with
149 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 45 additions & 41 deletions
86
...eModel/tests/Scenarios/Security/TransportSecurity/Security.TransportSecurity.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<TestCategories>OuterLoop</TestCategories> | ||
</PropertyGroup> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> | ||
<PropertyGroup> | ||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Security.TransportSecurity.Tests</RootNamespace> | ||
<AssemblyName>Security.TransportSecurity.Tests</AssemblyName> | ||
<SignAssembly>false</SignAssembly> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<ProjectGuid>{452BA2A7-81AD-4146-AD02-35EC242FF0EB}</ProjectGuid> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Https\ClientCredentialTypeTests.cs" /> | ||
<Compile Include="Https\HttpsTests.cs" /> | ||
<Compile Include="Tcp\ClientCredentialTypeTests.cs" /> | ||
<Compile Include="Tcp\IdentityTests.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="project.json" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<!-- Compile tests against the contract, but copy our local-built implementation for testing --> | ||
<ProjectReference Include="$(WcfSourceProj)"> | ||
<Project>{9e50e7bf-cd6e-4269-a6dd-59fd0bd6c0fd}</Project> | ||
<Name>System.Private.ServiceModel</Name> | ||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
<OutputItemType>Content</OutputItemType> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<Targets>Build;DebugSymbolsProjectOutputGroup</Targets> | ||
</ProjectReference> | ||
<ProjectReference Include='$(WcfScenarioTestCommonProj)'> | ||
<Project>{9098B41C-9C2E-4FC6-B7D8-FC3411736A22}</Project> | ||
<Name>ScenarioTests.Common</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> | ||
<PropertyGroup> | ||
<TestCategories>OuterLoop</TestCategories> | ||
</PropertyGroup> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> | ||
<PropertyGroup> | ||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Security.TransportSecurity.Tests</RootNamespace> | ||
<AssemblyName>Security.TransportSecurity.Tests</AssemblyName> | ||
<SignAssembly>false</SignAssembly> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<ProjectGuid>{452BA2A7-81AD-4146-AD02-35EC242FF0EB}</ProjectGuid> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Https\ClientCredentialTypeTests.cs" /> | ||
<Compile Include="Https\HttpsTests.cs" /> | ||
<Compile Include="Tcp\ClientCredentialTypeTests.cs" /> | ||
<Compile Include="Tcp\IdentityTests.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="project.json" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<!-- Compile tests against the contract, but copy our local-built implementation for testing --> | ||
<ProjectReference Include="$(WcfSourceProj)"> | ||
<Project>{9e50e7bf-cd6e-4269-a6dd-59fd0bd6c0fd}</Project> | ||
<Name>System.Private.ServiceModel</Name> | ||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
<OutputItemType>Content</OutputItemType> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<Targets>Build;DebugSymbolsProjectOutputGroup</Targets> | ||
</ProjectReference> | ||
<ProjectReference Include='$(WcfScenarioTestCommonProj)'> | ||
<Project>{9098B41C-9C2E-4FC6-B7D8-FC3411736A22}</Project> | ||
<Name>ScenarioTests.Common</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="$(WcfInfrastructureCommonProj)"> | ||
<Project>{AFD69665-89A3-42AE-A32E-AB2CBBE6EE7E}</Project> | ||
<Name>Infrastructure.Common</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...elfHostWcfService/TestResources/TcpTransportSecuritySslClientCredentialTypeCertificate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Diagnostics; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
using System.ServiceModel.Security; | ||
using WcfService.CertificateResources; | ||
using WcfTestBridgeCommon; | ||
|
||
namespace WcfService.TestResources | ||
{ | ||
internal class TcpTransportSecuritySslClientCredentialTypeCertificate : TcpResource | ||
{ | ||
protected override string Address { get { return "tcp-server-ssl-security-clientcredentialtype-certificate"; } } | ||
|
||
protected override Binding GetBinding() | ||
{ | ||
NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport); | ||
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; | ||
return binding; | ||
} | ||
|
||
protected override void ModifyHost(ServiceHost serviceHost, ResourceRequestContext context) | ||
{ | ||
// Ensure the https certificate is installed before this endpoint resource is used | ||
string thumbprint = CertificateResourceHelpers.EnsureSslPortCertificateInstalled(context.BridgeConfiguration); | ||
|
||
serviceHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; | ||
serviceHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, | ||
StoreName.My, | ||
X509FindType.FindByThumbprint, | ||
thumbprint); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters