public void ReturnUserClaimsDTOWithClaimsAndToken() { // GIVEN a Claims object contatining claims List <Claim> expectedClaims = new List <Claim> { new Claim(ClaimTypes.Email, "*****@*****.**"), new Claim(ClaimTypes.Name, "Test User"), new Claim(ClaimTypes.Role, UserRole.TRAINER.ToString()) }; Claims claims = new Claims(expectedClaims); // WHEN a UserClaimsDTO object is being generated UserClaimsDTO userClaims = claims.GenerateUserClaimsDTO(JWT_KEY); // THEN a UserClaimsDTO object with claims and a token is returned Assert.Equal(expectedClaims, userClaims.Claims); Assert.NotNull(userClaims.Token); }
public UserClaimsDTO AuthorizeTrainer(UserDTO user) { Claims claims = GetTrainerClaims(user); return(claims.GenerateUserClaimsDTO(config.Value.JwtKey)); }