diff --git a/test/Discord.Net.Tests/Tests.TokenUtils.cs b/test/Discord.Net.Tests/Tests.TokenUtils.cs index 4c4b6030f..1348b7744 100644 --- a/test/Discord.Net.Tests/Tests.TokenUtils.cs +++ b/test/Discord.Net.Tests/Tests.TokenUtils.cs @@ -125,5 +125,25 @@ namespace Discord Assert.Throws(() => TokenUtils.ValidateToken((TokenType)type, "MTk4NjIyNDgzNDcxOTI1MjQ4.Cl2FMQ.ZnCjm1XVW7vRze4b7Cq4se7kKWs")); } + + /// + /// Checks the method for expected output. + /// + /// The Bot Token to test. + /// The expected result. + [Theory] + // this method only checks the first part of the JWT + [InlineData("MTk4NjIyNDgzNDcxOTI1MjQ4..", true)] + [InlineData("MTk4NjIyNDgzNDcxOTI1MjQ4.Cl2FMQ.ZnCjm1XVW7vRze4b7Cq4se7kK", true)] + [InlineData("MTk4NjIyNDgzNDcxOTI1MjQ4. this part is invalid. this part is also invalid", true)] + [InlineData("MTk4NjIyNDgzNDcxOTI1MjQ4.", false)] + [InlineData("MTk4NjIyNDgzNDcxOTI1MjQ4", false)] + // should not throw an unexpected exception + [InlineData("", false)] + [InlineData(null, false)] + public void TestCheckBotTokenValidity(string token, bool expected) + { + Assert.Equal(expected, TokenUtils.CheckBotTokenValidity(token)); + } } }