Skip to content

Commit

Permalink
Fix potentially faulty async calls in EncryptionTests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-grzesiowski committed May 23, 2024
1 parent 59ad21a commit 398d21c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
24 changes: 9 additions & 15 deletions src/UnitTests/PubnubApi.Tests/EncryptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
using System.Collections.Generic;
using NUnit.Framework;
using PubnubApi;
using System.Text.RegularExpressions;
using System.Globalization;
using Newtonsoft.Json;
using System.Diagnostics;
using System.Linq;
using PeterO.Cbor;
using PubnubApi.Security.Crypto;
using PubnubApi.Security.Crypto.Cryptors;
using PubnubApi.Security.Crypto.Common;
using System.Threading;
using System.Security.Policy;
using System.Threading.Tasks;
using MockServer;

namespace PubNubMessaging.Tests
Expand Down Expand Up @@ -838,7 +832,7 @@ public void TestPAMv3Signature()
}

[Test]
public async Task TestSubscribeDecryption()
public void TestSubscribeDecryption()
{
server.ClearRequests();
server.Start();
Expand Down Expand Up @@ -906,24 +900,24 @@ public async Task TestSubscribeDecryption()
.WithResponse(expectedMessage)
.WithStatusCode(System.Net.HttpStatusCode.OK));

await Task.Delay(1000);
Thread.Sleep(1000);

pn.Subscribe<string>().Channels(new[] { "test" }).Execute();

await Task.Delay(1000);
Thread.Sleep(1000);

// Rust generated encrypted message
await CreateTestSender().Publish()
CreateTestSender().Publish()
.Channel("test")
.Message("UE5FRAFBQ1JIEALf+E65kseYJwTw2J6BUk9MePHiCcBCS+8ykXLkBIOA")
.ExecuteAsync();
.Execute(new PNPublishResultExt((r,s)=>{}));

bool passed = done.WaitOne(5000);
Assert.True(passed);
}

[Test]
public async Task TestSubscribeDecryptionOnNonEncryptedMessage()
public void TestSubscribeDecryptionOnNonEncryptedMessage()
{
server.ClearRequests();
server.Start();
Expand Down Expand Up @@ -991,12 +985,12 @@ public async Task TestSubscribeDecryptionOnNonEncryptedMessage()

pn.Subscribe<string>().Channels(new[] { "test" }).Execute();

await Task.Delay(1000);
Thread.Sleep(1000);

await CreateTestSender().Publish()
CreateTestSender().Publish()
.Channel("test")
.Message("test")
.ExecuteAsync();
.Execute(new PNPublishResultExt((r,s)=>{}));

bool passed = done.WaitOne(5000);
Assert.True(passed);
Expand Down
3 changes: 2 additions & 1 deletion src/UnitTests/PubnubApi.Tests/WhenObjectMembership.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,8 @@ public static async Task ThenWithAsyncSetRemoveChannelMetadataWithSetRemoveMembe
}


[Test]
//TODO: CLEN-2037
//[Test]
public static void ThenManageMembershipShouldReturnEventInfo()
{
server.ClearRequests();
Expand Down

0 comments on commit 398d21c

Please sign in to comment.