Exemplo n.º 1
0
		public void DefaultValues ()
		{
			RoleGroup rg = new RoleGroup ();
			Assert.IsNull (rg.ContentTemplate, "ContentTemplate");
			Assert.AreEqual (0, rg.Roles.Length, "Roles");
			Assert.AreEqual (String.Empty, rg.ToString ());
		}
Exemplo n.º 2
0
		public void Roles_Null ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.Roles = null;
			Assert.AreEqual (String.Empty, rg.ToString ());
			Assert.AreEqual (0, rg.Roles.Length, "Roles");
		}
 public void Remove(RoleGroup group)
 {
     int index = this.IndexOf(group);
     if (index >= 0)
     {
         base.List.RemoveAt(index);
     }
 }
Exemplo n.º 4
0
        public void Remove(RoleGroup group)
        {
            int index = this.IndexOf(group);

            if (index >= 0)
            {
                base.List.RemoveAt(index);
            }
        }
Exemplo n.º 5
0
        public void Remove(RoleGroup group)
        {
            int index = IndexOf(group);

            if (index >= 0)
            {
                List.RemoveAt(index);
            }
        }
Exemplo n.º 6
0
		public void Add ()
		{
			RoleGroupCollection rgc = new RoleGroupCollection ();
			Assert.AreEqual (0, rgc.Count, "0");
			RoleGroup rg1 = new RoleGroup ();
			rgc.Add (rg1);
			Assert.AreEqual (1, rgc.Count, "1");
			rgc.Add (rg1);
			Assert.AreEqual (2, rgc.Count, "2");
		}
Exemplo n.º 7
0
 public void Remove(RoleGroup group)
 {
     // note: checks required or we'll throw more exceptions :(
     if (group != null)
     {
         if (Contains(group))
         {
             List.Remove(group);
         }
     }
 }
Exemplo n.º 8
0
		public void CopyTo (RoleGroup[] array, int index)
		{
			if (array == null)
				throw new ArgumentNullException ("array");
			if (index < 0)
				throw new ArgumentException (Locale.GetText ("Negative index."), "index");
			if (this.Count <= array.Length - index)
				throw new ArgumentException (Locale.GetText ("Destination isn't large enough to copy collection."), "array");

			for (int i=0; i < Count; i++)
				array [i + index] = this [i];
		}
Exemplo n.º 9
0
        ITemplate GetTemplateFromRoleGroup(RoleGroup rg, IPrincipal user)
        {
            if (user == null)
            {
                return(null);
            }

            foreach (string role in rg.Roles)
            {
                if (user.IsInRole(role))
                {
                    return(rg.ContentTemplate);
                }
            }

            return(null);
        }
Exemplo n.º 10
0
		public void Contains ()
		{
			RoleGroupCollection rgc = new RoleGroupCollection ();
			Assert.IsFalse (rgc.Contains (null), "null");

			RoleGroup rg1 = new RoleGroup ();
			rgc.Add (rg1);
			Assert.IsTrue (rgc.Contains (rg1), "1a");

			RoleGroup rg2 = new RoleGroup ();
			Assert.IsFalse (rgc.Contains (rg2), "2a");
			rgc.Add (rg2);
			Assert.IsTrue (rgc.Contains (rg2), "2b");

			rgc.Remove (rg1);
			Assert.IsFalse (rgc.Contains (rg1), "1b");
		}
Exemplo n.º 11
0
		public void ContentTemplate ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.ContentTemplate = this;
			Assert.IsNotNull (rg.ContentTemplate, "ContentTemplate");
		}
Exemplo n.º 12
0
		public void ContainsUser_Out ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.Roles = new string[2] { "mono", "hackers" };
			Assert.IsFalse (rg.ContainsUser (GetPrincipal ("me", "m0n0")), "m0n0");
			Assert.IsFalse (rg.ContainsUser (GetPrincipal ("me", "h4ck")), "h4ck");
		}
Exemplo n.º 13
0
		public void ContainsUser_NoRoles ()
		{
			RoleGroup rg = new RoleGroup ();
			Assert.IsFalse (rg.ContainsUser (GetPrincipal ("me")), "me");
		}
Exemplo n.º 14
0
 public void Insert(int index, RoleGroup group)
 {
 }
