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()); }
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()); }
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); }
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()); }