2010-10-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added tests to HttpRequestTest about trailing slash of cookie
	path.
	* test/HttpRequestTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-10-09 14:52:41 +00:00
parent b8f8a14937
commit f816434d06
2 changed files with 47 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2010-10-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added tests to HttpRequestTest about trailing slash of cookie
path.
* test/HttpRequestTest.cc
2010-10-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Don't append slash in CookieStorage::criteriaFind(). Append file

View File

@ -381,21 +381,19 @@ void HttpRequestTest::testCreateRequest_with_cookie()
(new PiecedSegment(1024*1024, p));
SharedHandle<FileEntry> fileEntry(new FileEntry("file", 1024*1024*10, 0));
Cookie cookie1(createCookie("name1", "value1", "localhost", true,
"/archives", false));
Cookie cookie2(createCookie("name2", "value2", "localhost", true,
"/archives/download", false));
Cookie cookie3(createCookie("name3", "value3", "aria2.org", false,
"/archives/download", false));
Cookie cookie4(createCookie("name4", "value4", "aria2.org", false,
"/archives/", true));
time_t now = time(0);
Cookie cookies[] = {
createCookie("name1", "value1", "localhost", true, "/archives", false),
createCookie("name2", "value2", "localhost", true,
"/archives/download", false),
createCookie("name3", "value3", "aria2.org", false,
"/archives/download", false),
createCookie("name4", "value4", "aria2.org", false, "/archives/", true),
createCookie("name5", "value5", "example.org", false, "/", false)
};
SharedHandle<CookieStorage> st(new CookieStorage());
CPPUNIT_ASSERT(st->store(cookie1, now));
CPPUNIT_ASSERT(st->store(cookie2, now));
CPPUNIT_ASSERT(st->store(cookie3, now));
CPPUNIT_ASSERT(st->store(cookie4, now));
for(size_t i = 0; i < A2_ARRAY_LEN(cookies); ++i) {
CPPUNIT_ASSERT(st->store(cookies[i], 0));
}
HttpRequest httpRequest;
@ -460,7 +458,35 @@ void HttpRequestTest::testCreateRequest_with_cookie()
"\r\n";
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
// The path of cookie4 ends with '/'
request->setUri("https://www.aria2.org/archives/aria2-1.0.0.tar.bz2");
expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
"User-Agent: aria2\r\n"
"Accept: */*\r\n"
"Host: www.aria2.org\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n"
"Connection: close\r\n"
"Cookie: name4=value4;\r\n"
"\r\n";
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
request->setUri("http://example.org/aria2-1.0.0.tar.bz2");
expectedText = "GET /aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
"User-Agent: aria2\r\n"
"Accept: */*\r\n"
"Host: example.org\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n"
"Connection: close\r\n"
"Cookie: name5=value5;\r\n"
"\r\n";
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
}
void HttpRequestTest::testCreateRequest_query()