Exemplo n.º 15
0
		public void GetMatchingRoleGroup_In ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.Roles = new string[2] { "mono", "hackers" };

			RoleGroupCollection rgc = new RoleGroupCollection ();
			rgc.Add (rg);
			Assert.AreEqual (1, rgc.Count, "Count");

			RoleGroup result = rgc.GetMatchingRoleGroup (GetPrincipal ("me", "mono"));
			Assert.IsNotNull (result, "me+mono");
			Assert.IsTrue (Object.ReferenceEquals (result, rg), "ref1");

			result = rgc.GetMatchingRoleGroup (GetPrincipal ("me", "hackers"));
			Assert.IsNotNull (result, "me+hackers");
			Assert.IsTrue (Object.ReferenceEquals (result, rg), "ref2");

			// works for unauthenticated principals too
			result = rgc.GetMatchingRoleGroup (GetUnauthenticatedPrincipal ("me", "mono"));
			Assert.IsNotNull (result, "unauthenticated+me+mono");
			Assert.IsTrue (Object.ReferenceEquals (result, rg), "ref3");

			result = rgc.GetMatchingRoleGroup (GetUnauthenticatedPrincipal ("me", "hackers"));
			Assert.IsNotNull (result, "unauthenticated+me+hackers");
			Assert.IsTrue (Object.ReferenceEquals (result, rg), "ref4");

			// case insensitive
			result = rgc.GetMatchingRoleGroup (GetPrincipal ("me", "MoNo"));
			Assert.IsNotNull (result, "unauthenticated+me+MoNo");
			Assert.IsTrue (Object.ReferenceEquals (result, rg), "ref5");

			result = rgc.GetMatchingRoleGroup (GetPrincipal ("me", "hAcKeRs"));
			Assert.IsNotNull (result, "unauthenticated+me+hAcKeRs");
			Assert.IsTrue (Object.ReferenceEquals (result, rg), "ref6");
		}
Exemplo n.º 16
0
 public void Remove(RoleGroup group)
 {
 }
Exemplo n.º 17
0
 public int IndexOf(RoleGroup group)
 {
     return(base.List.IndexOf(group));
 }
Exemplo n.º 18
0
		public void ThisIndex ()
		{
			RoleGroupCollection rgc = new RoleGroupCollection ();
			RoleGroup rg = new RoleGroup ();
			rgc.Add (rg);
			Assert.IsTrue (Object.ReferenceEquals (rg, rgc [0]));
		}
 public void Insert(int index, RoleGroup group)
 {
 }
Exemplo n.º 20
0
		public void Remove ()
		{
			RoleGroupCollection rgc = new RoleGroupCollection ();
			rgc.Remove (null);

			RoleGroup rg1 = new RoleGroup ();
			rgc.Remove (rg1);
			rgc.Add (rg1);
			rgc.Add (rg1);
			Assert.AreEqual (2, rgc.Count, "Count");
			rgc.Remove (rg1);
			Assert.IsTrue (rgc.Contains (rg1), "rg1-bis");

			RoleGroup rg2 = new RoleGroup ();
			rgc.Add (rg2);
			rgc.Remove (rg2);
			rgc.Remove (rg2);
		}
Exemplo n.º 21
0
		public void IndexOf ()
		{
			RoleGroupCollection rgc = new RoleGroupCollection ();
			Assert.AreEqual (-1, rgc.IndexOf (null), "null");

			RoleGroup rg1 = new RoleGroup ();
			rgc.Add (rg1);
			Assert.AreEqual (0, rgc.IndexOf (rg1), "0");
			rgc.Add (rg1);
			Assert.AreEqual (0, rgc.IndexOf (rg1), "1");
		}
Exemplo n.º 22
0
		public void ContainsUser_Out ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.Roles = new string[2] { "mono", "hackers" };

			RoleGroupCollection rgc = new RoleGroupCollection ();
			rgc.Add (rg);
			Assert.AreEqual (1, rgc.Count, "Count");

			RoleGroup result = rgc.GetMatchingRoleGroup (GetPrincipal ("me", "m0n0"));
			Assert.IsNull (result, "me+MoNo");

			result = rgc.GetMatchingRoleGroup (GetPrincipal ("me", "h4ck"));
			Assert.IsNull (result, "me+h4ck");
		}
 public void Remove(RoleGroup group)
 {
 }
 public void Remove(RoleGroup group) {
     int index = IndexOf(group);
     if (index >= 0) {
         List.RemoveAt(index);
     }
 }
