示例#1
0
        public void CreateEncodedJwtToken_FromEnvVar_ShouldNotFail()
        {
            // Arrange
            var privateKeyName   = Guid.NewGuid().ToString("N");
            var privateKeySource = new EnvironmentVariablePrivateKeySource(privateKeyName);
            var options          = new GitHubJwtFactoryOptions
            {
                AppIntegrationId  = 6837,
                ExpirationSeconds = 600 // 10 minutes maximum
            };
            var factory = new GitHubJwtFactory(privateKeySource, options);

            using (new EnvironmentVariableScope(privateKeyName))
            {
                Environment.SetEnvironmentVariable(privateKeyName, File.ReadAllText("envvar.pem"));

                // Act
                var token = factory.CreateEncodedJwtToken();

                // Assert
                Assert.IsNotNull(token);
                Console.WriteLine(token);
            }
        }
        protected TokenGenerator CreateTokenGenerator()
        {
            var privateKeySource = new EnvironmentVariablePrivateKeySource(GitHubAppPrivateKeyEnvironmentVariable);

            return(new TokenGenerator(GitHubAppId, privateKeySource));
        }