From f1f59d4ad529377e3e89b8bff740a6c146d6b10f Mon Sep 17 00:00:00 2001 From: Adrian Godong Date: Sat, 11 Aug 2018 12:32:02 -0700 Subject: [PATCH] Added unit test for StringPrivateKeySource --- GitHubJwt.Tests/GitHubJwtFactoryTests.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/GitHubJwt.Tests/GitHubJwtFactoryTests.cs b/GitHubJwt.Tests/GitHubJwtFactoryTests.cs index b3bb41c..ba3888b 100644 --- a/GitHubJwt.Tests/GitHubJwtFactoryTests.cs +++ b/GitHubJwt.Tests/GitHubJwtFactoryTests.cs @@ -55,5 +55,25 @@ public void CreateEncodedJwtToken_FromEnvVar_ShouldNotFail() } } + [TestMethod] + public void CreateEncodedJwtToken_FromString_ShouldNotFail() + { + // Arrange + var privateKeySource = new StringPrivateKeySource(File.ReadAllText("envvar.pem")); + var options = new GitHubJwtFactoryOptions + { + AppIntegrationId = 6837, + ExpirationSeconds = 600 // 10 minutes maximum + }; + var factory = new GitHubJwtFactory(privateKeySource, options); + + // Act + var token = factory.CreateEncodedJwtToken(); + + // Assert + Assert.IsNotNull(token); + Console.WriteLine(token); + } + } }