Beispiel #1
0
        public void FromXml_InvalidTag()
        {
            ApplicationTrust at = new ApplicationTrust();
            SecurityElement  se = at.ToXml();

            se.Tag = "MonoTrust";
            at.FromXml(se);
        }
        public static void ApplicationTrustCallMethods()
        {
            ApplicationTrust at = new ApplicationTrust();
            SecurityElement  se = new SecurityElement("");

            at.FromXml(se);
            se = at.ToXml();
        }
Beispiel #3
0
        public void FromXml_NoVersion()
        {
            ApplicationTrust at = new ApplicationTrust();
            SecurityElement  se = at.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            foreach (SecurityElement child in se.Children)
            {
                w.AddChild(child);
            }

            at.FromXml(w);
        }
Beispiel #4
0
        public void FromXml_InvalidVersion()
        {
            ApplicationTrust at = new ApplicationTrust();
            SecurityElement  se = at.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", "2");
            foreach (SecurityElement child in se.Children)
            {
                w.AddChild(child);
            }

            at.FromXml(w);
        }
Beispiel #5
0
        public void FromXml_NoChild()
        {
            ApplicationTrust at = new ApplicationTrust();
            SecurityElement  se = at.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", "1");

            at.FromXml(w);

            Assert.IsNull(at.ApplicationIdentity, "ApplicationIdentity");
            Assert.AreEqual(PolicyStatementAttribute.Nothing, at.DefaultGrantSet.Attributes, "DefaultGrantSet.Attributes");
            Assert.AreEqual(String.Empty, at.DefaultGrantSet.AttributeString, "DefaultGrantSet.AttributeString");
            Assert.IsTrue(at.DefaultGrantSet.PermissionSet.IsEmpty(), "DefaultGrantSet.PermissionSet.IsEmpty");
            Assert.IsFalse(at.DefaultGrantSet.PermissionSet.IsUnrestricted(), "DefaultGrantSet.PermissionSet.IsUnrestricted");
            Assert.IsNull(at.ExtraInfo, "ExtraInfo");
            Assert.IsFalse(at.IsApplicationTrustedToRun, "IsApplicationTrustedToRun");
            Assert.IsFalse(at.Persist, "Persist");
        }
Beispiel #6
0
        public void ToFromXmlRoundtrip()
        {
            ApplicationTrust at = new ApplicationTrust();

            at.ApplicationIdentity       = new ApplicationIdentity("Mono Unit Test");
            at.DefaultGrantSet           = new PolicyStatement(new PermissionSet(PermissionState.Unrestricted));
            at.ExtraInfo                 = "Mono";
            at.IsApplicationTrustedToRun = true;
            at.Persist = true;

            SecurityElement se       = at.ToXml();
            string          expected = AdjustLineEnds("<ApplicationTrust version=\"1\"\r\nFullName=\"Mono Unit Test, Culture=neutral\"\r\nTrustedToRun=\"true\"\r\nPersist=\"true\">\r\n<DefaultGrant>\r\n<PolicyStatement version=\"1\">\r\n<PermissionSet class=\"System.Security.PermissionSet\"\r\nversion=\"1\"\r\nUnrestricted=\"true\"/>\r\n</PolicyStatement>\r\n</DefaultGrant>\r\n<ExtraInfo Data=\"0001000000FFFFFFFF01000000000000000601000000044D6F6E6F0B\"/>\r\n</ApplicationTrust>\r\n");

            Assert.AreEqual(expected, AdjustLineEnds(at.ToXml().ToString()), "XML");

            ApplicationTrust copy = new ApplicationTrust();

            copy.FromXml(se);
            se = copy.ToXml();
            Assert.AreEqual(expected, AdjustLineEnds(at.ToXml().ToString()), "Copy");
        }
Beispiel #7
0
        public void FromXml_Null()
        {
            ApplicationTrust at = new ApplicationTrust();

            at.FromXml(null);
        }