Skip to content

Commit

Permalink
fixing WebSocketHelper for tests on browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Katya Sokolova committed Dec 1, 2022
1 parent e913b46 commit 0953346
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<StringResourcesPath>../src/Resources/Strings.resx</StringResourcesPath>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser</TargetFrameworks>
Expand Down Expand Up @@ -70,15 +70,16 @@
<Compile Include="LoopbackHelper.cs" />
<Compile Include="ResourceHelper.cs" />
<Compile Include="SendReceiveTest.cs" />
<Compile Include="SendReceiveTest.Http2.cs" Condition="'$(TargetsBrowser)' == 'false'" />
<Compile Include="SendReceiveTest.Http2.cs" />
<Compile Include="WebSocketData.cs" />
<Compile Include="WebSocketHelper.cs" />
<Compile Include="DeflateTests.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Net.TestData" Version="$(SystemNetTestDataVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\System.Net.Http\ref\System.Net.Http.csproj" />
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Test" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,17 @@ public static Task<ClientWebSocket> GetConnectedWebSocket(
cws.Options.KeepAliveInterval = keepAliveInterval;
}

if (invoker == null)
if (!PlatformDetection.IsBrowser)
{
cws.Options.ClientCertificates.Add(Test.Common.Configuration.Certificates.GetClientCertificate());
cws.Options.RemoteCertificateValidationCallback = delegate { return true; };
if (invoker == null)
{
cws.Options.ClientCertificates.Add(Test.Common.Configuration.Certificates.GetClientCertificate());
cws.Options.RemoteCertificateValidationCallback = delegate { return true; };
}
cws.Options.HttpVersion = version;
cws.Options.HttpVersionPolicy = HttpVersionPolicy.RequestVersionExact;
}

cws.Options.HttpVersion = version;
cws.Options.HttpVersionPolicy = HttpVersionPolicy.RequestVersionExact;

using (var cts = new CancellationTokenSource(timeOutMilliseconds))
{
output.WriteLine("GetConnectedWebSocket: ConnectAsync starting.");
Expand All @@ -119,7 +121,7 @@ public static Task<ClientWebSocket> GetConnectedWebSocket(

public static async Task<T> Retry<T>(ITestOutputHelper output, Func<Task<T>> func)
{
const int MaxTries = 1;
const int MaxTries = 5;
int betweenTryDelayMilliseconds = 1000;

for (int i = 1; ; i++)
Expand Down

0 comments on commit 0953346

Please sign in to comment.