コード例 #1
0
            public void GenerateToken_Uses_IJwtGenerationOptionsFactory_GetOptions_To_Retrieve_JwtGenerationOptions_For_Token_Generation_When_ClaimsIdentity_For_Specified_User_Is_Found()
            {
                var request = new GenerateTokenRequestBuilder().Build();
                var result  = GenerateToken(request).Result;

                Verify <IJwtGenerationOptionsFactory>(
                    f => f.GetOptions(), Times.Once());
            }
コード例 #2
0
            public void GeneateToken_Uses_IClaimsIdentityRetriever_Retrieve_To_Retrieve_ClaimsIdentity_For_Specified_User()
            {
                var request = new GenerateTokenRequestBuilder().Build();
                var result  = GenerateToken(request).Result;

                Verify <IClaimsIdentityRetriever>(
                    r => r.Retrieve(request.UserIdentifier, request.Secret), Times.Once());
            }
コード例 #3
0
            public void GenerateToken_Returns_InternalServerError_Response_When_ClaimsIdentity_For_Specified_User_Cannot_Be_Found()
            {
                var request = new GenerateTokenRequestBuilder().Build();

                Returns <IClaimsIdentityRetriever, ClaimsIdentity>(
                    r => r.Retrieve(request.UserIdentifier, request.Secret), null);

                Assert.AreEqual(
                    HttpStatusCode.InternalServerError,
                    GenerateToken(request).Result.StatusCode);
            }
コード例 #4
0
            public void GenerateToken_Uses_IJwtSecurityTokenGenerator_To_Generate_Token_When_ClaimsIdentity_For_Specified_User_Is_Found()
            {
                var request        = new GenerateTokenRequestBuilder().Build();
                var claimsIdentity = new ClaimsIdentity();
                var options        = It.IsAny <JwtGenerationOptions>();

                Returns <IJwtGenerationOptionsFactory, JwtGenerationOptions>(
                    f => f.GetOptions(), options);

                Returns <IClaimsIdentityRetriever, ClaimsIdentity>(
                    r => r.Retrieve(request.UserIdentifier, request.Secret), claimsIdentity);

                var result = GenerateToken(request).Result;

                Verify <IJwtSecurityTokenGenerator>(
                    g => g.Generate(claimsIdentity, options), Times.Once());
            }