Skip to content

Commit 7bd88d8

Browse files
committed
Add MultiCredentialSecurityTokenManager to handle service certificates and fix tests
2 parents 8e93440 + f2cb5ff commit 7bd88d8

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

src/System.Private.ServiceModel/tests/Common/Scenarios/ScenarioTestHelpers.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ public static void CloseCommunicationObjects(params ICommunicationObject[] objec
210210
{
211211
comObj.Abort();
212212
}
213+
catch (System.Net.WebSockets.WebSocketException)
214+
{
215+
// WCF Client has a bug which throws WebSocketException when the server closes the connection.
216+
// The remote party closed the WebSocket connection without completing the close handshake.
217+
comObj.Abort();
218+
}
213219
}
214220
}
215221

src/System.Private.ServiceModel/tests/Scenarios/Extensibility/WebSockets/WebSocketTests.4.1.0.cs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ public static void WebSocket_Http_Duplex_Buffered(NetHttpMessageEncoding message
168168
"The logging done by the Server was not returned via the Callback.");
169169

170170
// *** CLEANUP *** \\
171-
((ICommunicationObject)client).Close();
172-
channelFactory.Close();
171+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
172+
if (!ScenarioTestHelpers.IsLocalHost())
173+
{
174+
((ICommunicationObject)client).Close();
175+
channelFactory.Close();
176+
}
173177
}
174178
finally
175179
{
@@ -236,8 +240,12 @@ public static void WebSocket_Http_Duplex_Buffered_KeepAlive(NetHttpMessageEncodi
236240
"The logging done by the Server was not returned via the Callback.");
237241

238242
// *** CLEANUP *** \\
239-
((ICommunicationObject)client).Close();
240-
channelFactory.Close();
243+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
244+
if (!ScenarioTestHelpers.IsLocalHost())
245+
{
246+
((ICommunicationObject)client).Close();
247+
channelFactory.Close();
248+
}
241249
}
242250
finally
243251
{
@@ -471,7 +479,7 @@ public static void WebSocket_Http_RequestReply_Streamed(NetHttpMessageEncoding m
471479
}
472480

473481
// *** CLEANUP *** \\
474-
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method.
482+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
475483
if (!ScenarioTestHelpers.IsLocalHost())
476484
{
477485
((ICommunicationObject)client).Close();
@@ -529,9 +537,13 @@ public static void WebSocket_Http_RequestReply_Buffered(NetHttpMessageEncoding m
529537
}
530538

531539
// *** CLEANUP *** \\
540+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
541+
if (!ScenarioTestHelpers.IsLocalHost())
542+
{
532543
((ICommunicationObject)client).Close();
533544
channelFactory.Close();
534545
}
546+
}
535547
finally
536548
{
537549
// *** ENSURE CLEANUP *** \\
@@ -583,7 +595,7 @@ public static void WebSocket_Http_RequestReply_Buffered_KeepAlive(NetHttpMessage
583595
}
584596

585597
// *** CLEANUP *** \\
586-
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method.
598+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
587599
if (!ScenarioTestHelpers.IsLocalHost())
588600
{
589601
((ICommunicationObject)client).Close();
@@ -642,8 +654,12 @@ public static void WebSocket_Https_RequestReply_Buffered(NetHttpMessageEncoding
642654
}
643655

644656
// *** CLEANUP *** \\
645-
((ICommunicationObject)client).Close();
646-
channelFactory.Close();
657+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
658+
if (!ScenarioTestHelpers.IsLocalHost())
659+
{
660+
((ICommunicationObject)client).Close();
661+
channelFactory.Close();
662+
}
647663
}
648664
finally
649665
{
@@ -699,8 +715,12 @@ public static void WebSocket_Https_RequestReply_Buffered_KeepAlive(NetHttpMessag
699715
}
700716

701717
// *** CLEANUP *** \\
702-
((ICommunicationObject)client).Close();
703-
channelFactory.Close();
718+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
719+
if (!ScenarioTestHelpers.IsLocalHost())
720+
{
721+
((ICommunicationObject)client).Close();
722+
channelFactory.Close();
723+
}
704724
}
705725
finally
706726
{
@@ -865,8 +885,12 @@ public static void WebSocket_Http_VerifyWebSocketsUsed()
865885
Assert.True(responseFromService, String.Format("Response from the service was not expected. Expected: 'True' but got {0}", responseFromService));
866886

867887
// *** CLEANUP *** \\
868-
((ICommunicationObject)client).Close();
869-
channelFactory.Close();
888+
// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
889+
if (!ScenarioTestHelpers.IsLocalHost())
890+
{
891+
((ICommunicationObject)client).Close();
892+
channelFactory.Close();
893+
}
870894
}
871895
finally
872896
{

0 commit comments

Comments
 (0)