Skip to content

Commit

Permalink
test:fix: subscribe tests grant token access
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohit Tejani authored and Mohit Tejani committed Feb 7, 2025
1 parent a986caf commit a1839f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
32 changes: 4 additions & 28 deletions src/UnitTests/PubnubApi.Tests/WhenSubscribedToAChannel3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,39 +82,15 @@ public static async Task Init()
.WithParameter("signature", "hc7IKhEB7tyL6ENR3ndOOlHqPIG3RmzxwJMSGpofE6Q=")
.WithResponse(expected)
.WithStatusCode(System.Net.HttpStatusCode.OK));

var authValues = new PNTokenAuthValues()
if (string.IsNullOrEmpty(PubnubCommon.GrantToken))
{
Read = true,
Write = true,
Create = true,
Get = true,
Delete = true,
Join = true,
Update = true,
Manage = true
};
var grantTokenResult = await pubnub.GrantToken().TTL(20).AuthorizedUuid(config.UserId).Resources(
new PNTokenResources() {
Channels = new Dictionary<string, PNTokenAuthValues>()
{
{
channel,authValues
},
{
channel2,authValues
}
}
}).ExecuteAsync();
await Task.Delay(4000);

authToken = grantTokenResult.Result?.Token;
await GenerateTestGrantToken(pubnub);
}
authToken = PubnubCommon.GrantToken;

pubnub.Destroy();
pubnub.PubnubUnitTest = null;
pubnub = null;

Assert.IsTrue(grantTokenResult.Status.Error == false && grantTokenResult.Result != null, "WhenSubscribedToAChannel3 Grant access failed.");
}

[TearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ public static async Task ThenSubscribeShouldReturnWildCardPresenceEventInWildcar
{
{ "foo.*", fullAccess },
{ "foo.*-pnpres", fullAccess }
}, ChannelGroups = new Dictionary<string, PNTokenAuthValues>()
{
{ "hello_my_group", fullAccess },
{ "hello_my_group-pnpres", fullAccess }
}
})
.ExecuteAsync();
Expand Down

0 comments on commit a1839f2

Please sign in to comment.