public void TestIsInRole() { SecurePrincipal u = new SecurePrincipal(new SecureIdentity("test", null), new string[] { "role1", "role2" }); Assert.IsTrue(u.IsInRole("role1")); Assert.IsTrue(u.IsInRole("role2")); Assert.IsFalse(u.IsInRole("role3")); }
/// <summary> /// Starts the current service. /// </summary> public virtual void Start() { //Create an anonymous user on service startup. _current = new SecurePrincipal(); #if !SILVERLIGHT AppDomain.CurrentDomain.SetThreadPrincipal(_current); #endif }
public void TestPromotePrincipal() { SecurePrincipal u = new SecurePrincipal(); u.Promote(new string[] {"r1", "r2"}); Assert.AreEqual(2, u.AllRoles.Count()); Assert.IsTrue(u.IsInRole("r1")); Assert.IsTrue(u.IsInRole("r2")); }
public void TestPromoteIdentity2() { SecurePrincipal u = new SecurePrincipal(); u.Identity.Promote("dave", null, "test"); Assert.AreEqual("dave", u.Identity.Name); Assert.AreEqual("test", u.Identity.AuthenticationType); Assert.IsTrue(u.Identity.IsAuthenticated); }
public void TestPromotePrincipal() { SecurePrincipal u = new SecurePrincipal(); u.Promote(new string[] { "r1", "r2" }); Assert.AreEqual(2, u.AllRoles.Count()); Assert.IsTrue(u.IsInRole("r1")); Assert.IsTrue(u.IsInRole("r2")); }
public void TestAnonymous() { SecurePrincipal u = new SecurePrincipal(); Assert.IsNotNull(u.Identity); Assert.IsNotNull(u.AllRoles); Assert.AreEqual(0, u.AllRoles.Count()); Assert.IsFalse(u.IsInRole("test")); Assert.IsFalse(u.Identity.IsAuthenticated); Assert.AreEqual(string.Empty, u.Identity.AuthenticationType); Assert.AreEqual(string.Empty, u.Identity.Name); }
public void TestCreate() { SecurePrincipal u = new SecurePrincipal(new SecureIdentity("test", null), new string[] {}); }
public void TestCreate() { SecurePrincipal u = new SecurePrincipal(new SecureIdentity("test", null), new string[]{}); }