Exemplo n.º 25
0
 public bool Contains(RoleGroup group)
 {
     return(base.List.Contains(group));
 }
 public bool Contains(RoleGroup group)
 {
     return base.List.Contains(group);
 }
Exemplo n.º 27
0
 public void Insert(int index, RoleGroup group)
 {
     base.List.Insert(index, group);
 }
 public int IndexOf(RoleGroup group)
 {
     return base.List.IndexOf(group);
 }
 public void Add(RoleGroup group)
 {
     base.List.Add(group);
 }
Exemplo n.º 30
0
		public void GetMatchingRoleGroup_NoRoles ()
		{
			RoleGroup rg = new RoleGroup ();
			
			RoleGroupCollection rgc = new RoleGroupCollection ();
			rgc.Add (rg);
			Assert.AreEqual (1, rgc.Count, "Count");

			RoleGroup result = rgc.GetMatchingRoleGroup (GetPrincipal ("me"));
			Assert.IsNull (result, "me");

			result = rgc.GetMatchingRoleGroup (GetPrincipal ("me", "mono"));
			Assert.IsNull (result, "me+mono");
		}
 public void CopyTo(RoleGroup[] array, int index)
 {
     base.List.CopyTo(array, index);
 }
Exemplo n.º 32
0
		public void Remove (RoleGroup group)
		{
			// note: checks required or we'll throw more exceptions :(
			if (group != null) {
				if (Contains (group))
					List.Remove (group);
			}
		}
 public void Insert(int index, RoleGroup group)
 {
     base.List.Insert(index, group);
 }
Exemplo n.º 34
0
		public void Add (RoleGroup group)
		{
			List.Add (group);
		}
Exemplo n.º 35
0
		public void ContainsUser_Null ()
		{
			RoleGroup rg = new RoleGroup ();
			Assert.IsFalse (rg.ContainsUser (null), "null");
		}
Exemplo n.º 36
0
		public void Roles_One ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.Roles = new string[1] { "mono" };
			Assert.AreEqual ("mono", rg.ToString ());
			Assert.AreEqual (1, rg.Roles.Length, "Roles");
		}
Exemplo n.º 37
0
		public void ContainsUser_In ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.Roles = new string[2] { "mono", "hackers" };
			Assert.IsTrue (rg.ContainsUser (GetPrincipal ("me1", "mono")), "me+mono");
			Assert.IsTrue (rg.ContainsUser (GetPrincipal ("me2", "hackers")), "me+hackers");
			// works for unauthenticated principals too
			Assert.IsTrue (rg.ContainsUser (GetUnauthenticatedPrincipal ("me3", "mono")), "unauthenticated+me+mono");
			Assert.IsTrue (rg.ContainsUser (GetUnauthenticatedPrincipal ("me4", "hackers")), "unauthenticated+me+hackers");
			// case insensitive
			Assert.IsTrue (rg.ContainsUser (GetPrincipal ("me5", "MoNo")), "case+me+mono");
			Assert.IsTrue (rg.ContainsUser (GetPrincipal ("me6", "hAcKeRs")), "case+me+hackers");
		}
Exemplo n.º 38
0
 public bool Contains(RoleGroup group)
 {
     return(default(bool));
 }
Exemplo n.º 39
0
 public int IndexOf(RoleGroup group)
 {
     return(default(int));
 }
Exemplo n.º 40
0
 public void Add(RoleGroup group)
 {
     List.Add(group);
 }
Exemplo n.º 41
0
 public void Add(RoleGroup group)
 {
     base.List.Add(group);
 }
Exemplo n.º 42
0
		ITemplate GetTemplateFromRoleGroup (RoleGroup rg, IPrincipal user)
		{
			if (user == null)
				return null;
			
			foreach (string role in rg.Roles) {
				if (user.IsInRole (role))
					return rg.ContentTemplate;
			}
			
			return null;
		}
Exemplo n.º 43
0
		public void Roles_Two ()
		{
			RoleGroup rg = new RoleGroup ();
			rg.Roles = new string[2] { "mono", "hackers" };
			Assert.AreEqual ("mono,hackers", rg.ToString ());
			Assert.AreEqual (2, rg.Roles.Length, "Roles");
		}
Exemplo n.º 44
0
 public void Add(RoleGroup group)
 {
 }