+2004-09-01 Sebastien Pouliot <sebastien@ximian.com>
+
+ * EnvironmentPermissionTest.cs: Fixed tests so they execute without
+ errors on both Fx 1.1 and Fx 2.0 (beta 1).
+ * PublisherIdentityPermissionTest.cs: Fixed tests so they execute
+ without errors on both Fx 1.1 and Fx 2.0 (beta 1).
+ * SiteIdentityPermissionTest.cs: Fixed tests so they execute without
+ errors on both Fx 1.1 and Fx 2.0 (beta 1). Fixed line endings.
+ * StrongNameIdentityPermissionTest.cs: Fixed tests so they execute
+ without errors on both Fx 1.1 and Fx 2.0 (beta 1).
+ * StrongNamePublicKeyBlobTest.cs: Fixed tests so they execute without
+ errors on both Fx 1.1 and Fx 2.0 (beta 1). Converted tests to NUnit
+ 2.2 format.
+ * UrlIdentityPermissionTest.cs: Fixed tests so they execute without
+ errors on both Fx 1.1 and Fx 2.0 (beta 1).
+
2004-09-01 Sebastien Pouliot <sebastien@ximian.com>
* ZoneIdentityPermissionTest.cs: Ensure we aren't encoding NoZone in
// EnvironmentPermissionTest.cs - NUnit Test Cases for EnvironmentPermission
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
public void GetPathList ()
{
EnvironmentPermission ep = new EnvironmentPermission (PermissionState.None);
+#if NET_2_0
+ AssertEquals ("GetPathList-Read-Empty", String.Empty, ep.GetPathList (EnvironmentPermissionAccess.Read));
+ AssertEquals ("GetPathList-Write-Empty", String.Empty, ep.GetPathList (EnvironmentPermissionAccess.Write));
+#else
AssertNull ("GetPathList-Read-Empty", ep.GetPathList (EnvironmentPermissionAccess.Read));
AssertNull ("GetPathList-Write-Empty", ep.GetPathList (EnvironmentPermissionAccess.Write));
+#endif
ep.AddPathList (EnvironmentPermissionAccess.Read, "UID");
ep.AddPathList (EnvironmentPermissionAccess.Write, "PROMPT");
AssertEquals ("GetPathList-Read", "UID", ep.GetPathList (EnvironmentPermissionAccess.Read));
//
-// PublisherIdentityPermissionTest.cs - NUnit Test Cases for PublisherIdentityPermission
+// PublisherIdentityPermissionTest.cs -
+// NUnit Test Cases for PublisherIdentityPermission
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
p2 = new PublisherIdentityPermission (PermissionState.None);
p3 = (PublisherIdentityPermission) p1.Union (p2);
AssertEquals ("cert U None == cert", p3.ToXml ().ToString (), p1.ToXml ().ToString ());
- // 2 different certificates
X509Certificate x2 = new X509Certificate (cert2);
+#if !NET_2_0
+ // 2 different certificates
p2 = new PublisherIdentityPermission (x2);
p3 = (PublisherIdentityPermission) p1.Union (p2);
AssertNull ("cert1 U cert2 == null", p3);
+#endif
// 2 certificates (same)
x2 = new X509Certificate (cert);
p2 = new PublisherIdentityPermission (x2);
AssertEquals ("cert1 U cert1 == cert1", p3.ToString (), p1.ToString ());
}
+#if NET_2_0
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Union_DifferentCertificates ()
+ {
+ PublisherIdentityPermission p1 = new PublisherIdentityPermission (x509);
+ X509Certificate x2 = new X509Certificate (cert2);
+ PublisherIdentityPermission p2 = new PublisherIdentityPermission (x2);
+ p1.Union (p2);
+ }
+#endif
+
[Test]
[ExpectedException (typeof (ArgumentException))]
public void UnionWithBadPermission ()
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void Union_Different ()
{
SiteIdentityPermission sip1 = new SiteIdentityPermission (GoodSites [0]);
//
-// StrongNameIdentityPermissionTest.cs - NUnit Test Cases for StrongNameIdentityPermission
+// StrongNameIdentityPermissionTest.cs -
+// NUnit Test Cases for StrongNameIdentityPermission
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void StrongNameIdentityPermission_NameEmpty ()
{
StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, String.Empty, new Version (1, 2));
+#if !NET_2_0
+ // TODO
+#endif
}
[Test]
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void Name_Empty ()
{
StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));
snip.Name = String.Empty;
+#if !NET_2_0
+ Assert.AreEqual (String.Empty, snip.Name, "Name");
+#endif
}
[Test]
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void Copy_NameEmpty ()
{
StrongNameIdentityPermission snip = new StrongNameIdentityPermission (PermissionState.None);
// because Name == String.Empty, which is illegal using the other constructor
// but (somewhat) required to copy the teo other informations
StrongNameIdentityPermission copy = (StrongNameIdentityPermission)snip.Copy ();
+#if !NET_2_0
+ // TODO
+#endif
}
private void Compare (StrongNameIdentityPermission p1, StrongNameIdentityPermission p2, string prefix)
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void Union_DifferentPk ()
{
StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));
StrongNamePublicKeyBlob blob2 = new StrongNamePublicKeyBlob (new byte [16]);
StrongNameIdentityPermission diffPk = new StrongNameIdentityPermission (blob2, "mono", new Version (1, 2, 3, 4));
- snip.Union (diffPk);
+ StrongNameIdentityPermission result = (StrongNameIdentityPermission) snip.Union (diffPk);
+#if !NET_2_0
+ // TODO
+#endif
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void Union_SamePublicKey_DifferentName ()
{
StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));
StrongNameIdentityPermission diffName = new StrongNameIdentityPermission (blob, "novell", null);
- snip.Union (diffName);
+ StrongNameIdentityPermission result = (StrongNameIdentityPermission) snip.Union (diffName);
+#if !NET_2_0
+ // TODO
+#endif
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void Union_SamePublicKey_DifferentVersion ()
{
StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (ecma);
StrongNameIdentityPermission snip = new StrongNameIdentityPermission (blob, "mono", new Version (1, 2, 3, 4));
StrongNameIdentityPermission diffVersion = new StrongNameIdentityPermission (blob, null, new Version (1, 2));
- snip.Union (diffVersion);
+ StrongNameIdentityPermission result = (StrongNameIdentityPermission) snip.Union (diffVersion);
+#if !NET_2_0
+ // TODO
+#endif
}
[Test]
// StrongNamePublicKeyBlobTest.cs - NUnit Test Cases for StrongNamePublicKeyBlob
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
namespace MonoTests.System.Security.Permissions {
[TestFixture]
-public class StrongNamePublicKeyBlobTest : Assertion {
+public class StrongNamePublicKeyBlobTest {
static byte[] bad = { 0xB, 0xAD };
// should be a valid one (see StrongNameKeyPairTest.cs)
{
StrongNamePublicKeyBlob snpkb = new StrongNamePublicKeyBlob (bad);
// Proof that there's no validation on public key
- AssertEquals ("ToString(BAD)", "0BAD", snpkb.ToString ());
+ Assert.AreEqual ("0BAD", snpkb.ToString (), "ToString(BAD)");
}
[Test]
public void PublicKey ()
{
StrongNamePublicKeyBlob snpkb = new StrongNamePublicKeyBlob (pk);
- Assert ("Equals(Self)", snpkb.Equals (snpkb));
- AssertEquals ("ToString(pk)", "00240000048000009400000006020000002400005253413100040000010001003DBD7208C62B0EA8C1C058072B635F7C9ABDCB22DB20B2A9DADAEFE800642F5D8DEB7802F7A5367728D7558D1468DBEB2409D02B131B926E2E59544AAC18CFC909023F4FA83E94001FC2F11A27477D1084F514B861621A0C66ABD24C4B9FC90F3CD8920FF5FFCED76E5C6FB1F57DD356F96727A4A5485B079344004AF8FFA4CB", snpkb.ToString ());
+ Assert.IsTrue (snpkb.Equals (snpkb), "Equals(Self)");
+ Assert.IsFalse (snpkb.Equals (null), "Equals(null)");
+ Assert.AreEqual ("00240000048000009400000006020000002400005253413100040000010001003DBD7208C62B0EA8C1C058072B635F7C9ABDCB22DB20B2A9DADAEFE800642F5D8DEB7802F7A5367728D7558D1468DBEB2409D02B131B926E2E59544AAC18CFC909023F4FA83E94001FC2F11A27477D1084F514B861621A0C66ABD24C4B9FC90F3CD8920FF5FFCED76E5C6FB1F57DD356F96727A4A5485B079344004AF8FFA4CB", snpkb.ToString (), "ToString(pk)");
StrongNamePublicKeyBlob snpkb2 = new StrongNamePublicKeyBlob (pk);
- Assert ("Equals()-true", snpkb.Equals (snpkb2));
+ Assert.IsTrue (snpkb.Equals (snpkb2), "Equals()-true");
StrongNamePublicKeyBlob snpkb3 = new StrongNamePublicKeyBlob (bad);
- Assert ("Equals()-false", !snpkb.Equals (snpkb3));
+ Assert.IsFalse (snpkb.Equals (snpkb3), "Equals()-false");
// non standard get hash code - why ???
+ Assert.AreEqual (snpkb2.GetHashCode (), snpkb.GetHashCode (), "GetHashCode-0");
+#if NET_2_0
+ // the first 4 bytes has code has been fixed in 2.0 beta 1
+#elif NET_1_1
// It seems to be the first four bytes of the public key data
// which seems like non sense as all valid public key will have the same header ?
- AssertEquals ("GetHashCode-1", 2359296, snpkb.GetHashCode ());
- AssertEquals ("GetHashCode-2", 2359296, snpkb2.GetHashCode ());
- AssertEquals ("GetHashCode-3", 2989, snpkb3.GetHashCode ());
+ Assert.AreEqual (2359296, snpkb.GetHashCode (), "GetHashCode-1");
+ Assert.AreEqual (2359296, snpkb2.GetHashCode (), "GetHashCode-2");
+ Assert.AreEqual (2989, snpkb3.GetHashCode (), "GetHashCode-3");
+ byte[] header = { 0x00, 0x24, 0x00, 0x00 };
+ StrongNamePublicKeyBlob snpkb4 = new StrongNamePublicKeyBlob (header);
+ Assert.AreEqual (2359296, snpkb4.GetHashCode (), "GetHashCode-4");
+#endif
}
}
Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes");
Assert.IsNull (se.Children, "Xml-Children");
- UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy ();
- Assert.IsFalse (Object.ReferenceEquals (uip, copy), "ReferenceEquals");
+// UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy ();
+// Assert.IsFalse (Object.ReferenceEquals (uip, copy), "ReferenceEquals");
}
#if !NET_2_0
UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None);
foreach (string s in GoodUrls) {
uip.Url = s;
+#if NET_2_0
Assert.AreEqual (s, uip.Url, s);
+#else
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+#endif
}
}
public void Copy ()
{
UrlIdentityPermission uip = new UrlIdentityPermission (PermissionState.None);
- foreach (string s in GoodUrls)
- {
+ foreach (string s in GoodUrls) {
uip.Url = s;
UrlIdentityPermission copy = (UrlIdentityPermission)uip.Copy ();
- Assert.AreEqual (s, copy.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.AreEqual (uip.Url, copy.Url, "Url");
}
}
foreach (string s in GoodUrls) {
uip.Url = s;
UrlIdentityPermission result = (UrlIdentityPermission)uip.Intersect (uip);
- Assert.AreEqual (s, result.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (result.Url.StartsWith (uip.Url), s);
}
}
foreach (string s in GoodUrls) {
uip.Url = s;
UrlIdentityPermission union = (UrlIdentityPermission)uip.Union (null);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip.Url), s);
}
}
foreach (string s in GoodUrls) {
uip1.Url = s;
UrlIdentityPermission union = (UrlIdentityPermission)uip1.Union (uip2);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip1.Url), s);
}
uip1 = new UrlIdentityPermission (PermissionState.None);
// b. destination (target) is none
foreach (string s in GoodUrls) {
uip2.Url = s;
UrlIdentityPermission union = (UrlIdentityPermission)uip2.Union (uip1);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip2.Url), s);
}
}
foreach (string s in GoodUrls) {
uip.Url = s;
union = (UrlIdentityPermission)uip.Union (uip);
- Assert.AreEqual (s, union.Url, s);
+ // Fx 1.0/1.1 adds a '/' at the end, while 2.0 keeps the original format
+ // so we only compare the start of the url
+ Assert.IsTrue (union.Url.StartsWith (uip.Url), s);
}
}
[Test]
+#if NET_2_0
[ExpectedException (typeof (ArgumentException))]
+#endif
public void Union_Different ()
{
UrlIdentityPermission uip1 = new UrlIdentityPermission (GoodUrls [0]);