Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -28,7 +28,7 @@
//
// NET_2_1 profile lacks some (of the few) CAS features required to execute those tests
#if NET_2_0 && !NET_2_1
#if !NET_2_1
using NUnit.Framework;
using System;

View File

@@ -151,13 +151,8 @@ namespace MonoTests.System.Security {
NamedPermissionSet nps = new NamedPermissionSet ("name", null);
Assert.AreEqual ("name", nps.Name, "Name");
Assert.IsNull (nps.Description, "Description");
#if NET_2_0
Assert.IsTrue (!nps.IsUnrestricted (), "IsUnrestricted");
Assert.IsTrue (nps.IsEmpty (), "IsEmpty");
#else
Assert.IsTrue (nps.IsUnrestricted (), "IsUnrestricted");
Assert.IsTrue (!nps.IsEmpty (), "IsEmpty");
#endif
Assert.IsTrue (!nps.IsReadOnly, "IsReadOnly");
Assert.IsTrue (!nps.IsSynchronized, "IsSynchronized");
Assert.AreEqual (0, nps.Count, "Count");
@@ -348,10 +343,8 @@ namespace MonoTests.System.Security {
se = nps.ToXml ();
Assert.IsNull (se.Attribute ("Name"), "Name attribute");
#if NET_2_0
Assert.AreEqual (0, nps.GetHashCode (), "GetHashCode");
Assert.IsTrue (nps.Equals (nps), "Equals-self");
#endif
}
[Test]
@@ -407,7 +400,6 @@ namespace MonoTests.System.Security {
Assert.IsNull ((se.Attributes ["Description"] as string), "Unrestricted.Description");
Assert.AreEqual ("true", (se.Attributes ["Unrestricted"] as string), "Unrestricted.Unrestricted");
}
#if NET_2_0
[Test]
public void Equals ()
{
@@ -442,8 +434,7 @@ namespace MonoTests.System.Security {
psu.Description = sentinel;
Assert.IsTrue (psu.GetHashCode () == uhc, "GetHashCode-3");
}
#endif
}
}
#endif
#endif

View File

@@ -45,7 +45,6 @@ namespace MonoCasTests.System.Security {
Assert.Ignore ("SecurityManager isn't enabled");
}
#if NET_2_0
[Test]
[ExpectedException (typeof (ExecutionEngineException))]
public void RevertAssert_WithoutAssertion ()
@@ -60,6 +59,5 @@ namespace MonoCasTests.System.Security {
ups.Assert ();
PermissionSet.RevertAssert ();
}
#endif
}
}

View File

