示例#1
0
        public void IsSubset_Null()
        {
            NonAbstractDBDataPermission dbdp = new NonAbstractDBDataPermission(PermissionState.None);

            Assert.IsTrue(dbdp.IsSubsetOf(null), "Empty-null");

            dbdp.Add(defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
            Assert.IsFalse(dbdp.IsSubsetOf(null), "Element-null");

            dbdp = new NonAbstractDBDataPermission(PermissionState.Unrestricted);
            Assert.IsFalse(dbdp.IsSubsetOf(null), "Unrestricted-null");
        }
示例#2
0
        public void IsSubsetOf_AllowPreventSame_KeyRestrictionBehavior()
        {
            NonAbstractDBDataPermission pAllow = new NonAbstractDBDataPermission(PermissionState.None);

            pAllow.Add(defaultConnectString, "password=;", KeyRestrictionBehavior.AllowOnly);
            NonAbstractDBDataPermission pPrevent = new NonAbstractDBDataPermission(PermissionState.None);

            pPrevent.Add(defaultConnectString, "password=;", KeyRestrictionBehavior.PreventUsage);

            Assert.IsTrue(pAllow.IsSubsetOf(pAllow), "AllowPreventSame - pAllow subsetof pAllow");
            Assert.IsTrue(pAllow.IsSubsetOf(pPrevent), "AllowPreventSame - pAllow subsetof pPrevent");
            Assert.IsTrue(pPrevent.IsSubsetOf(pAllow), "AllowPreventSame - pPrevent subsetof pAllow");
            Assert.IsTrue(pPrevent.IsSubsetOf(pPrevent), "AllowPreventSame - pPrevent subsetof pPrevent");
        }
示例#3
0
        public void IsSubsetOf_BothEmpty_KeyRestrictionBehavior()
        {
            NonAbstractDBDataPermission pAllow = new NonAbstractDBDataPermission(PermissionState.None);

            pAllow.Add(defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
            NonAbstractDBDataPermission pPrevent = new NonAbstractDBDataPermission(PermissionState.None);

            pPrevent.Add(defaultConnectString, String.Empty, KeyRestrictionBehavior.PreventUsage);

            Assert.IsTrue(pAllow.IsSubsetOf(pAllow), "BothEmpty - pAllow subsetof pAllow");
            Assert.IsTrue(pAllow.IsSubsetOf(pPrevent), "BothEmpty - pAllow subsetof pPrevent");
            Assert.IsTrue(pPrevent.IsSubsetOf(pAllow), "BothEmpty - pPrevent subsetof pAllow");
            Assert.IsTrue(pPrevent.IsSubsetOf(pPrevent), "BothEmpty - pPrevent subsetof pPrevent");
        }
示例#4
0
        public void IsSubsetOf_AllowBlankPassword()
        {
            NonAbstractDBDataPermission ptrue = new NonAbstractDBDataPermission(PermissionState.None);

            ptrue.AllowBlankPassword = true;
            ptrue.Add(defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
            NonAbstractDBDataPermission pfalse = new NonAbstractDBDataPermission(PermissionState.None);

            pfalse.AllowBlankPassword = false;
            pfalse.Add(defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);

            Assert.IsTrue(ptrue.IsSubsetOf(ptrue), "true subsetof true");
            Assert.IsFalse(ptrue.IsSubsetOf(pfalse), "true subsetof false");
            Assert.IsTrue(pfalse.IsSubsetOf(ptrue), "false subsetof true");
            Assert.IsTrue(pfalse.IsSubsetOf(pfalse), "false subsetof false");
        }
示例#5
0
        public void IsSubsetOf_AllowPreventDifferent_KeyRestrictionBehavior()
        {
            NonAbstractDBDataPermission pAllow1 = new NonAbstractDBDataPermission(PermissionState.None);

            pAllow1.Add(defaultConnectString, "security=;", KeyRestrictionBehavior.AllowOnly);
            NonAbstractDBDataPermission pAllow2 = new NonAbstractDBDataPermission(PermissionState.None);

            pAllow2.Add(defaultConnectString, "password=;", KeyRestrictionBehavior.AllowOnly);
            NonAbstractDBDataPermission pPrevent1 = new NonAbstractDBDataPermission(PermissionState.None);

            pPrevent1.Add(defaultConnectString, "security=;", KeyRestrictionBehavior.PreventUsage);
            NonAbstractDBDataPermission pPrevent2 = new NonAbstractDBDataPermission(PermissionState.None);

            pPrevent2.Add(defaultConnectString, "password=;", KeyRestrictionBehavior.PreventUsage);

            Assert.IsTrue(pAllow1.IsSubsetOf(pAllow1), "AllowPreventDifferent - pAllow subsetof pAllow");
            Assert.IsTrue(pAllow1.IsSubsetOf(pPrevent2), "AllowPreventDifferent - pAllow subsetof pPrevent");
            Assert.IsTrue(pPrevent1.IsSubsetOf(pAllow2), "AllowPreventDifferent - pPrevent subsetof pAllow");
            Assert.IsTrue(pPrevent1.IsSubsetOf(pPrevent2), "AllowPreventDifferent - pPrevent subsetof pPrevent");
        }
示例#6
0
        public void IsSubset()
        {
            NonAbstractDBDataPermission empty = new NonAbstractDBDataPermission(PermissionState.None);

            Assert.IsTrue(empty.IsSubsetOf(empty), "Empty-Empty");

            NonAbstractDBDataPermission dbdp1 = new NonAbstractDBDataPermission(PermissionState.None);

            dbdp1.Add(defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
            Assert.IsTrue(empty.IsSubsetOf(dbdp1), "Empty-1");
            Assert.IsFalse(dbdp1.IsSubsetOf(empty), "1-Empty");
            Assert.IsTrue(dbdp1.IsSubsetOf(dbdp1), "1-1");

            NonAbstractDBDataPermission dbdp2 = (NonAbstractDBDataPermission)dbdp1.Copy();

            dbdp2.Add(defaultConnectString2, String.Empty, KeyRestrictionBehavior.AllowOnly);
            Assert.IsTrue(dbdp1.IsSubsetOf(dbdp2), "1-2");
            Assert.IsFalse(dbdp2.IsSubsetOf(dbdp1), "2-1");
            Assert.IsTrue(dbdp2.IsSubsetOf(dbdp2), "2-2");

            NonAbstractDBDataPermission dbdp3 = new NonAbstractDBDataPermission(PermissionState.None);

            dbdp3.Add(defaultConnectString, String.Empty, KeyRestrictionBehavior.PreventUsage);
            Assert.IsTrue(dbdp3.IsSubsetOf(dbdp1), "3-1");
            Assert.IsTrue(dbdp1.IsSubsetOf(dbdp3), "1-3");
            Assert.IsTrue(dbdp3.IsSubsetOf(dbdp3), "3-3");

            NonAbstractDBDataPermission unr = new NonAbstractDBDataPermission(PermissionState.Unrestricted);

            Assert.IsTrue(dbdp1.IsSubsetOf(unr), "1-unrestricted");
            Assert.IsFalse(unr.IsSubsetOf(dbdp1), "unrestricted-1");
            Assert.IsTrue(dbdp2.IsSubsetOf(unr), "2-unrestricted");
            Assert.IsFalse(unr.IsSubsetOf(dbdp2), "unrestricted-2");
            Assert.IsTrue(dbdp3.IsSubsetOf(unr), "3-unrestricted");
            Assert.IsFalse(unr.IsSubsetOf(dbdp3), "unrestricted-3");
            Assert.IsTrue(unr.IsSubsetOf(unr), "unrestricted-unrestricted");
        }
示例#7
0
        public void IsSubsetOf_BadPermission()
        {
            NonAbstractDBDataPermission dbdp = new NonAbstractDBDataPermission(PermissionState.Unrestricted);

            dbdp.IsSubsetOf(new SecurityPermission(SecurityPermissionFlag.Assertion));
        }
示例#8
0
		public void IsSubsetOf_AllowPreventDifferent_KeyRestrictionBehavior ()
		{
			NonAbstractDBDataPermission pAllow1 = new NonAbstractDBDataPermission (PermissionState.None);
			pAllow1.Add (defaultConnectString, "security=;", KeyRestrictionBehavior.AllowOnly);
			NonAbstractDBDataPermission pAllow2 = new NonAbstractDBDataPermission (PermissionState.None);
			pAllow2.Add (defaultConnectString, "password=;", KeyRestrictionBehavior.AllowOnly);
			NonAbstractDBDataPermission pPrevent1 = new NonAbstractDBDataPermission (PermissionState.None);
			pPrevent1.Add (defaultConnectString, "security=;", KeyRestrictionBehavior.PreventUsage);
			NonAbstractDBDataPermission pPrevent2 = new NonAbstractDBDataPermission (PermissionState.None);
			pPrevent2.Add (defaultConnectString, "password=;", KeyRestrictionBehavior.PreventUsage);

			Assert.IsTrue (pAllow1.IsSubsetOf (pAllow1), "AllowPreventDifferent - pAllow subsetof pAllow");
			Assert.IsTrue (pAllow1.IsSubsetOf (pPrevent2), "AllowPreventDifferent - pAllow subsetof pPrevent");
			Assert.IsTrue (pPrevent1.IsSubsetOf (pAllow2), "AllowPreventDifferent - pPrevent subsetof pAllow");
			Assert.IsTrue (pPrevent1.IsSubsetOf (pPrevent2), "AllowPreventDifferent - pPrevent subsetof pPrevent");
		}
示例#9
0
		public void IsSubsetOf_BadPermission ()
		{
			NonAbstractDBDataPermission dbdp = new NonAbstractDBDataPermission (PermissionState.Unrestricted);
			dbdp.IsSubsetOf (new SecurityPermission (SecurityPermissionFlag.Assertion));
		}
示例#10
0
		public void IsSubsetOf_AllowPreventSame_KeyRestrictionBehavior ()
		{
			NonAbstractDBDataPermission pAllow = new NonAbstractDBDataPermission (PermissionState.None);
			pAllow.Add (defaultConnectString, "password=;", KeyRestrictionBehavior.AllowOnly);
			NonAbstractDBDataPermission pPrevent = new NonAbstractDBDataPermission (PermissionState.None);
			pPrevent.Add (defaultConnectString, "password=;", KeyRestrictionBehavior.PreventUsage);

			Assert.IsTrue (pAllow.IsSubsetOf (pAllow), "AllowPreventSame - pAllow subsetof pAllow");
			Assert.IsTrue (pAllow.IsSubsetOf (pPrevent), "AllowPreventSame - pAllow subsetof pPrevent");
			Assert.IsTrue (pPrevent.IsSubsetOf (pAllow), "AllowPreventSame - pPrevent subsetof pAllow");
			Assert.IsTrue (pPrevent.IsSubsetOf (pPrevent), "AllowPreventSame - pPrevent subsetof pPrevent");
		}
示例#11
0
		public void IsSubsetOf_BothEmpty_KeyRestrictionBehavior ()
		{
			NonAbstractDBDataPermission pAllow = new NonAbstractDBDataPermission (PermissionState.None);
			pAllow.Add (defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
			NonAbstractDBDataPermission pPrevent = new NonAbstractDBDataPermission (PermissionState.None);
			pPrevent.Add (defaultConnectString, String.Empty, KeyRestrictionBehavior.PreventUsage);

			Assert.IsTrue (pAllow.IsSubsetOf (pAllow), "BothEmpty - pAllow subsetof pAllow");
			Assert.IsTrue (pAllow.IsSubsetOf (pPrevent), "BothEmpty - pAllow subsetof pPrevent");
			Assert.IsTrue (pPrevent.IsSubsetOf (pAllow), "BothEmpty - pPrevent subsetof pAllow");
			Assert.IsTrue (pPrevent.IsSubsetOf (pPrevent), "BothEmpty - pPrevent subsetof pPrevent");
		}
示例#12
0
		public void IsSubsetOf_AllowBlankPassword ()
		{
			NonAbstractDBDataPermission ptrue = new NonAbstractDBDataPermission (PermissionState.None);
			ptrue.AllowBlankPassword = true;
			ptrue.Add (defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
			NonAbstractDBDataPermission pfalse = new NonAbstractDBDataPermission (PermissionState.None);
			pfalse.AllowBlankPassword = false;
			pfalse.Add (defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);

			Assert.IsTrue (ptrue.IsSubsetOf (ptrue), "true subsetof true");
			Assert.IsFalse (ptrue.IsSubsetOf (pfalse), "true subsetof false");
			Assert.IsTrue (pfalse.IsSubsetOf (ptrue), "false subsetof true");
			Assert.IsTrue (pfalse.IsSubsetOf (pfalse), "false subsetof false");
		}
示例#13
0
		public void IsSubset ()
		{
			NonAbstractDBDataPermission empty = new NonAbstractDBDataPermission (PermissionState.None);
			Assert.IsTrue (empty.IsSubsetOf (empty), "Empty-Empty");

			NonAbstractDBDataPermission dbdp1 = new NonAbstractDBDataPermission (PermissionState.None);
			dbdp1.Add (defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
			Assert.IsTrue (empty.IsSubsetOf (dbdp1), "Empty-1");
			Assert.IsFalse (dbdp1.IsSubsetOf (empty), "1-Empty");
			Assert.IsTrue (dbdp1.IsSubsetOf (dbdp1), "1-1");

			NonAbstractDBDataPermission dbdp2 = (NonAbstractDBDataPermission)dbdp1.Copy ();
			dbdp2.Add (defaultConnectString2, String.Empty, KeyRestrictionBehavior.AllowOnly);
			Assert.IsTrue (dbdp1.IsSubsetOf (dbdp2), "1-2");
			Assert.IsFalse (dbdp2.IsSubsetOf (dbdp1), "2-1");
			Assert.IsTrue (dbdp2.IsSubsetOf (dbdp2), "2-2");

			NonAbstractDBDataPermission dbdp3 = new NonAbstractDBDataPermission (PermissionState.None);
			dbdp3.Add (defaultConnectString, String.Empty, KeyRestrictionBehavior.PreventUsage);
			Assert.IsTrue (dbdp3.IsSubsetOf (dbdp1), "3-1");
			Assert.IsTrue (dbdp1.IsSubsetOf (dbdp3), "1-3");
			Assert.IsTrue (dbdp3.IsSubsetOf (dbdp3), "3-3");

			NonAbstractDBDataPermission unr = new NonAbstractDBDataPermission (PermissionState.Unrestricted);
			Assert.IsTrue (dbdp1.IsSubsetOf (unr), "1-unrestricted");
			Assert.IsFalse (unr.IsSubsetOf (dbdp1), "unrestricted-1");
			Assert.IsTrue (dbdp2.IsSubsetOf (unr), "2-unrestricted");
			Assert.IsFalse (unr.IsSubsetOf (dbdp2), "unrestricted-2");
			Assert.IsTrue (dbdp3.IsSubsetOf (unr), "3-unrestricted");
			Assert.IsFalse (unr.IsSubsetOf (dbdp3), "unrestricted-3");
			Assert.IsTrue (unr.IsSubsetOf (unr), "unrestricted-unrestricted");
		}
示例#14
0
		public void IsSubset_Null ()
		{
			NonAbstractDBDataPermission dbdp = new NonAbstractDBDataPermission (PermissionState.None);
			Assert.IsTrue (dbdp.IsSubsetOf (null), "Empty-null");

			dbdp.Add (defaultConnectString, String.Empty, KeyRestrictionBehavior.AllowOnly);
			Assert.IsFalse (dbdp.IsSubsetOf (null), "Element-null");

			dbdp = new NonAbstractDBDataPermission (PermissionState.Unrestricted);
			Assert.IsFalse (dbdp.IsSubsetOf (null), "Unrestricted-null");
		}