Esempio n. 1
0
        public void GeneratedUserIdCheck()
        {
            var token    = new JwtSecurityHelper(_settings.Object);
            var tempGuid = Guid.NewGuid().ToString();
            var jwt      = token.GetToken(tempGuid);

            var userClaim = jwt.Claims.FirstOrDefault(i => i.Type.Equals(JwtRegisteredClaimNames.Sub));

            Assert.Equal(userClaim.Value, tempGuid);
        }
Esempio n. 2
0
        public void TokenStringValidation()
        {
            var token       = new JwtSecurityHelper(_settings.Object);
            var tempGuid    = Guid.NewGuid().ToString();
            var jwt         = token.GetToken(tempGuid);
            var tokenString = token.GetTokenValue(jwt);
            var handler     = new JwtSecurityTokenHandler();
            var result      = handler.ReadJwtToken(tokenString);

            Assert.Equal(_settings.Object.Value.Issuer, result.Issuer);
        }
Esempio n. 3
0
 public ActionResult <string> GetJwtToken()
 {
     return(JwtSecurityHelper.GenerateJwtToken(_config[Constants.AuthSecretPreference]));
 }