Esempio n. 1
0
        public void CreateSandboxSimpleTest()
        {
            PermissionSet sandboxSet = PermissionSetFactory.GetStandardPermissionSet(StandardPermissionSet.LocalIntranet, new Url(Path.GetTempPath()));
            AppDomain     sandbox    = SandboxFactory.CreateSandbox(Path.GetTempPath(), sandboxSet);

            Assert.IsTrue(sandbox.IsSandboxed());
            Assert.IsTrue(sandbox.GetPermissionSet().IsSubsetOf(sandboxSet));
            Assert.IsTrue(sandboxSet.IsSubsetOf(sandbox.GetPermissionSet()));
            Assert.AreEqual(Path.GetTempPath(), sandbox.BaseDirectory);
        }
Esempio n. 2
0
        public void CreateSandboxFullTrustListTest()
        {
            PermissionSet sandboxSet = PermissionSetFactory.GetStandardPermissionSet(StandardPermissionSet.LocalIntranet, new Url(Path.GetTempPath()));

            // Yes, both mscorlib and System.dll are in the GAC and would therefore be fully trusted anyway,
            // without needing this list.  However, by adding them here we can ensure that the strong names
            // are flowing properly.
            AppDomain sandbox = SandboxFactory.CreateSandbox(Path.GetTempPath(),
                                                             sandboxSet,
                                                             typeof(object).Assembly,
                                                             typeof(System.Diagnostics.Debug).Assembly);

            Assert.IsTrue(sandbox.IsSandboxed());
            Assert.IsTrue(sandbox.GetPermissionSet().IsSubsetOf(sandboxSet));
            Assert.IsTrue(sandboxSet.IsSubsetOf(sandbox.GetPermissionSet()));
            Assert.AreEqual(Path.GetTempPath(), sandbox.BaseDirectory);

            IList <StrongName> fullTrustList = sandbox.ApplicationTrust.GetFullTrustAssemblies();

            Assert.AreEqual(2, fullTrustList.Count);

            Assert.IsTrue(fullTrustList.Contains(typeof(object).Assembly.GetStrongName()));
            Assert.IsTrue(fullTrustList.Contains(typeof(System.Diagnostics.Debug).Assembly.GetStrongName()));
        }
Esempio n. 3
0
 public void CreateSandboxNullGrantTest()
 {
     SandboxFactory.CreateSandbox(Path.GetTempPath(), null);
 }
Esempio n. 4
0
 public void CreateSandboxNullAppBaseTest()
 {
     SandboxFactory.CreateSandbox(null, PermissionSetFactory.GetStandardPermissionSet(StandardPermissionSet.Internet));
 }