Skip to content

Commit 42bc6a5

Browse files
Test coverage improvements (#252)
* Add more data validation to channel metadata tests * Add more detail to Metadata tests * Cleanup RemoveUUIDMetadata test * Add unsubsribe test, improve token tests, small membership tests cleanup * Add WhereNow and Signal CustomType tests * Add new Set/Get/Remove/Manage Memberships integration tests * Add new test for SetPresenceState * Add new file and message count tests * Add delays in metadata tests * Add uuid pattern to TestHarness token granting for testing and tests for Set/Get/Remove/Manage channel members * Add new integration tests + chennel group rule to TestHarness grant token * Add new custom type, download file, and add listener tests * Fix access in object channel metadata tests * Update vulnerable package, remove obsolete payloadContainer from EventEmtitter * Add more asserts to ThenSetRemoveChannelMetadataWithSetRemoveMembershipShouldReturnSuccessCodeAndInfo * Change assertion format in ThenWithAsyncGrantTokenShouldReturnSuccess * Small grant an sub tests tweaks * Test random channel id tweak * Add missing delays, small stability-improving refactor of WhenSubscribedToAChannel tests * Improve random id generation in tests --------- Co-authored-by: PubNub Release Bot <[email protected]>
1 parent 9dd31a3 commit 42bc6a5

28 files changed

+2180
-270
lines changed

.pubnub.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: c-sharp
2-
version: "7.3.11"
2+
version: "7.3.12"
33
schema: 1
44
scm: github.com/pubnub/c-sharp
55
changelog:
6+
- date: 2025-05-28
7+
version: v7.3.12
8+
changes:
9+
- type: feature
10+
text: "Added new integration tests to better cover all SDK endpoints."
11+
- type: bug
12+
text: "Fixed an issue when upon receiving a message with published with a custom type the CustomMessageType would be null upon receiving."
613
- date: 2025-05-20
714
version: v7.3.11
815
changes:
@@ -902,7 +909,7 @@ features:
902909
- QUERY-PARAM
903910
supported-platforms:
904911
-
905-
version: Pubnub 'C#' 7.3.11
912+
version: Pubnub 'C#' 7.3.12
906913
platforms:
907914
- Windows 10 and up
908915
- Windows Server 2008 and up
@@ -913,7 +920,7 @@ supported-platforms:
913920
- .Net Framework 4.6.1+
914921
- .Net Framework 6.0
915922
-
916-
version: PubnubPCL 'C#' 7.3.11
923+
version: PubnubPCL 'C#' 7.3.12
917924
platforms:
918925
- Xamarin.Android
919926
- Xamarin.iOS
@@ -933,7 +940,7 @@ supported-platforms:
933940
- .Net Core
934941
- .Net 6.0
935942
-
936-
version: PubnubUWP 'C#' 7.3.11
943+
version: PubnubUWP 'C#' 7.3.12
937944
platforms:
938945
- Windows Phone 10
939946
- Universal Windows Apps
@@ -957,7 +964,7 @@ sdks:
957964
distribution-type: source
958965
distribution-repository: GitHub
959966
package-name: Pubnub
960-
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.11.0
967+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.12.0
961968
requires:
962969
-
963970
name: ".Net"
@@ -1240,7 +1247,7 @@ sdks:
12401247
distribution-type: source
12411248
distribution-repository: GitHub
12421249
package-name: PubNubPCL
1243-
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.11.0
1250+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.12.0
12441251
requires:
12451252
-
12461253
name: ".Net Core"
@@ -1599,7 +1606,7 @@ sdks:
15991606
distribution-type: source
16001607
distribution-repository: GitHub
16011608
package-name: PubnubUWP
1602-
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.11.0
1609+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.12.0
16031610
requires:
16041611
-
16051612
name: "Universal Windows Platform Development"

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
v7.3.12 - May 28 2025
2+
-----------------------------
3+
- Added: added new integration tests to better cover all SDK endpoints.
4+
5+
- Fixed: fixed an issue when upon receiving a message with published with a custom type the CustomMessageType would be null upon receiving.
6+
17
v7.3.11 - May 20 2025
28
-----------------------------
39
- Fixed: fix missing `heartbeat` and `leave` REST API calls when the event engine is enabled and `presenceTimeout` or `presenceHeartbeatInterval` not set.

src/Api/PubnubApi/EventEngine/Common/EventEmitter.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,9 @@ public void EmitEvent<T>(object e)
132132
{
133133
payload = eventData?.Payload;
134134
}
135-
136-
List<object> payloadContainer = new List<object>(); //First item always message
135+
137136
if (currentMessageChannel.Contains("-pnpres") || currentMessageChannel.Contains(".*-pnpres"))
138137
{
139-
payloadContainer.Add(payload);
140138
jsonFields.Add("payload", payload);
141139
}
142140
else if (eventData.MessageType == 2) //Objects Simplification events
@@ -150,7 +148,6 @@ public void EmitEvent<T>(object e)
150148
{
151149
if (objectsVersion.CompareTo(2D) == 0) //Process only version=2 for Objects Simplification. Ignore 1.
152150
{
153-
payloadContainer.Add(payload);
154151
jsonFields.Add("payload", payload);
155152
}
156153
}
@@ -172,7 +169,6 @@ public void EmitEvent<T>(object e)
172169
}
173170

