Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2009-07-23 03:29:10 +0400
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2009-07-23 03:29:10 +0400
commit874ad36781ad7f0950d3c2a051beb478ee10b148 (patch)
tree08000c46540037a469e334d55d977f6c5f6b5d74 /mcs/class/System/Test
parentc9bf6e9a786ee8c32c9b860ad4ce5fcc9aa8389f (diff)
Implement the 2.0 IsRestricted and add tests
svn path=/trunk/mcs/; revision=138472
Diffstat (limited to 'mcs/class/System/Test')
-rw-r--r--mcs/class/System/Test/System.Net/ChangeLog4
-rw-r--r--mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs90
2 files changed, 94 insertions, 0 deletions
diff --git a/mcs/class/System/Test/System.Net/ChangeLog b/mcs/class/System/Test/System.Net/ChangeLog
index 2015be81b1b..b636565ed11 100644
--- a/mcs/class/System/Test/System.Net/ChangeLog
+++ b/mcs/class/System/Test/System.Net/ChangeLog
@@ -1,3 +1,7 @@
+2009-07-22 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+ * WebHeaderCollectionTest.cs: test for 2.0 IsRestricted().
+
2009-07-09 Gonzalo Paniagua Javier <gonzalo@novell.com>
* HttpWebRequestTest.cs: use different ports for different tests since
diff --git a/mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs b/mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs
index 384ba0eaf3e..a840997db29 100644
--- a/mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs
+++ b/mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs
@@ -5,6 +5,7 @@
// Lawrence Pit (loz@cable.a2000.nl)
// Martin Willemoes Hansen (mwh@sysrq.dk)
// Gert Driesen (drieseng@users.sourceforge.net)
+// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// (C) 2003 Martin Willemoes Hansen
//
@@ -375,5 +376,94 @@ namespace MonoTests.System.Net
0x74, 0x74, 0x61, 0x63, 0x68, 0x0b
#endif
};
+
+#if NET_2_0
+ static string [] request_headers = new string [] {
+ "Accept", "Accept-Charset", "Accept-Encoding", "Accept-Language", "Accept-Ranges", "Authorization",
+ "Cache-Control", "Connection", "Cookie", "Content-Length", "Content-Type", "Date",
+ "Expect", "From", "Host", "If-Match", "If-Modified-Since", "If-None-Match",
+ "If-Range", "If-Unmodified-Since", "Max-Forwards", "Pragma", "Proxy-Authorization",
+ "Range", "Referer", "TE", "Upgrade", "User-Agent", "Via", "Warn" };
+
+ static string [] response_headers = new string [] {
+ "Accept-Ranges", "Age", "Allow", "Cache-Control", "Content-Encoding", "Content-Language",
+ "Content-Length", "Content-Location", "Content-Disposition", "Content-MD5", "Content-Range",
+ "Content-Type", "Date", "ETag", "Expires", "Last-Modified", "Location", "Pragma",
+ "Proxy-Authenticate", "Retry-After", "Server", "Set-Cookie", "Trailer",
+ "Transfer-Encoding", "Vary", "Via", "Warn", "WWW-Authenticate" };
+
+ static string [] restricted_request_request = new string [] {
+ "Accept", "Connection", "Content-Length", "Content-Type", "Date",
+ "Expect", "Host", "If-Modified-Since", "Range", "Referer",
+ "User-Agent" };
+ static string [] restricted_response_request = new string [] {
+ "Content-Length", "Content-Type", "Date", "Transfer-Encoding" };
+
+ static string [] restricted_request_response = new string [] {
+ "Content-Length" };
+ static string [] restricted_response_response = new string [] {
+ "Content-Length", "Transfer-Encoding", "WWW-Authenticate" };
+
+ [Test]
+ public void IsRestricted_2_0_RequestRequest ()
+ {
+ int count = 0;
+ foreach (string str in request_headers) {
+ if (WebHeaderCollection.IsRestricted (str, false)) {
+ Assert.IsTrue (Array.IndexOf (restricted_request_request, str) != -1, "restricted " + str);
+ count++;
+ } else {
+ Assert.IsTrue (Array.IndexOf (restricted_request_request, str) == -1, str);
+ }
+ }
+ Assert.IsTrue (count == restricted_request_request.Length, "req-req length");
+ }
+
+ [Test]
+ public void IsRestricted_2_0_ResponseRequest ()
+ {
+ int count = 0;
+ foreach (string str in response_headers) {
+ if (WebHeaderCollection.IsRestricted (str, false)) {
+ Assert.IsTrue (Array.IndexOf (restricted_response_request, str) != -1, "restricted " + str);
+ count++;
+ } else {
+ Assert.IsTrue (Array.IndexOf (restricted_response_request, str) == -1, str);
+ }
+ }
+ Assert.IsTrue (count == restricted_response_request.Length, "length");
+ }
+
+ [Test]
+ public void IsRestricted_2_0_RequestResponse ()
+ {
+ int count = 0;
+ foreach (string str in request_headers) {
+ if (WebHeaderCollection.IsRestricted (str, true)) {
+ Assert.IsTrue (Array.IndexOf (restricted_request_response, str) != -1, "restricted " + str);
+ count++;
+ } else {
+ Assert.IsTrue (Array.IndexOf (restricted_request_response, str) == -1, str);
+ }
+ }
+ Assert.IsTrue (count == restricted_request_response.Length, "length");
+ }
+
+ [Test]
+ public void IsRestricted_2_0_ResponseResponse ()
+ {
+ int count = 0;
+ foreach (string str in response_headers) {
+ if (WebHeaderCollection.IsRestricted (str, true)) {
+ Assert.IsTrue (Array.IndexOf (restricted_response_response, str) != -1, "restricted " + str);
+ count++;
+ } else {
+ Assert.IsTrue (Array.IndexOf (restricted_response_response, str) == -1, str);
+ }
+ }
+ Assert.IsTrue (count == restricted_response_response.Length, "length");
+ }
+#endif
}
}
+