Skip to content

Commit

Permalink
Objectsv2 Acceptance Tests (#157)
Browse files Browse the repository at this point in the history
* objectsv2 acceptance tests

* Content-Type to request header to support acceptance tests
  • Loading branch information
budgetpreneur authored Nov 7, 2022
1 parent eaeb6bb commit d3b3b8a
Show file tree
Hide file tree
Showing 40 changed files with 3,416 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/run_acceptance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:

steps:
- name: Checkout Project
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Checkout mock-server action
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: pubnub/client-engineering-deployment-tools
ref: github-actions
ref: v1
token: ${{ secrets.GH_TOKEN }}
path: client-engineering-deployment-tools

Expand All @@ -51,7 +51,7 @@ jobs:
cd ./UnitTests/AcceptanceTests && dotnet test --no-build --verbosity normal --logger trx --results-directory ./results
- name: Upload acceptance tests reports
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: acceptance-test-reports
path: |
Expand Down
21 changes: 14 additions & 7 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
name: c-sharp
version: "6.10.0"
version: "6.11.0"
schema: 1
scm: github.com/pubnub/c-sharp
changelog:
- date: 2022-11-07
version: v6.11.0
changes:
- type: improvement
text: "Added Content-Type to request header to support internal acceptance tests."
- type: improvement
text: "Added acceptance tests for ObjectsV2 feature."
- date: 2022-09-06
version: v6.10.0
changes:
Expand Down Expand Up @@ -680,7 +687,7 @@ features:
- QUERY-PARAM
supported-platforms:
-
version: Pubnub 'C#' 6.10.0
version: Pubnub 'C#' 6.11.0
platforms:
- Windows 10 and up
- Windows Server 2008 and up
Expand All @@ -690,7 +697,7 @@ supported-platforms:
- .Net Framework 4.5
- .Net Framework 4.6.1+
-
version: PubnubPCL 'C#' 6.10.0
version: PubnubPCL 'C#' 6.11.0
platforms:
- Xamarin.Android
- Xamarin.iOS
Expand All @@ -710,7 +717,7 @@ supported-platforms:
- .Net Core
- .Net 6.0
-
version: PubnubUWP 'C#' 6.10.0
version: PubnubUWP 'C#' 6.11.0
platforms:
- Windows Phone 10
- Universal Windows Apps
Expand All @@ -734,7 +741,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: Pubnub
location: https://github.com/pubnub/c-sharp/releases/tag/v6.10.0.0
location: https://github.com/pubnub/c-sharp/releases/tag/v6.11.0.0
requires:
-
name: ".Net"
Expand Down Expand Up @@ -1017,7 +1024,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubNubPCL
location: https://github.com/pubnub/c-sharp/releases/tag/v6.10.0.0
location: https://github.com/pubnub/c-sharp/releases/tag/v6.11.0.0
requires:
-
name: ".Net Core"
Expand Down Expand Up @@ -1376,7 +1383,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubnubUWP
location: https://github.com/pubnub/c-sharp/releases/tag/v6.10.0.0
location: https://github.com/pubnub/c-sharp/releases/tag/v6.11.0.0
requires:
-
name: "Universal Windows Platform Development"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v6.11.0 - November 07 2022
-----------------------------
- Modified: added Content-Type to request header to support internal acceptance tests.
- Modified: added acceptance tests for ObjectsV2 feature.

v6.10.0 - September 06 2022
-----------------------------
- Fixed: add Users/Spaces support to PCL versions.
Expand Down
2 changes: 1 addition & 1 deletion src/Api/PubnubApi/Interface/IPubnubHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface IPubnubHttp

Task<string> SendRequestAndGetJsonResponseWithPOST<T>(Uri requestUri, RequestState<T> pubnubRequestState, HttpWebRequest request, byte[] postData, string contentType);

Task<string> SendRequestAndGetJsonResponseWithPATCH<T>(Uri requestUri, RequestState<T> pubnubRequestState, HttpWebRequest request, byte[] patchData);
Task<string> SendRequestAndGetJsonResponseWithPATCH<T>(Uri requestUri, RequestState<T> pubnubRequestState, HttpWebRequest request, byte[] patchData, string contentType);

Task<byte[]> SendRequestAndGetStreamResponse<T>(Uri requestUri, RequestState<T> pubnubRequestState, HttpWebRequest request);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
[assembly: AssemblyProduct("Pubnub C# SDK")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("6.10.0.0")]
[assembly: AssemblyFileVersion("6.10.0.0")]
[assembly: AssemblyVersion("6.11.0.0")]
[assembly: AssemblyFileVersion("6.11.0.0")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
Expand Down
5 changes: 3 additions & 2 deletions src/Api/PubnubApi/PubnubApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@

<PropertyGroup>
<PackageId>Pubnub</PackageId>
<PackageVersion>6.10.0.0</PackageVersion>
<PackageVersion>6.11.0.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
<PackageReleaseNotes>Add Users/Spaces support to PCL versions.</PackageReleaseNotes>
<PackageReleaseNotes>Added Content-Type to request header to support internal acceptance tests.
Added acceptance tests for ObjectsV2 feature.</PackageReleaseNotes>
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
<!--<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>-->
<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>
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/PubnubCoreBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ internal protected async Task<Tuple<string, PNStatus>> UrlProcessRequest<T>(Uri
}
else if (pubnubRequestState != null && pubnubRequestState.UsePatchMethod)
{
jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, null, postOrPatchData).ConfigureAwait(false);
jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, null, postOrPatchData, contentType).ConfigureAwait(false);
}
else
{
Expand All @@ -1125,7 +1125,7 @@ internal protected async Task<Tuple<string, PNStatus>> UrlProcessRequest<T>(Uri
}
else if (pubnubRequestState != null && pubnubRequestState.UsePatchMethod)
{
jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, request, postOrPatchData).ConfigureAwait(false);
jsonString = await pubnubHttp.SendRequestAndGetJsonResponseWithPATCH(requestUri, pubnubRequestState, request, postOrPatchData, contentType).ConfigureAwait(false);
}
else
{
Expand Down
28 changes: 21 additions & 7 deletions src/Api/PubnubApi/PubnubHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async Task<string> IPubnubHttp.SendRequestAndGetJsonResponseWithPOST<T>(Uri requ
}
}

