Пример #1
0
        public void should_add_email_to_existing_claims_stored_in_token()
        {
            // given
            var roleClaim      = new Claim(ClaimTypes.Role, "Admin");
            var existingClaims = new List <Claim>()
            {
                roleClaim
            };
            string email = "*****@*****.**";

            // when
            string token = _provider.CreateToken(existingClaims, email);

            // then
            token.ShouldNotBeNullOrEmpty();
            _tokenHandler
            .Received()
            .CreateToken(Arg.Is <SecurityTokenDescriptor>(
                             x => x.Subject.Claims.Any(y => y.Type == roleClaim.Type && y.Value == roleClaim.Value) &&
                             x.Subject.Claims.Any(y => y.Type == ClaimTypes.Name && y.Value == email)));
        }