Created
September 4, 2012 00:45
-
-
Save pmhsfelix/3615356 to your computer and use it in GitHub Desktop.
Playing with claims and boolean operator overloading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void Fact1() | |
{ | |
var namedAlice = new UserNameClaim("Alice"); | |
var teacher = new RoleClaim("Teacher"); | |
var student = new RoleClaim("Student"); | |
var alice = Claims.Identity(new UserNameClaim("Alice"), student); | |
var bob = Claims.Identity(new UserNameClaim("Bob"), teacher); | |
var anotherAlice = Claims.Identity(new UserNameClaim("Alice")); | |
var authorized = (namedAlice && student) || teacher; | |
Assert.True(alice.Is(authorized)); | |
Assert.True(bob.Is(authorized)); | |
Assert.False(anotherAlice.Is(authorized)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment