public void CreateToken_useMiCakeUser_privateProperty() { var options = new MiCakeJwtOptions(); //default value. var supporter = CreateJwtSupporter(options); var micakeUser = new UserWithPrivateProperty() { Id = 10086 }; var token = supporter.CreateToken(micakeUser); var tokenModel = JwtHander.ReadJwtToken(token); var userIdClaim = tokenModel.Claims.FirstOrDefault(s => s.Type.Equals("userid")); var ageClaim = tokenModel.Claims.FirstOrDefault(s => s.Type.Equals("age")); Assert.NotNull(userIdClaim); Assert.NotNull(ageClaim); Assert.Equal("10086", userIdClaim.Value); }
public async void CreateToken_UseMiCakeUser_PrivateProperty() { var supporter = CreateJwtAuthManager(s => { }); var micakeUser = new UserWithPrivateProperty() { Id = 10086 }; var token = await supporter.CreateToken(micakeUser); var tokenModel = JwtHander.ReadJwtToken(token.AccessToken); var userIdClaim = tokenModel.Claims.FirstOrDefault(s => s.Type.Equals("userid")); var ageClaim = tokenModel.Claims.FirstOrDefault(s => s.Type.Equals("age")); Assert.NotNull(userIdClaim); Assert.NotNull(ageClaim); Assert.Equal("10086", userIdClaim.Value); }