174171
object decodeMessage = jsonLibrary.DeserializeToObject((decryptMessage == "**DECRYPT ERROR**") ? jsonLibrary.SerializeToJsonString(payload) : decryptMessage);
175-
payloadContainer.Add(decodeMessage);
176172
jsonFields.Add("payload", decodeMessage);
177173
}
178174
else
@@ -181,33 +177,27 @@ public void EmitEvent<T>(object e)
181177
object payloadJObject = jsonLibrary.BuildJsonObject(payloadJson);
182178
if (payloadJObject == null)
183179
{
184-
payloadContainer.Add(payload);
185180
jsonFields.Add("payload", payload);
186181
}
187182
else
188183
{
189-
payloadContainer.Add(payloadJObject);
190184
jsonFields.Add("payload", payloadJObject);
191185
}
192186
}
193187
}
194188

195189
var userMetaData = eventData.UserMetadata;
196-
payloadContainer.Add(userMetaData); //Second one always user meta data
197190
jsonFields.Add("userMetadata", userMetaData);
198-
payloadContainer.Add(GetTimetokenMetadata(eventData.PublishMetadata).Timetoken); //Third one always Timetoken - 2
199191
jsonFields.Add("publishTimetoken", GetTimetokenMetadata(eventData.PublishMetadata).Timetoken);
200-
payloadContainer.Add(eventData.IssuingClientId); //Fourth one always Publisher
201-
jsonFields.Add("userId", eventData.IssuingClientId); // - 3
192+
jsonFields.Add("userId", eventData.IssuingClientId);
202193

203-
payloadContainer.Add(currentMessageChannelGroup);
204-
payloadContainer.Add(currentMessageChannel);
194+
jsonFields.Add("currentMessageChannelGroup", currentMessageChannelGroup);
195+
jsonFields.Add("currentMessageChannel", currentMessageChannel);
205196

