Skip to content

Commit

Permalink
chore: add test for moderation token
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeadi committed Nov 29, 2024
1 parent 4b84cbd commit 71dff98
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,24 @@ public void TestToken()
Assert.AreEqual(true, (bool)result["testing"]);
Assert.False(result.ContainsKey("missing"));
}

Check warning on line 118 in tests/ClientTests.cs

View workflow job for this annotation

GitHub Actions / Run tests

Code should not contain trailing whitespace
[Test]
public void TestModerationToken()
{
var result = DecodeJwt(Client.CreateUserToken("user"));
Assert.AreEqual("user", (string)result["user_id"]);

var extra = new Dictionary<string, object>()
{
{ "client", "dotnet" },
{ "required_moderation_template", "mod_template_1" },
};
result = DecodeJwt(Client.CreateUserToken("user2", extra));

Assert.AreEqual("mod_template_1", (string)result["required_moderation_template"]);
Assert.False(result.ContainsKey("missing"));
}

Check warning on line 135 in tests/ClientTests.cs

View workflow job for this annotation

GitHub Actions / Run tests

Code should not contain trailing whitespace
private Dictionary<string, object> DecodeJwt(string token)
{
var segment = token.Split('.')[1];
Expand Down

0 comments on commit 71dff98

Please sign in to comment.