async Task<string> IPubnubHttp.SendRequestAndGetJsonResponseWithPATCH<T>(Uri requestUri, RequestState<T> pubnubRequestState, HttpWebRequest request, byte[] patchData)
async Task<string> IPubnubHttp.SendRequestAndGetJsonResponseWithPATCH<T>(Uri requestUri, RequestState<T> pubnubRequestState, HttpWebRequest request, byte[] patchData, string contentType)
{
LoggingMethod.WriteToLog(pubnubLog, string.Format("DateTime: {0}, patchData = {1}", DateTime.Now.ToString(CultureInfo.InvariantCulture), patchData), pubnubConfig.LogVerbosity);
if (pubnubConfig.UseClassicHttpWebRequest)
Expand All @@ -160,14 +160,14 @@ async Task<string> IPubnubHttp.SendRequestAndGetJsonResponseWithPATCH<T>(Uri req
#if !NET35 && !NET40 && !NET45 && !NET461 && !NET48 && !NETSTANDARD10
if (pubnubConfig.UseTaskFactoryAsyncInsteadOfHttpClient)
{
return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData).ConfigureAwait(false);
return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData, contentType).ConfigureAwait(false);
}
else
{
return await SendRequestAndGetJsonResponseHttpClientWithPATCH(requestUri, pubnubRequestState, patchData).ConfigureAwait(false);
return await SendRequestAndGetJsonResponseHttpClientWithPATCH(requestUri, pubnubRequestState, patchData, contentType).ConfigureAwait(false);
}
#else
return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData).ConfigureAwait(false);
return await SendRequestAndGetJsonResponseTaskFactoryWithPATCH(pubnubRequestState, request, patchData, contentType).ConfigureAwait(false);
#endif
}
}
Expand Down Expand Up @@ -447,7 +447,7 @@ async Task<string> SendRequestAndGetJsonResponseHttpClientWithPOST<T>(Uri reques
return jsonString;
}