206197
switch (eventData.MessageType)
207198
{
208199
case 1:
209200
{
210-
payloadContainer.Add(eventData.CustomMessageType);
211201
jsonFields.Add("customMessageType", eventData.CustomMessageType);
212202
ResponseBuilder responseBuilder = new ResponseBuilder(configuration, jsonLibrary);
213203
PNMessageResult<T> pnMessageResult = responseBuilder.GetEventResultObject<PNMessageResult<T>>(jsonFields);
@@ -308,7 +298,7 @@ public void EmitEvent<T>(object e)
308298
}
309299
case 4:
310300
{
311-
payloadContainer.Add(eventData.CustomMessageType);
301+
jsonFields.Add("customMessageType", eventData.CustomMessageType);
312302
ResponseBuilder responseBuilder =new ResponseBuilder(configuration, jsonLibrary);
313303
PNMessageResult<object> filesEvent = responseBuilder.GetEventResultObject<PNMessageResult<object>>(jsonFields);
314304
if (filesEvent != null)
@@ -404,7 +394,7 @@ public void EmitEvent<T>(object e)
404394
}
405395
else
406396
{
407-
payloadContainer.Add(eventData.CustomMessageType);
397+
jsonFields.Add("customMessageType", eventData.CustomMessageType);
408398
ResponseBuilder responseBuilder =new ResponseBuilder(configuration, jsonLibrary);
409399
PNMessageResult<T> userMessage = responseBuilder.GetEventResultObject<PNMessageResult<T>>(jsonFields);
410400
try

src/Api/PubnubApi/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
[assembly: AssemblyProduct("Pubnub C# SDK")]
1212
[assembly: AssemblyCopyright("Copyright © 2021")]
1313
[assembly: AssemblyTrademark("")]
14-
[assembly: AssemblyVersion("7.3.11.0")]
15-
[assembly: AssemblyFileVersion("7.3.11.0")]
14+
[assembly: AssemblyVersion("7.3.12.0")]
15+
[assembly: AssemblyFileVersion("7.3.12.0")]
1616
// Setting ComVisible to false makes the types in this assembly not visible
1717
// to COM components. If you need to access a type in this assembly from
1818
// COM, set the ComVisible attribute to true on that type.

src/Api/PubnubApi/PubnubApi.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414

1515
<PropertyGroup>
1616
<PackageId>Pubnub</PackageId>
17-
<PackageVersion>7.3.11.0</PackageVersion>
17+
<PackageVersion>7.3.12.0</PackageVersion>
1818
<Title>PubNub C# .NET - Web Data Push API</Title>
1919
<Authors>Pandu Masabathula</Authors>
2020
<Owners>PubNub</Owners>
2121
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2222
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
2323
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2424
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
25-
<PackageReleaseNotes>Fix missing `heartbeat` and `leave` REST API calls when the event engine is enabled and `presenceTimeout` or `presenceHeartbeatInterval` not set.</PackageReleaseNotes>
25+
<PackageReleaseNotes>Fixed an issue when upon receiving a message with published with a custom type the CustomMessageType would be null upon receiving.
26+
Added new integration tests to better cover all SDK endpoints.</PackageReleaseNotes>
2627
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
2728
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
2829
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>

src/Api/PubnubApiPCL/PubnubApiPCL.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414

1515
<PropertyGroup>
1616
<PackageId>PubnubPCL</PackageId>
17-
<PackageVersion>7.3.11.0</PackageVersion>
17+
<PackageVersion>7.3.12.0</PackageVersion>
1818
<Title>PubNub C# .NET - Web Data Push API</Title>
1919
<Authors>Pandu Masabathula</Authors>
2020
<Owners>PubNub</Owners>
2121
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2222
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
2323
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2424
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
25-
<PackageReleaseNotes>Fix missing `heartbeat` and `leave` REST API calls when the event engine is enabled and `presenceTimeout` or `presenceHeartbeatInterval` not set.</PackageReleaseNotes>
25+
<PackageReleaseNotes>Fixed an issue when upon receiving a message with published with a custom type the CustomMessageType would be null upon receiving.
26+
Added new integration tests to better cover all SDK endpoints.</PackageReleaseNotes>
2627
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
2728
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
2829
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>

src/Api/PubnubApiUWP/PubnubApiUWP.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616

1717
<PropertyGroup>
1818
<PackageId>PubnubUWP</PackageId>
19-
<PackageVersion>7.3.11.0</PackageVersion>
19+
<PackageVersion>7.3.12.0</PackageVersion>
2020
<Title>PubNub C# .NET - Web Data Push API</Title>
2121
<Authors>Pandu Masabathula</Authors>
2222
<Owners>PubNub</Owners>
2323
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2424
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
2525
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2626
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
27-
<PackageReleaseNotes>Fix missing `heartbeat` and `leave` REST API calls when the event engine is enabled and `presenceTimeout` or `presenceHeartbeatInterval` not set.</PackageReleaseNotes>
27+
<PackageReleaseNotes>Fixed an issue when upon receiving a message with published with a custom type the CustomMessageType would be null upon receiving.
28+
Added new integration tests to better cover all SDK endpoints.</PackageReleaseNotes>
2829
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
2930
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
3031
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>

src/Api/PubnubApiUnity/PubnubApiUnity.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<PropertyGroup>
1717
<PackageId>PubnubApiUnity</PackageId>
18-
<PackageVersion>7.3.11.0</PackageVersion>
18+
<PackageVersion>7.3.12.0</PackageVersion>
1919
<Title>PubNub C# .NET - Web Data Push API</Title>
2020
<Authors>Pandu Masabathula</Authors>
2121
<Owners>PubNub</Owners>

src/UnitTests/PubnubApi.Tests/EncryptionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,14 +995,14 @@ public void TestSubscribeDecryptionOnNonEncryptedMessage()
995995

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

998-
Thread.Sleep(1000);
998+
Thread.Sleep(2000);
999999

10001000
CreateTestSender().Publish()
10011001
.Channel("test")
10021002
.Message("test")
10031003
.Execute(new PNPublishResultExt((r,s)=>{}));
10041004

1005-
bool passed = done.WaitOne(5000);
1005+
bool passed = done.WaitOne(6500);
10061006
Assert.True(passed);
10071007
}
10081008

src/UnitTests/PubnubApi.Tests/PubnubApi.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
</EmbeddedResource>
9292
</ItemGroup>
9393

94+
<ItemGroup>
95+
<None Update="file_large.png">
96+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
97+
</None>
98+
</ItemGroup>
99+
94100
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
95101
<Exec Command="copy $(ProjectDir)fileupload.txt $(ProjectDir)$(OutDir)" />
96102
<Exec Command="copy $(ProjectDir)fileupload_enc.txt $(ProjectDir)$(OutDir)" />

src/UnitTests/PubnubApi.Tests/TestHarness.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public static async Task GenerateTestGrantToken(Pubnub pubnub, string presenceTe
5050
string channel4 = "hello_my_channel_4";
5151
string group = "hello_my_group";
5252
string channelPattern = "foo.*";
53+
string channelGroupPattern = "foo.*";
54+
string uuidPattern = "fuu.*";
5355

5456
var fullAccess = new PNTokenAuthValues()
5557
{
@@ -116,6 +118,14 @@ public static async Task GenerateTestGrantToken(Pubnub pubnub, string presenceTe
116118
{
117119
{ channelPattern, fullAccess },
118120
{ channelPattern+"-pnpres", fullAccess }
121+
},
122+
Uuids = new Dictionary<string, PNTokenAuthValues>()
123+
{
124+
{uuidPattern, fullAccess}
125+
},
126+
ChannelGroups = new Dictionary<string, PNTokenAuthValues>()
127+
{
128+
{channelGroupPattern, fullAccess}
119129
}
120130
})
121131
.ExecuteAsync();

0 commit comments

Comments
 (0)