[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Security Makefil
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Security Makefile, NONE, 1.1 SuiteSecurity.cs, NONE, 1.1 TestSecurityElement.cs, NONE, 1.1 TestSecurityExceptions.cs, NONE, 1.1 code-review.txt, NONE, 1.1 |
Date: |
Wed, 23 Jul 2003 00:57:34 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Security
In directory subversions:/tmp/cvs-serv5482/tests/runtime/System/Security
Added Files:
Makefile SuiteSecurity.cs TestSecurityElement.cs
TestSecurityExceptions.cs code-review.txt
Log Message:
Some test cases and bug fixes for "System.Security".
--- NEW FILE ---
all:
(cd ../..; make)
check:
(cd ../..; make check)
--- NEW FILE ---
/*
* SuiteSecurity.cs - Tests for "System.Security".
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
public class SuiteSecurity
{
public static TestSuite Suite()
{
TestSuite suite = new TestSuite("Security
Tests");
suite.AddTests(typeof(TestSecurityExceptions));
suite.AddTests(typeof(TestSecurityElement));
return suite;
}
}; // class SuiteSecurity
--- NEW FILE ---
/*
* TestSecurityElement.cs - Test the "SecurityElement" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Security;
public class TestSecurityElement : TestCase
{
// Constructor.
public TestSecurityElement(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
// Nothing to do here.
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
#if CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS
// Test the constructor.
public void TestSecurityElementConstructor()
{
SecurityElement e;
try
{
e = new SecurityElement(null);
Fail("Constructor (1)");
}
catch(ArgumentNullException)
{
// Success.
}
try
{
e = new SecurityElement("");
Fail("Constructor (2)");
}
catch(ArgumentException)
{
// Success.
}
try
{
e = new SecurityElement("<");
Fail("Constructor (3)");
}
catch(ArgumentException)
{
// Success.
}
try
{
e = new SecurityElement("a", "<");
Fail("Constructor (4)");
}
catch(ArgumentException)
{
// Success.
}
try
{
e = new SecurityElement("&");
Fail("Constructor (5)");
}
catch(ArgumentException)
{
// Success.
}
e = new SecurityElement("foo", "bar");
AssertEquals("Constructor (6)", "foo", e.Tag);
AssertEquals("Constructor (7)", "bar", e.Text);
e = new SecurityElement("foo");
AssertEquals("Constructor (8)", "foo", e.Tag);
AssertNull("Constructor (9)", e.Text);
e = new SecurityElement("foo", "&");
AssertEquals("Constructor (10)", "foo", e.Tag);
AssertEquals("Constructor (11)", "&", e.Text);
}
// Test the valid string testing operators.
public void TestSecurityElementValidStrings()
{
Assert("ValidAttrName (1)",
!SecurityElement.IsValidAttributeName(null));
Assert("ValidAttrName (2)",
!SecurityElement.IsValidAttributeName(""));
Assert("ValidAttrName (3)",
!SecurityElement.IsValidAttributeName("a<b"));
Assert("ValidAttrName (4)",
!SecurityElement.IsValidAttributeName("a>b"));
Assert("ValidAttrName (5)",
!SecurityElement.IsValidAttributeName("&"));
Assert("ValidAttrName (6)",
!SecurityElement.IsValidAttributeName(" "));
Assert("ValidAttrName (7)",
SecurityElement.IsValidAttributeName("fooBar"));
Assert("ValidAttrName (8)",
SecurityElement.IsValidAttributeName("123"));
Assert("ValidAttrValue (1)",
!SecurityElement.IsValidAttributeValue(null));
Assert("ValidAttrValue (2)",
SecurityElement.IsValidAttributeValue(""));
Assert("ValidAttrValue (3)",
!SecurityElement.IsValidAttributeValue("a<b"));
Assert("ValidAttrValue (4)",
!SecurityElement.IsValidAttributeValue("a>b"));
Assert("ValidAttrValue (5)",
SecurityElement.IsValidAttributeValue("&"));
Assert("ValidAttrValue (6)",
SecurityElement.IsValidAttributeValue(" "));
Assert("ValidAttrValue (7)",
SecurityElement.IsValidAttributeValue("fooBar"));
Assert("ValidAttrValue (8)",
SecurityElement.IsValidAttributeValue("123"));
Assert("ValidAttrValue (9)",
!SecurityElement.IsValidAttributeValue("\""));
Assert("ValidTag (1)",
!SecurityElement.IsValidTag(null));
Assert("ValidTag (2)",
!SecurityElement.IsValidTag(""));
Assert("ValidTag (3)",
!SecurityElement.IsValidTag("a<b"));
Assert("ValidTag (4)",
!SecurityElement.IsValidTag("a>b"));
Assert("ValidTag (5)",
!SecurityElement.IsValidTag("&"));
Assert("ValidTag (6)",
!SecurityElement.IsValidTag(" "));
Assert("ValidTag (7)",
SecurityElement.IsValidTag("fooBar"));
Assert("ValidTag (8)",
SecurityElement.IsValidTag("123"));
Assert("ValidText (1)",
!SecurityElement.IsValidText(null));
Assert("ValidText (2)",
SecurityElement.IsValidText(""));
Assert("ValidText (3)",
!SecurityElement.IsValidText("a<b"));
Assert("ValidText (4)",
!SecurityElement.IsValidText("a>b"));
Assert("ValidText (5)",
SecurityElement.IsValidText("&"));
Assert("ValidText (6)",
SecurityElement.IsValidText(" "));
Assert("ValidText (7)",
SecurityElement.IsValidText("fooBar"));
Assert("ValidText (8)",
SecurityElement.IsValidText("123"));
Assert("ValidText (9)",
SecurityElement.IsValidText("\""));
}
// Test the "Escape" method.
public void TestSecurityElementEscape()
{
AssertNull("Escape (1)",
SecurityElement.Escape(null));
AssertEquals("Escape (2)", "abc65 *",
SecurityElement.Escape("abc65 *"));
AssertEquals("Escape (3)", "ab<>c&",
SecurityElement.Escape("ab<>c&"));
AssertEquals("Escape (4)", "ab<>c&d",
SecurityElement.Escape("ab<>c&d"));
}
// Test the "Unescape" method. Note: "SecurityElement.Unescape"
// is not public, so we have to do this via the "Text" property.
private String Unescape(String value)
{
SecurityElement e = new SecurityElement("foo",
value);
return e.Text;
}
public void TestSecurityElementUnescape()
{
AssertNull("Unescape (1)", Unescape(null));
AssertEquals("Unescape (2)", "abc65 *",
Unescape("abc65 *"));
AssertEquals("Unescape (3)", "ab<>c&",
Unescape("ab<>c&"));
AssertEquals("Unescape (4)", "ab<>c&d",
Unescape("ab<>c&d"));
}
#endif
}; // class TestSecurityElement
--- NEW FILE ---
/*
* TestSecurityExceptions.cs - Test various exception classes.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using CSUnit;
using System;
using System.Security;
public class TestSecurityExceptions : TestCase
{
// Constructor.
public TestSecurityExceptions(String name)
: base(name)
{
// Nothing to do here.
}
// Set up for the tests.
protected override void Setup()
{
// Nothing to do here.
}
// Clean up after the tests.
protected override void Cleanup()
{
// Nothing to do here.
}
// Test the SecurityException class.
public void TestSecurityException()
{
// Check the three main exception constructors.
ExceptionTester.CheckMain
(typeof(SecurityException),
unchecked((int)0x8013150a));
}
// Test the VerificationException class.
public void TestVerificationException()
{
// Check the three main exception constructors.
ExceptionTester.CheckMain
(typeof(VerificationException),
unchecked((int)0x8013150d));
}
#if !ECMA_COMPAT && (CONFIG_PERMISSIONS || CONFIG_POLICY_OBJECTS)
// Test the XmlSyntaxException class.
public void TestXmlSyntaxException()
{
// Check the three main exception constructors.
ExceptionTester.CheckMain
(typeof(XmlSyntaxException),
unchecked((int)0x80131418));
}
#endif
}; // class TestSecurityExceptions
--- NEW FILE ---
Code review for System.Security
===============================
Last updated: 23 July 2003
Classes that need tests
-----------------------
CodeAccessPermission
MiniXml
NamedPermissionSet
PermissionSet
SecurityElement
SecurityException (done)
SecurityManager
VerificationException (done)
XmlSyntaxException (done)
Classes that were validated using manual inspection and csdocvalil
------------------------------------------------------------------
AllowPartiallyTrustedCallersAttribute
IEvidenceFactory
IPermission
ISecurityEncodable
ISecurityPolicyEncodable
IStackWalk
PolicyLevelType
SecurityZone
SuppressUnmanagedCodeSecurityAttribute
UnverifiableCodeAttribute
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Security Makefile, NONE, 1.1 SuiteSecurity.cs, NONE, 1.1 TestSecurityElement.cs, NONE, 1.1 TestSecurityExceptions.cs, NONE, 1.1 code-review.txt, NONE, 1.1,
Rhys Weatherley <address@hidden> <=