@@ -69,13 +69,8 @@ namespace MonoTests.System.Security {
{
// no exception is thrown
PermissionSet ps = new PermissionSet (null);
#if NET_2_0
Assert.IsTrue (!ps.IsUnrestricted (), "PermissionStateNull.IsUnrestricted");
Assert.IsTrue (ps.IsEmpty (), "PermissionStateNull.IsEmpty");
#else
Assert.IsTrue (ps.IsUnrestricted (), "PermissionStateNull.IsUnrestricted");
Assert.IsTrue (!ps.IsEmpty (), "PermissionStateNull.IsEmpty");
#endif
Assert.IsTrue (!ps.IsReadOnly, "PermissionStateNull.IsReadOnly");
Assert.AreEqual (ps.ToXml ().ToString (), ps.ToString (), "PermissionStateNull.ToXml().ToString()==ToString()");
Assert.IsTrue (!ps.ContainsNonCodeAccessPermissions (), "ContainsNonCodeAccessPermissions");
@@ -150,14 +145,9 @@ namespace MonoTests.System.Security {
ZoneIdentityPermission zip = new ZoneIdentityPermission (SecurityZone.MyComputer);
result = ps.AddPermission (zip);
Assert.IsNotNull (result, "Add(ZoneIdentityPermission)");
#if NET_2_0
// Identity permissions aren't added to unrestricted permission sets in 2.0
Assert.AreEqual (SecurityZone.NoZone, (result as ZoneIdentityPermission).SecurityZone, "ZoneIdentityPermission");
Assert.AreEqual (0, ps.Count, "1");
#else
Assert.AreEqual (zip.SecurityZone, (result as ZoneIdentityPermission).SecurityZone, "ZoneIdentityPermission");
Assert.AreEqual (1, ps.Count, "1");
#endif
}
[Test]
@@ -291,9 +281,6 @@ namespace MonoTests.System.Security {
}
[Test]
#if !NET_2_0
[Ignore ("Don't know why it doesn't work under Fx 1.1")]
#endif
public void ConvertPermissionSet_BinaryToBinary ()
{
PermissionSet ps = new PermissionSet (PermissionState.None);
@@ -306,9 +293,6 @@ namespace MonoTests.System.Security {
}
[Test]
#if !NET_2_0
[Ignore ("Don't know why it doesn't work under Fx 1.1")]
#endif
public void ConvertPermissionSet_XmlToBinary ()
{
PermissionSet ps = new PermissionSet (PermissionState.None);
@@ -335,11 +319,7 @@ namespace MonoTests.System.Security {
}
[Test]
#if NET_2_0
[ExpectedException (typeof (XmlSyntaxException))]
#else
[ExpectedException (typeof (ArgumentException))]
#endif
public void ConvertPermissionSet_XmlAsciiToXmlUnicode ()
{
PermissionSet ps = new PermissionSet (PermissionState.Unrestricted);
@@ -391,12 +371,8 @@ namespace MonoTests.System.Security {
Assert.IsNotNull (result, "2.Add");
copy = ps.Copy ();
Assert.IsTrue (copy.IsUnrestricted (), "3.State");
#if NET_2_0
// Identity permissions aren't added to unrestricted permission sets in 2.0
Assert.AreEqual (0, copy.Count, "3.Count");
#else
Assert.AreEqual (1, copy.Count, "3.Count");
#endif
}
[Test]
@@ -546,20 +522,11 @@ namespace MonoTests.System.Security {
se.AddAttribute ("Unrestricted", "true");
ps2.FromXml (se);
Assert.IsTrue (ps2.IsUnrestricted (), "FromXml-Unrestricted.IsUnrestricted");
#if NET_2_0
Assert.AreEqual (0, ps2.Count, "Unrestricted.Count");
#else
// IPermission not shown in XML but still present in Count
Assert.AreEqual (1, ps2.Count, "Unrestricted.Count");
#endif
}
[Test]
#if NET_2_0
[ExpectedException (typeof (TypeLoadException))]
#else
[ExpectedException (typeof (ArgumentException))]
#endif
public void FromXml_PermissionWithoutNamespace ()
{
SecurityElement child = new SecurityElement ("IPermission");
@@ -577,11 +544,7 @@ namespace MonoTests.System.Security {
}
[Test]
#if NET_2_0
[ExpectedException (typeof (TypeLoadException))]
#else
[ExpectedException (typeof (ArgumentException))]
#endif
public void FromXml_PermissionOutsideCorlib ()
{
SecurityElement child = new SecurityElement ("IPermission");
@@ -629,7 +592,6 @@ namespace MonoTests.System.Security {
}
Assert.AreEqual (1, i, "Count");
}
#if NET_2_0
[Test]
public void GetHashCode_ ()
{
@@ -641,7 +603,6 @@ namespace MonoTests.System.Security {
PermissionSet copy = ps.Copy ();
Assert.IsTrue (ps.GetHashCode () != copy.GetHashCode (), "Copy");
}
#endif
[Test]
public void GetPermission_Null ()
{
@@ -742,14 +703,9 @@ namespace MonoTests.System.Security {
Compare ("UPS1 N UPS2", ups1.Intersect (ups2), true, 0);
Compare ("UPS2 N UPS1", ups2.Intersect (ups1), true, 0);
ups2.AddPermission (zip);
#if NET_2_0
// Identity permissions aren't added to unrestricted permission sets in 2.0
Compare ("UPS1 N UPS2+ZIP", ups1.Intersect (ups2), true, 0);
Compare ("UPS2+ZIP N UPS1", ups2.Intersect (ups1), true, 0);
#else
Compare ("UPS1 N UPS2+ZIP", ups1.Intersect (ups2), true, 1);
Compare ("UPS2+ZIP N UPS1", ups2.Intersect (ups1), true, 1);
#endif
}
[Test]
@@ -768,12 +724,8 @@ namespace MonoTests.System.Security {
PermissionSet ps = new PermissionSet (PermissionState.Unrestricted);
Assert.IsTrue (!ps.IsEmpty (), "Unrestricted.IsEmpty");
ps.AddPermission (new ZoneIdentityPermission (SecurityZone.NoZone));
#if NET_2_0
// Identity permissions aren't added to unrestricted permission sets in 2.0
Assert.AreEqual (0, ps.Count, "Count==0");
#else
Assert.AreEqual (1, ps.Count, "Count==1");
#endif
Assert.IsTrue (!ps.IsEmpty ()); // yes empty!, "Zip.IsEmpty");
}
@@ -837,12 +789,8 @@ namespace MonoTests.System.Security {
Assert.IsTrue (!ups1.IsSubsetOf (ps1), "Unrestricted.IsSubset(PS1)");
PermissionSet ups2 = new PermissionSet (PermissionState.Unrestricted);
#if NET_2_0
// as ZoneIdentityPermission isn't added UPS1Z == UPS2
Assert.IsTrue (ups1.IsSubsetOf (ups2), "UPS1Z.IsSubset(UPS2)");
#else
Assert.IsTrue (!ups1.IsSubsetOf (ups2), "UPS1Z.IsSubset(UPS2)");
#endif
Assert.IsTrue (ups2.IsSubsetOf (ups1), "UPS2.IsSubset(UPS1Z)");
ups2.AddPermission (zip);
Assert.IsTrue (ups1.IsSubsetOf (ups2), "UPS1Z.IsSubset(UPS2Z)");
@@ -864,11 +812,7 @@ namespace MonoTests.System.Security {
Assert.IsTrue (ps3.IsSubsetOf (ps1), "PS3.IsSubset(PS1)");
PermissionSet ups1 = new PermissionSet (PermissionState.Unrestricted);
#if NET_2_0
Assert.IsTrue (ps1.IsSubsetOf (ups1), "PS1.IsSubset(Unrestricted)");
#else
Assert.IsTrue (!ps1.IsSubsetOf (ups1), "PS1.IsSubset(Unrestricted)");
#endif
Assert.IsTrue (!ups1.IsSubsetOf (ps1), "Unrestricted.IsSubset(PS1)");
}
@@ -906,11 +850,7 @@ namespace MonoTests.System.Security {
Assert.IsTrue (ps3.IsSubsetOf (ps1), "PS3.IsSubset(PS1)");
PermissionSet ups1 = new PermissionSet (PermissionState.Unrestricted);
#if NET_2_0
Assert.IsTrue (ps1.IsSubsetOf (ups1), "PS1.IsSubset(Unrestricted)");
#else
Assert.IsTrue (!ps1.IsSubsetOf (ups1), "PS1.IsSubset(Unrestricted)");
#endif
Assert.IsTrue (!ups1.IsSubsetOf (ps1), "Unrestricted.IsSubset(PS1)");
}
@@ -945,13 +885,9 @@ namespace MonoTests.System.Security {
ZoneIdentityPermission zip = new ZoneIdentityPermission (SecurityZone.MyComputer);
ps.AddPermission (zip);
ZoneIdentityPermission removed = (ZoneIdentityPermission)ps.RemovePermission (typeof (ZoneIdentityPermission));
#if NET_2_0
// identity permissions aren't added to unrestricted permission sets
// so they cannot be removed later (hence the null)
Assert.IsNull (removed, "ZoneIdentityPermission");
#else
Assert.IsNotNull (removed, "ZoneIdentityPermission");
#endif
}
[Test]
@@ -1002,13 +938,9 @@ namespace MonoTests.System.Security {
ZoneIdentityPermission zipr = (ZoneIdentityPermission)ps.SetPermission (zip);
Assert.AreEqual (1, ps.Count, "ZoneIdentityPermission");
Assert.AreEqual (SecurityZone.MyComputer, zipr.SecurityZone, "SecurityZone");
#if NET_2_0
// Adding a non unrestricted identity permission now results in
// a permission set loosing it's unrestricted status
Assert.IsTrue (!ps.IsUnrestricted (), "State-Unrestricted-2");
#else
Assert.IsTrue (ps.IsUnrestricted (), "State-Unrestricted-2");
#endif
zip = new ZoneIdentityPermission (SecurityZone.Intranet);
zipr = (ZoneIdentityPermission)ps.SetPermission (zip);
Assert.AreEqual (1, ps.Count, "ZoneIdentityPermission-2");
@@ -1103,7 +1035,6 @@ namespace MonoTests.System.Security {
PermissionSet ups1 = new PermissionSet (PermissionState.Unrestricted);
ups1.AddPermission (zip);
#if NET_2_0
// Identity permissions aren't added to unrestricted permission sets in 2.0
Compare ("PS1 U Unrestricted", ps1.Union (ups1), true, 0);
Compare ("Unrestricted U PS1", ups1.Union (ps1), true, 0);
@@ -1113,18 +1044,7 @@ namespace MonoTests.System.Security {
ups2.AddPermission (zip);
Compare ("UPS1 U UPS2+ZIP", ups1.Union (ups2), true, 0);
Compare ("UPS2+ZIP U UPS1", ups2.Union (ups1), true, 0);
#else
Compare ("PS1 U Unrestricted", ps1.Union (ups1), true, 1);
Compare ("Unrestricted U PS1", ups1.Union (ps1), true, 1);
PermissionSet ups2 = new PermissionSet (PermissionState.Unrestricted);
Compare ("UPS1 U UPS2", ups1.Union (ups1), true, 1);
Compare ("UPS2 U UPS1", ups2.Union (ups1), true, 1);
ups2.AddPermission (zip);
Compare ("UPS1 U UPS2+ZIP", ups1.Union (ups2), true, 1);
Compare ("UPS2+ZIP U UPS1", ups2.Union (ups1), true, 1);
#endif
}
#if NET_2_0
[Test]
[Category ("NotWorking")] // requires imperative stack modifiers
[ExpectedException (typeof (ExecutionEngineException))]
@@ -1141,7 +1061,6 @@ namespace MonoTests.System.Security {
ups.Assert ();
PermissionSet.RevertAssert ();
}
#endif
[Test]
public void Assert_NonCasPermission ()
{

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Reflection;
@@ -83,4 +82,3 @@ namespace MonoCasTests.System.Security {
}
}
#endif

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Security;
@@ -405,4 +404,3 @@ namespace MonoTests.System.Security {
}
}
#endif

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Security;
@@ -169,4 +168,3 @@ namespace MonoCasTests.System.Security {
}
}
#endif

View File

@@ -601,15 +601,11 @@ namespace MonoTests.System.Security {
SecurityElement se = new SecurityElement ("Multiple");
se.AddAttribute ("Attribute1", "One");
se.AddAttribute ("Attribute2", "Two");
#if NET_2_0
string expected = String.Format ("<Multiple Attribute1=\"One\"{0}Attribute2=\"Two\"/>{0}", Environment.NewLine);
#else
string expected = String.Format ("<Multiple Attribute1=\"One\"{0} Attribute2=\"Two\"/>{0}", Environment.NewLine);
#endif
Assert.AreEqual (expected, se.ToString (), "ToString()");
}
#if NET_2_0
[Test]
public void Copy ()
{
@@ -735,7 +731,6 @@ namespace MonoTests.System.Security {
Assert.AreEqual ("Suds&#x26;Soda&#38;", se.Text, "#5");
Assert.IsNull (se.Children, "#6");
}
#endif
[Test] // bug #333699 (ugh, mostly a dup)
public void TestToString ()
@@ -749,17 +744,11 @@ namespace MonoTests.System.Security {
Assert.AreEqual ("<'Suds' & \"Soda\">!", infoValue.Text, "#2");
Assert.IsNull (values.Text, "#3");
#if NET_2_0
Assert.AreEqual (String.Format ("<values>{0}<value name=\"string\">&lt;&apos;Suds&apos; &amp; &quot;Soda&quot;&gt;!</value>{0}</values>{0}", Environment.NewLine), values.ToString (), "#4");
#else
Assert.AreEqual (String.Format ("<values>{0} <value name=\"string\">&lt;&apos;Suds&apos; &amp; &quot;Soda&quot;&gt;!</value>{0}</values>{0}", Environment.NewLine), values.ToString (), "#4");
#endif
#if NET_2_0
SecurityElement sec = SecurityElement.FromString (values.ToString ());
Assert.AreEqual (1, sec.Children.Count, "#5");
Assert.AreEqual ("<'Suds' & \"Soda\">!", ((SecurityElement) sec.Children [0]).Text, "#6");
#endif
}
}
}

View File

@@ -53,7 +53,6 @@ namespace MonoCasTests.System.Security {
}
#if NET_2_0
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void GetAction ()
@@ -187,7 +186,6 @@ namespace MonoCasTests.System.Security {
{
se.FirstPermissionThatFailed = null;
}
#endif
[Test]
[SecurityPermission (SecurityAction.PermitOnly, ControlEvidence = true, ControlPolicy = true)]
public void GetGrantedSet_Pass ()
@@ -210,7 +208,6 @@ namespace MonoCasTests.System.Security {
{
string s = se.GrantedSet;
}
#if NET_2_0
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void SetGrantedSet ()
@@ -247,7 +244,6 @@ namespace MonoCasTests.System.Security {
{
se.Method = null;
}
#endif
[Test]
[SecurityPermission (SecurityAction.PermitOnly, ControlEvidence = true, ControlPolicy = true)]
public void GetPermissionState_Pass ()
@@ -270,7 +266,6 @@ namespace MonoCasTests.System.Security {
{
string s = se.PermissionState;
}
#if NET_2_0
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void SetPermissionState ()
@@ -307,7 +302,6 @@ namespace MonoCasTests.System.Security {
{
se.PermitOnlySetInstance = null;
}
#endif
[Test]
[SecurityPermission (SecurityAction.PermitOnly, ControlEvidence = true, ControlPolicy = true)]
public void GetRefusedSet_Pass ()
@@ -330,7 +324,6 @@ namespace MonoCasTests.System.Security {
{
string s = se.RefusedSet;
}
#if NET_2_0
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void SetRefusedSet ()
@@ -381,7 +374,6 @@ namespace MonoCasTests.System.Security {
{
se.Zone = SecurityZone.Untrusted;
}
#endif
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void ToString_Empty ()

View File

@@ -72,11 +72,7 @@ namespace MonoCasTests.System.Security {
[Test]
[SecurityPermission (SecurityAction.Deny, ControlPolicy = true)]
#if NET_2_0
// it seems that this was removed in 2.0 - maybe because you can't turn CAS off ?!?
#else
[ExpectedException (typeof (SecurityException))]
#endif
public void SecurityEnabled_DenyControlPolicy ()
{
SecurityManager.SecurityEnabled = false;
@@ -93,7 +89,6 @@ namespace MonoCasTests.System.Security {
// the Deny shows that IsGranted only checks for assembly
// granted set (and not the stack modifiers)
#if NET_2_0
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void IsGranted_GacIdentityPermission ()
@@ -101,17 +96,12 @@ namespace MonoCasTests.System.Security {
GacIdentityPermission gip = new GacIdentityPermission ();
Assert.IsTrue (SecurityManager.IsGranted (gip));
}
#endif
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void IsGranted_ZoneIdentityPermission ()
{
ZoneIdentityPermission zip = new ZoneIdentityPermission (SecurityZone.Internet);
#if NET_2_0
Assert.IsTrue (SecurityManager.IsGranted (zip));
#else
Assert.IsFalse (SecurityManager.IsGranted (zip));
#endif
}
[Test]

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Security;
@@ -54,5 +53,4 @@ namespace MonoTests.System.Security {
}
}
#endif

View File

@@ -27,7 +27,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
@@ -54,4 +53,3 @@ namespace MonoTests.System.Security {
}
}
#endif