Beispiel #1
0
        public void Unrestricted()
        {
            PublisherIdentityPermissionAttribute a = new PublisherIdentityPermissionAttribute(SecurityAction.Assert);

            a.Unrestricted = true;
            IPermission perm = a.CreatePermission();
        }
Beispiel #2
0
        public void None()
        {
            PublisherIdentityPermissionAttribute attr = new PublisherIdentityPermissionAttribute(SecurityAction.Assert);

            Assert.IsNull(attr.CertFile, "None.CertFile");
            Assert.IsNull(attr.SignedFile, "None.SignedFile");
            Assert.IsNull(attr.X509Certificate, "None.X509Certificate");
            PublisherIdentityPermission p = (PublisherIdentityPermission)attr.CreatePermission();

            Assert.IsNull(p.Certificate, "None.CreatePermission");
        }
Beispiel #3
0
        public void Default()
        {
            PublisherIdentityPermissionAttribute a = new PublisherIdentityPermissionAttribute(SecurityAction.Assert);

            Assert.IsNull(a.CertFile, "CertFile");
            Assert.IsNull(a.SignedFile, "SignedFile");
            Assert.IsNull(a.X509Certificate, "X509Certificate");
            Assert.AreEqual(a.ToString(), a.TypeId.ToString(), "TypeId");
            Assert.IsFalse(a.Unrestricted, "Unrestricted");

            PublisherIdentityPermission perm = (PublisherIdentityPermission)a.CreatePermission();

            Assert.IsNull(perm.Certificate, "CreatePermission.Certificate");
        }
Beispiel #4
0
        public void X509CertificateProperty()
        {
            X509Certificate x509 = new X509Certificate(cert2);
            PublisherIdentityPermissionAttribute attr = new PublisherIdentityPermissionAttribute(SecurityAction.Assert);

            attr.CertFile        = null;
            attr.SignedFile      = null;
            attr.X509Certificate = x509.GetRawCertDataString();
            Assert.IsNull(attr.CertFile, "CertFile");
            Assert.IsNull(attr.SignedFile, "SignedFile");
            Assert.AreEqual(x509.GetRawCertDataString(), attr.X509Certificate, "X509Certificate");
            PublisherIdentityPermission p = (PublisherIdentityPermission)attr.CreatePermission();

            Assert.AreEqual(x509.GetRawCertDataString(), p.Certificate.GetRawCertDataString(), "X509CertificateProperty.Certificate");
        }
Beispiel #5
0
        public void Action()
        {
            PublisherIdentityPermissionAttribute a = new PublisherIdentityPermissionAttribute(SecurityAction.Assert);

            Assert.AreEqual(SecurityAction.Assert, a.Action, "Action=Assert");
            a.Action = SecurityAction.Demand;
            Assert.AreEqual(SecurityAction.Demand, a.Action, "Action=Demand");
            a.Action = SecurityAction.Deny;
            Assert.AreEqual(SecurityAction.Deny, a.Action, "Action=Deny");
            a.Action = SecurityAction.InheritanceDemand;
            Assert.AreEqual(SecurityAction.InheritanceDemand, a.Action, "Action=InheritanceDemand");
            a.Action = SecurityAction.LinkDemand;
            Assert.AreEqual(SecurityAction.LinkDemand, a.Action, "Action=LinkDemand");
            a.Action = SecurityAction.PermitOnly;
            Assert.AreEqual(SecurityAction.PermitOnly, a.Action, "Action=PermitOnly");
            a.Action = SecurityAction.RequestMinimum;
            Assert.AreEqual(SecurityAction.RequestMinimum, a.Action, "Action=RequestMinimum");
            a.Action = SecurityAction.RequestOptional;
            Assert.AreEqual(SecurityAction.RequestOptional, a.Action, "Action=RequestOptional");
            a.Action = SecurityAction.RequestRefuse;
            Assert.AreEqual(SecurityAction.RequestRefuse, a.Action, "Action=RequestRefuse");
        }
Beispiel #6
0
        public void Priority()
        {
            X509Certificate x509 = new X509Certificate(cert1);
            PublisherIdentityPermissionAttribute attr = new PublisherIdentityPermissionAttribute(SecurityAction.Assert);

            attr.CertFile        = "cert1.cer";
            attr.SignedFile      = "cert2.cer";
            attr.X509Certificate = x509.GetRawCertDataString();
            Assert.AreEqual("cert1.cer", attr.CertFile, "CertFile");
            Assert.AreEqual("cert2.cer", attr.SignedFile, "SignedFile");
            Assert.AreEqual(x509.GetRawCertDataString(), attr.X509Certificate, "X509Certificate");
            // from documentation X509Certificate has priority over CertFile and SignedFile
            PublisherIdentityPermission p = (PublisherIdentityPermission)attr.CreatePermission();

            Assert.AreEqual(x509.GetRawCertDataString(), p.Certificate.GetRawCertDataString(), "p.Certificate");
            // but no word about CertFile and SignedFile priority
            attr.CertFile        = "cert1.cer";
            attr.SignedFile      = "cert2.cer";
            attr.X509Certificate = null;
            p = (PublisherIdentityPermission)attr.CreatePermission();
            Assert.AreEqual(x509.GetRawCertDataString(), p.Certificate.GetRawCertDataString(), "p.Certificate");
            // CertFile !
        }
Beispiel #7
0
 public static void PublisherIdentityPermissionAttributeCallMethods()
 {
     PublisherIdentityPermissionAttribute pipa = new PublisherIdentityPermissionAttribute(new Permissions.SecurityAction());
     IPermission ip = pipa.CreatePermission();
 }
Beispiel #8
0
 public static void PublisherIdentityPermissionAttributeCallMethods()
 {
     PublisherIdentityPermissionAttribute pipa = new PublisherIdentityPermissionAttribute(new Permissions.SecurityAction());
     IPermission ip = pipa.CreatePermission();
 }
Beispiel #9
0
 public void Action_Invalid()
 {
     PublisherIdentityPermissionAttribute a = new PublisherIdentityPermissionAttribute((SecurityAction)Int32.MinValue);
     // no validation in attribute
 }