|
@@ -23,15 +23,14 @@ class RequestTest:public CppUnit::TestFixture {
|
|
|
CPPUNIT_TEST(testSetUrl14);
|
|
|
CPPUNIT_TEST(testSetUrl15);
|
|
|
CPPUNIT_TEST(testSetUrl16);
|
|
|
+ CPPUNIT_TEST(testSetUrl17);
|
|
|
CPPUNIT_TEST(testSetUrl_username);
|
|
|
CPPUNIT_TEST(testSetUrl_usernamePassword);
|
|
|
CPPUNIT_TEST(testSetUrl_zeroUsername);
|
|
|
CPPUNIT_TEST(testRedirectUrl);
|
|
|
CPPUNIT_TEST(testRedirectUrl2);
|
|
|
CPPUNIT_TEST(testResetUrl);
|
|
|
- CPPUNIT_TEST(testSafeChar);
|
|
|
CPPUNIT_TEST(testInnerLink);
|
|
|
- CPPUNIT_TEST(testMetalink);
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
public:
|
|
@@ -51,15 +50,14 @@ public:
|
|
|
void testSetUrl14();
|
|
|
void testSetUrl15();
|
|
|
void testSetUrl16();
|
|
|
+ void testSetUrl17();
|
|
|
void testSetUrl_username();
|
|
|
void testSetUrl_usernamePassword();
|
|
|
void testSetUrl_zeroUsername();
|
|
|
void testRedirectUrl();
|
|
|
void testRedirectUrl2();
|
|
|
void testResetUrl();
|
|
|
- void testSafeChar();
|
|
|
void testInnerLink();
|
|
|
- void testMetalink();
|
|
|
};
|
|
|
|
|
|
|
|
@@ -179,7 +177,7 @@ void RequestTest::testSetUrl10() {
|
|
|
void RequestTest::testSetUrl11() {
|
|
|
Request req;
|
|
|
bool v = req.setUrl("http://host?query/");
|
|
|
-
|
|
|
+
|
|
|
CPPUNIT_ASSERT(v);
|
|
|
CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol());
|
|
|
CPPUNIT_ASSERT_EQUAL(string("host"), req.getHost());
|
|
@@ -245,6 +243,17 @@ void RequestTest::testSetUrl16()
|
|
|
CPPUNIT_ASSERT_EQUAL(string("file"), req.getFile());
|
|
|
}
|
|
|
|
|
|
+void RequestTest::testSetUrl17()
|
|
|
+{
|
|
|
+ Request req;
|
|
|
+ bool v = req.setUrl("http://host:80/file<with%2 %20space/file with space;param?a=/?");
|
|
|
+ CPPUNIT_ASSERT(v);
|
|
|
+ CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol());
|
|
|
+ CPPUNIT_ASSERT_EQUAL(string("host"), req.getHost());
|
|
|
+ CPPUNIT_ASSERT_EQUAL(string("/file%3cwith%252%20%20space"), req.getDir());
|
|
|
+ CPPUNIT_ASSERT_EQUAL(string("file%20with%20space;param?a=/?"), req.getFile());
|
|
|
+}
|
|
|
+
|
|
|
void RequestTest::testRedirectUrl() {
|
|
|
Request req;
|
|
|
req.setKeepAlive(true);
|
|
@@ -310,12 +319,6 @@ void RequestTest::testResetUrl() {
|
|
|
CPPUNIT_ASSERT_EQUAL(string("index.html"), req.getFile());
|
|
|
}
|
|
|
|
|
|
-void RequestTest::testSafeChar() {
|
|
|
- Request req;
|
|
|
- bool v = req.setUrl("http://aria.rednoah.com/|<>");
|
|
|
- CPPUNIT_ASSERT(!v);
|
|
|
-}
|
|
|
-
|
|
|
void RequestTest::testInnerLink() {
|
|
|
Request req;
|
|
|
bool v = req.setUrl("http://aria.rednoah.com/index.html#download");
|
|
@@ -323,24 +326,6 @@ void RequestTest::testInnerLink() {
|
|
|
CPPUNIT_ASSERT_EQUAL(string("index.html"), req.getFile());
|
|
|
}
|
|
|
|
|
|
-void RequestTest::testMetalink() {
|
|
|
- Request req;
|
|
|
- bool v = req.setUrl("http://aria.rednoah.com/download/aria.tar.bz2#!metalink3!http://aria2.sourceforge.net/download/aria.metalink");
|
|
|
- CPPUNIT_ASSERT(v);
|
|
|
-#ifdef ENABLE_METALINK
|
|
|
- CPPUNIT_ASSERT_EQUAL(string("aria2.sourceforge.net"), req.getHost());
|
|
|
- CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
|
|
- CPPUNIT_ASSERT_EQUAL(string("aria.metalink"), req.getFile());
|
|
|
-
|
|
|
- bool v2 = req.setUrl("http://aria.rednoah.com/download/aria.tar.bz2#!metalink3!");
|
|
|
- CPPUNIT_ASSERT(!v2);
|
|
|
-#else
|
|
|
- CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost());
|
|
|
- CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
|
|
- CPPUNIT_ASSERT_EQUAL(string("aria.tar.bz2"), req.getFile());
|
|
|
-#endif // ENABLE_METALINK
|
|
|
-}
|
|
|
-
|
|
|
void RequestTest::testSetUrl_zeroUsername()
|
|
|
{
|
|
|
Request req;
|