async Task<string> SendRequestAndGetJsonResponseHttpClientWithPATCH<T>(Uri requestUri, RequestState<T> pubnubRequestState, byte[] patchData)
async Task<string> SendRequestAndGetJsonResponseHttpClientWithPATCH<T>(Uri requestUri, RequestState<T> pubnubRequestState, byte[] patchData, string contentType)
{
string jsonString = "";
HttpResponseMessage response = null;
Expand All @@ -459,9 +459,20 @@ async Task<string> SendRequestAndGetJsonResponseHttpClientWithPATCH<T>(Uri reque
System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
HttpMethod httpMethod = new HttpMethod("PATCH");
ByteArrayContent patchDataContent = new ByteArrayContent(patchData);
patchDataContent.Headers.Remove("Content-Type");
if (string.IsNullOrEmpty(contentType))
{
patchDataContent.Headers.TryAddWithoutValidation("Content-Type", "application/json");
}
else
{
patchDataContent.Headers.TryAddWithoutValidation("Content-Type", contentType);
}

HttpRequestMessage requestMsg = new HttpRequestMessage(httpMethod, requestUri)
{
Content = new ByteArrayContent(patchData)
Content = patchDataContent
};
if (pubnubRequestState.ResponseType == PNOperationType.PNSubscribeOperation)
{
Expand Down Expand Up @@ -795,7 +806,7 @@ async Task<string> SendRequestAndGetJsonResponseTaskFactoryWithPOST<T>(RequestSt
}
}

async Task<string> SendRequestAndGetJsonResponseTaskFactoryWithPATCH<T>(RequestState<T> pubnubRequestState, HttpWebRequest request, byte[] patchData)
async Task<string> SendRequestAndGetJsonResponseTaskFactoryWithPATCH<T>(RequestState<T> pubnubRequestState, HttpWebRequest request, byte[] patchData, string contentType)
{
System.Diagnostics.Debug.WriteLine(string.Format("DateTime {0}, Before Task.Factory.FromAsync With PATCH", DateTime.Now.ToString(CultureInfo.InvariantCulture)));
try
Expand All @@ -807,6 +818,9 @@ async Task<string> SendRequestAndGetJsonResponseTaskFactoryWithPATCH<T>(RequestS
stopWatch.Start();

request.ContentType = "application/json";
#if NET35 || NET40 || NET45 || NET461 || NET48
request.Headers.Add("Content-Type", string.IsNullOrEmpty(contentType) ? "application/json" : contentType);
#endif

using (var requestStream = await Task<Stream>.Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, pubnubRequestState).ConfigureAwait(false))
{
Expand Down
5 changes: 3 additions & 2 deletions src/Api/PubnubApiPCL/PubnubApiPCL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

<PropertyGroup>
<PackageId>PubnubPCL</PackageId>
<PackageVersion>6.10.0.0</PackageVersion>
<PackageVersion>6.11.0.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
<PackageReleaseNotes>Add Users/Spaces support to PCL versions.</PackageReleaseNotes>
<PackageReleaseNotes>Added Content-Type to request header to support internal acceptance tests.
Added acceptance tests for ObjectsV2 feature.</PackageReleaseNotes>
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
<!--<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>-->
<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>
Expand Down
5 changes: 3 additions & 2 deletions src/Api/PubnubApiUWP/PubnubApiUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

<PropertyGroup>
<PackageId>PubnubUWP</PackageId>
<PackageVersion>6.10.0.0</PackageVersion>
<PackageVersion>6.11.0.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
<PackageReleaseNotes>Add Users/Spaces support to PCL versions.</PackageReleaseNotes>
<PackageReleaseNotes>Added Content-Type to request header to support internal acceptance tests.
Added acceptance tests for ObjectsV2 feature.</PackageReleaseNotes>
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
<!--<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>-->
<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>
Expand Down
52 changes: 52 additions & 0 deletions src/UnitTests/AcceptanceTests/AcceptanceTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,62 @@
<ItemGroup>
<Folder Include="Drivers\" />
<Folder Include="Hooks\" />
<Folder Include="Data\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Api\PubnubApiPCL\PubnubApiPCL.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Data\alice.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\ameliamember.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\bob.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\chat.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\chatmembership.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\dm.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\dmmembership.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\evamember.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\james.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\lisa.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\olivermember.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\patient.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\patientmembership.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\petermember.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\vipchat.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\vipchatmembership.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/UnitTests/AcceptanceTests/Data/alice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Alice",
"email": "[email protected]",
"externalId": "410b802b-7f18-4a79-b788-f34b7e600cf2",
"profileUrl": "http://fWOkYZQfM.com",
"id": "alice-id",
"updated": "2022-09-16T11:51:53.316718Z",
"type": "admin",
"status": "active",
"eTag": "Afrav42WqsmyZA"
}
9 changes: 9 additions & 0 deletions src/UnitTests/AcceptanceTests/Data/ameliamember.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"uuid": {
"id": "amelia-id"
},
"status": null,
"custom": null,
"updated": "2022-10-12T10:57:19.618621Z",
"eTag": "AZO/t53al7m8fw"
}
15 changes: 15 additions & 0 deletions src/UnitTests/AcceptanceTests/Data/bob.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Bob",
"email": "[email protected]",
"externalId": "410b802b-7f18-1337-b788-f34b7e600cf2",
"profileUrl": "http://fWOkYZQfX.com",
"id": "bob-id",
"custom": {
"uuid_param1": "val1",
"uuid_param2": "val2"
},
"type": "participant",
"status": "active",
"updated": "2022-02-22T11:51:53.316718Z",
"eTag": "Afrav42WQsmyZA"
}
9 changes: 9 additions & 0 deletions src/UnitTests/AcceptanceTests/Data/chat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Chat",
"id": "chat-id",
"description": "chat-description",
"updated": "2022-09-16T11:51:53.316718Z",
"eTag": "Afrav42WqsmyZA",
"type": "GroupChat",
"status": "active"
}
Loading

0 comments on commit d3b3b8a

Please sign in to comment.