public void Should_return_false_for_any_required_claim_if_the_claims_are_null() { // Given IUserIdentity user = GetFakeUser("Fake"); var requiredClaims = new[] { "not-present-claim1", "not-present-claim2" }; // When var result = user.HasAnyClaim(requiredClaims); // Then result.ShouldBeFalse(); }
public void Should_return_true_for_any_required_claim_if_the_user_does_have_any_of_claim() { // Given IUserIdentity user = GetFakeUser("Fake", new[] { "present-claim1", "present-claim2", "present-claim3" }); var requiredClaims = new[] { "present-claim1", "not-present-claim1" }; // When var result = user.HasAnyClaim(requiredClaims); // Then result.ShouldBeTrue(); }
public static bool DoesNotHaveClaims(IEnumerable <string> claims, IUserIdentity identity) { return(!identity?.HasAnyClaim(claims) ?? true); }