public void JudgeEnforcePass() { // The default Advise implementation for JudgeDummy is to always return true. var judgeDummy = new JudgeDummy(); judgeDummy.Enforce("any-law"); }
public void PrincipalWithCurrentUser() { var judge = new JudgeDummy(); var expectedUserName = getCurrentUserName(); Assert.AreEqual(expectedUserName, judge.Principal.Identity.Name); }
public void JudgeEnforceFail() { // JudgeDummy evil twin that always Advise to false (just like //the real Judge Death) var judgeDeath = new JudgeDummy((l, a) => false); judgeDeath.Enforce("any-law"); }
public void ThreadOverridenPrincipal() { IPrincipal initialPrincipal = Thread.CurrentPrincipal; Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("vienna"), new string[0]); var judge = new JudgeDummy(); var judgePrincipal = judge.Principal; Thread.CurrentPrincipal = initialPrincipal; Assert.AreEqual("vienna", judgePrincipal.Identity.Name); }
public void JudgeOverridenPrincipal() { var judge = new JudgeDummy(); judge.Principal = new GenericPrincipal(new GenericIdentity("rico"), new string[0]); Assert.AreEqual("rico", judge.Principal.Identity.Name); judge.Principal = null; var expectedUserName = getCurrentUserName(); Assert.AreEqual(expectedUserName, judge.Principal.Identity.Name); }