Exemplo n.º 1
0
        public async Task ShouldRemoveClaimsFromUserByPassingOriginalReferences()
        {
            DocumentDbUserStore <DocumentDbIdentityUser> userStore = CreateUserStore();
            Claim userCountryClaim    = new Claim(ClaimTypes.Country, "Austria");
            Claim userPostalCodeClaim = new Claim(ClaimTypes.PostalCode, "1010");
            Claim userNameClaim       = new Claim(ClaimTypes.Name, "Name");

            Claim[] claimsToRemove = new Claim[] { userCountryClaim, userNameClaim };

            DocumentDbIdentityUser targetUser = DocumentDbIdentityUserBuilder.Create().AddClaim(userCountryClaim).AddClaim(userPostalCodeClaim);

            await userStore.RemoveClaimsAsync(targetUser, claimsToRemove, CancellationToken.None);

            Assert.DoesNotContain(userCountryClaim, targetUser.Claims);
            Assert.DoesNotContain(userNameClaim, targetUser.Claims);
        }
Exemplo n.º 2
0
        public async Task ShouldRemoveClaimsFromUserByValueComparison()
        {
            string userCountryClaimValue = "Austria";
            string userPostalCodeValue   = "1010";

            DocumentDbUserStore <DocumentDbIdentityUser> userStore = CreateUserStore();
            Claim userCountryClaim              = new Claim(ClaimTypes.Country, userCountryClaimValue);
            Claim userPostalCodeClaim           = new Claim(ClaimTypes.PostalCode, userPostalCodeValue);
            Claim userCountryClaimComparison    = new Claim(ClaimTypes.Country, userCountryClaimValue);
            Claim userPostalCodeClaimComparison = new Claim(ClaimTypes.PostalCode, userPostalCodeValue);

            Claim[] claimsToRemove = new Claim[] { userCountryClaimComparison, userPostalCodeClaimComparison };

            DocumentDbIdentityUser targetUser = DocumentDbIdentityUserBuilder.Create().AddClaim(userCountryClaim).AddClaim(userPostalCodeClaim);

            await userStore.RemoveClaimsAsync(targetUser, claimsToRemove, CancellationToken.None);

            Assert.DoesNotContain(userCountryClaim, targetUser.Claims);
            Assert.DoesNotContain(userPostalCodeClaim, targetUser.Claims);
        }