Ejemplo n.º 1
0
        public void Intersect_None()
        {
            ServiceControllerPermission scp1 = new ServiceControllerPermission(PermissionState.None);
            ServiceControllerPermission scp2 = new ServiceControllerPermission(PermissionState.None);
            // 1. None N None
            ServiceControllerPermission result = (ServiceControllerPermission)scp1.Intersect(scp2);

            Assert.IsNull(result, "Empty N Empty");
            // 2. None N Entry
            scp2.PermissionEntries.Add(new ServiceControllerPermissionEntry(ServiceControllerPermissionAccess.None, "localhost", "http"));
            result = (ServiceControllerPermission)scp1.Intersect(scp2);
            Assert.IsNull(result, "Empty N Entry");
            // 3. Entry N None
            result = (ServiceControllerPermission)scp2.Intersect(scp1);
            Assert.IsNull(result, "Entry N Empty");
        }
Ejemplo n.º 2
0
        public void Intersect_Null()
        {
            ServiceControllerPermission scp = new ServiceControllerPermission(PermissionState.None);

            // No intersection with null
            Assert.IsNull(scp.Intersect(null), "None N null");
        }
Ejemplo n.º 3
0
        public void Intersect_Unrestricted()
        {
            // Intersection with unrestricted == Copy
            // a. source (this) is unrestricted
            ServiceControllerPermission scp1 = new ServiceControllerPermission(PermissionState.Unrestricted);
            ServiceControllerPermission scp2 = new ServiceControllerPermission(PermissionState.None);

            // 1. Unrestricted N None
            ServiceControllerPermission result = (ServiceControllerPermission)scp1.Intersect(scp2);

            Assert.IsFalse(result.IsUnrestricted(), "(Unrestricted N None).IsUnrestricted");
            Assert.AreEqual(0, result.PermissionEntries.Count, "(Unrestricted N None).Count");

            // 2. None N Unrestricted
            result = (ServiceControllerPermission)scp2.Intersect(scp1);
            Assert.IsFalse(result.IsUnrestricted(), "(None N Unrestricted).IsUnrestricted");
            Assert.AreEqual(0, result.PermissionEntries.Count, "(None N Unrestricted).Count");

            // 3. Unrestricted N Unrestricted
            result = (ServiceControllerPermission)scp1.Intersect(scp1);
            Assert.IsTrue(result.IsUnrestricted(), "(Unrestricted N Unrestricted).IsUnrestricted");
            Assert.AreEqual(0, result.PermissionEntries.Count, "(Unrestricted N Unrestricted).Count");

            // 4. Unrestricted N Entry
            scp2.PermissionEntries.Add(new ServiceControllerPermissionEntry(ServiceControllerPermissionAccess.None, "localhost", "http"));
            result = (ServiceControllerPermission)scp1.Intersect(scp2);
            Assert.IsFalse(result.IsUnrestricted(), "(Unrestricted N Entry).IsUnrestricted");
            Assert.AreEqual(1, result.PermissionEntries.Count, "(Unrestricted N Entry).Count");

            // 5. Entry N Unrestricted
            result = (ServiceControllerPermission)scp2.Intersect(scp1);
            Assert.IsFalse(result.IsUnrestricted(), "(Entry N Unrestricted).IsUnrestricted");
            Assert.AreEqual(1, result.PermissionEntries.Count, "(Entry N Unrestricted).Count");

            // 6. Unrestricted N Unrestricted
            scp1.PermissionEntries.Add(new ServiceControllerPermissionEntry(ServiceControllerPermissionAccess.None, "localhost", "http"));
            result = (ServiceControllerPermission)scp1.Intersect(scp1);
            Assert.IsTrue(result.IsUnrestricted(), "(Unrestricted N Unrestricted).IsUnrestricted");
            Assert.AreEqual(1, result.PermissionEntries.Count, "(Unrestricted N Unrestricted).Count");
        }
Ejemplo n.º 4
0
        public void Intersect_BadPermission()
        {
            ServiceControllerPermission scp1 = new ServiceControllerPermission(PermissionState.Unrestricted);

            scp1.Intersect(new SecurityPermission(SecurityPermissionFlag.Assertion));
        }