Skip to content

Commit

Permalink
Fix Duplex Channel shaped tests using http.
Browse files Browse the repository at this point in the history
* One test was using the wrong binding, both needed seperate endpoints on the server configured to receive incoming messages using websockets.
  • Loading branch information
StephenBonikowsky committed Nov 9, 2016
1 parent 8c22c3f commit 5446748
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public static string HttpBaseAddress_NetHttp
get { return GetEndpointAddress("NetHttp.svc//NetHttp"); }
}

public static string HttpBaseAddress_NetHttpWebSockets
{
get { return GetEndpointAddress("NetHttpWebSockets.svc//NetHttpWebSockets"); }
}

public static string HttpSoap11_Address
{
get { return GetEndpointAddress("HttpSoap11.svc//http-soap11"); }
Expand Down Expand Up @@ -258,6 +263,14 @@ public static string HttpBaseAddress_NetHttps
}
}

public static string HttpBaseAddress_NetHttpsWebSockets
{
get
{
return GetEndpointAddress("NetHttpsWebSockets.svc//NetHttpsWebSockets", protocol: "https");
}
}

public static string Https_SecModeTrans_ClientCredTypeNone_ServerCertValModePeerTrust_Address
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public partial class DuplexChannelShapeTests : ConditionalWcfTest
[WcfFact]
[Condition(nameof(Root_Certificate_Installed))]
[OuterLoop]
[Issue(1157)]
public static void IDuplexSessionChannel_Https_NetHttpsBinding()
{
IChannelFactory<IDuplexSessionChannel> factory = null;
Expand All @@ -34,7 +33,7 @@ public static void IDuplexSessionChannel_Https_NetHttpsBinding()
factory.Open();

// Create the channel.
channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps));
channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttpsWebSockets));
channel.Open();

// Create the Message object to send to the service.
Expand Down Expand Up @@ -76,8 +75,7 @@ public static void IDuplexSessionChannel_Https_NetHttpsBinding()
[WcfFact]
[Condition(nameof(Root_Certificate_Installed))]
[OuterLoop]
[Issue(1157)]
public static void IDuplexSessionChannel_Http_BasicHttpBinding()
public static void IDuplexSessionChannel_Http_NetHttpBinding()
{
IChannelFactory<IDuplexSessionChannel> factory = null;
IDuplexSessionChannel channel = null;
Expand All @@ -86,14 +84,14 @@ public static void IDuplexSessionChannel_Http_BasicHttpBinding()
try
{
// *** SETUP *** \\
BasicHttpBinding binding = new BasicHttpBinding();
NetHttpBinding binding = new NetHttpBinding();

// Create the channel factory
factory = binding.BuildChannelFactory<IDuplexSessionChannel>(new BindingParameterCollection());
factory.Open();

// Create the channel.
channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps));
channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttpWebSockets));
channel.Open();

// Create the Message object to send to the service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,30 @@ public NetHttpTestServiceHost(Type serviceType, params Uri[] baseAddresses)
{
}
}

public class NetHttpTestServiceHostUsingWebSocketsFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
NetHttpTestServiceHostUsingWebSockets serviceHost = new NetHttpTestServiceHostUsingWebSockets(serviceType, baseAddresses);
return serviceHost;
}
}

public class NetHttpTestServiceHostUsingWebSockets : TestServiceHostBase<IWcfService>
{
protected override string Address { get { return "NetHttpWebSockets"; } }

protected override Binding GetBinding()
{
var binding = new NetHttpBinding();
binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always;
return binding;
}

public NetHttpTestServiceHostUsingWebSockets(Type serviceType, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,29 @@ public NetHttpsTestServiceHost(Type serviceType, params Uri[] baseAddresses)
{
}
}

public class NetHttpsTestServiceHostUsingWebSocketsFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
NetHttpsTestServiceHostUsingWebSockets serviceHost = new NetHttpsTestServiceHostUsingWebSockets(serviceType, baseAddresses);
return serviceHost;
}
}
public class NetHttpsTestServiceHostUsingWebSockets : TestServiceHostBase<IWcfService>
{
protected override string Address { get { return "NetHttpsWebSockets"; } }

protected override Binding GetBinding()
{
var binding = new NetHttpsBinding();
binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always;
return binding;
}

public NetHttpsTestServiceHostUsingWebSockets(Type serviceType, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
<add factory="WcfService.HttpsWindowsTestServiceHostFactory" service="WcfService.WcfService" relativeAddress="~\WindowAuthenticationNegotiate\HttpsWindows.svc" />
<add factory="WcfService.HttpWindowsTestServiceHostFactory" service="WcfService.WcfService" relativeAddress="~\WindowAuthenticationNegotiate\HttpWindows.svc" />
<add factory="WcfService.NetHttpTestServiceHostFactory" service="WcfService.WcfService" relativeAddress="~\NetHttp.svc" />
<add factory="WcfService.NetHttpTestServiceHostUsingWebSocketsFactory" service="WcfService.WcfService" relativeAddress="~\NetHttpWebSockets.svc" />
<add factory="WcfService.NetHttpsTestServiceHostFactory" service="WcfService.WcfService" relativeAddress="~\NetHttps.svc" />
<add factory="WcfService.NetHttpsTestServiceHostUsingWebSocketsFactory" service="WcfService.WcfService" relativeAddress="~\NetHttpsWebSockets.svc" />
<add factory="WcfService.HttpsCertificateValidationPeerTrustTestServiceHostFactory" service="WcfService.WcfService" relativeAddress="~\HttpsCertValModePeerTrust.svc" />
<add factory="WcfService.HttpsCertificateValidationChainTrustTestServiceHostFactory" service="WcfService.WcfService" relativeAddress="~\HttpsCertValModeChainTrust.svc" />
<add factory="WcfService.ServiceContractAsyncIntOutTestServiceHostFactory" service="WcfService.ServiceContractIntOutService" relativeAddress="~\ServiceContractAsyncIntOut.svc" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ private static void Main()
CreateHost<HttpsWindowsTestServiceHost, WcfService.WcfService>("WindowAuthenticationNegotiate/HttpsWindows.svc", httpsBaseAddress);
CreateHost<HttpWindowsTestServiceHost, WcfService.WcfService>("WindowAuthenticationNegotiate/HttpWindows.svc", httpBaseAddress);
CreateHost<NetHttpTestServiceHost, WcfService.WcfService>("NetHttp.svc", httpBaseAddress);
CreateHost<NetHttpTestServiceHostUsingWebSockets, WcfService.WcfService>("NetHttpWebSockets.svc", httpBaseAddress);
CreateHost<NetHttpsTestServiceHost, WcfService.WcfService>("NetHttps.svc", httpsBaseAddress);
CreateHost<NetHttpsTestServiceHostUsingWebSockets, WcfService.WcfService>("NetHttpsWebSockets.svc", httpsBaseAddress);
CreateHost<HttpsCertificateValidationPeerTrustTestServiceHost, WcfService.WcfService>("HttpsCertValModePeerTrust.svc", httpsBaseAddress);
CreateHost<HttpsCertificateValidationChainTrustTestServiceHost, WcfService.WcfService>("HttpsCertValModeChainTrust.svc", httpsBaseAddress);
CreateHost<ServiceContractAsyncIntOutTestServiceHost, ServiceContractIntOutService>("ServiceContractAsyncIntOut.svc", httpBaseAddress);
Expand Down

0 comments on commit 5446748

Please sign in to comment.