Skip to content

Commit

Permalink
feat: add PublisherOnly role
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed May 14, 2024
1 parent d4e4f3e commit 7714306
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion OpenTok/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ public enum Role
/// mute audio in published streams. See the
/// <a href="https://tokbox.com/developer/guides/moderation/">Moderation developer guide</a>.
/// </summary>
MODERATOR
MODERATOR,
/// <summary>
/// A publisher-only role can publish streams, but not signal.
/// </summary>
PUBLISHERONLY,
}

/// <summary>
Expand Down
12 changes: 8 additions & 4 deletions OpenTokTest/TokenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ public void GenerateTokenTest()
Assert.Equal(data["role"], "publisher");
}

[Fact]
public void GenerateTokenWithRoleTest()
[Theory]
[InlineData(Role.SUBSCRIBER, "subscriber")]
[InlineData(Role.PUBLISHER, "publisher")]
[InlineData(Role.MODERATOR, "moderator")]
[InlineData(Role.PUBLISHERONLY, "publisheronly")]
public void GenerateTokenWithRoleTest(Role role, string expectedRole)
{
OpenTok opentok = new OpenTok(ApiKey, ApiSecret);

String sessionId = "1_MX4xMjM0NTZ-flNhdCBNYXIgMTUgMTQ6NDI6MjMgUERUIDIwMTR-MC40OTAxMzAyNX4";
string token = opentok.GenerateToken(sessionId, role:Role.SUBSCRIBER);
string token = opentok.GenerateToken(sessionId, role: role);

Assert.NotNull(token);
var data = CheckToken(token);
Expand All @@ -42,7 +46,7 @@ public void GenerateTokenWithRoleTest()
Assert.NotNull(data["sig"]);
Assert.NotNull(data["create_time"]);
Assert.NotNull(data["nonce"]);
Assert.Equal(data["role"], "subscriber");
Assert.Equal(data["role"], expectedRole);
}

[Fact]
Expand Down

0 comments on commit 7714306

Please sign in to comment.