Пример #1
0
        public void GetGrantSetTest()
        {
            AppDomain homogenousTrusted = AppDomainFactory.CreateHomogenousDomain(new PermissionSet(PermissionState.Unrestricted));

            Assert.IsTrue(homogenousTrusted.GetPermissionSet().IsUnrestricted());

            PermissionSet execution = new PermissionSet(PermissionState.None);

            execution.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
            AppDomain homogenousPartialTrust = AppDomainFactory.CreateHomogenousDomain(execution);

            PermissionSet homogenousPartialTrustGrant = homogenousPartialTrust.GetPermissionSet();

            Assert.IsTrue(homogenousPartialTrustGrant.IsSubsetOf(execution) &&
                          execution.IsSubsetOf(homogenousPartialTrustGrant));

            Evidence  myComputer    = new Evidence(new object[] { new Zone(SecurityZone.MyComputer) }, new object[] { });
            AppDomain legacyTrusted = AppDomainFactory.CreateLegacySandbox(myComputer);

            Assert.IsTrue(legacyTrusted.GetPermissionSet().IsUnrestricted());

            Evidence  internet           = new Evidence(new object[] { new Zone(SecurityZone.Internet) }, new object[] { });
            AppDomain legacyPartialTrust = AppDomainFactory.CreateLegacySandbox(internet);

            PermissionSet legacyPartialTrustGrant = legacyPartialTrust.GetPermissionSet();
            PermissionSet internetGrant           = SecurityManager.ResolveSystemPolicy(internet);

            Assert.IsTrue(legacyPartialTrustGrant.IsSubsetOf(internetGrant) &&
                          internetGrant.IsSubsetOf(legacyPartialTrustGrant));
        }
Пример #2
0
        public void IsSandboxedTest()
        {
            Assert.IsFalse(AppDomainFactory.CreateHomogenousDomain(new PermissionSet(PermissionState.Unrestricted)).IsSandboxed());

            PermissionSet execution = new PermissionSet(PermissionState.None);

            execution.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
            Assert.IsTrue(AppDomainFactory.CreateHomogenousDomain(execution).IsSandboxed());

            Evidence myComputer = new Evidence(new object[] { new Zone(SecurityZone.MyComputer) }, new object[] { });

            Assert.IsFalse(AppDomainFactory.CreateLegacySandbox(myComputer).IsSandboxed());

            Evidence internet = new Evidence(new object[] { new Zone(SecurityZone.Internet) }, new object[] { });

            Assert.IsTrue(AppDomainFactory.CreateLegacySandbox(internet).IsSandboxed());
        }
Пример #3
0
 public void IsHomogenousTest()
 {
     Assert.IsTrue(AppDomainFactory.CreateHomogenousDomain(new PermissionSet(PermissionState.Unrestricted)).IsHomogenous());
     Assert.IsFalse(AppDomainFactory.CreateLegacySandbox(AppDomain.CurrentDomain.Evidence).IsHomogenous());
 }