summaryrefslogtreecommitdiff
path: root/test/AuthConfigFactoryTest.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-07-27 23:28:31 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-07-27 23:28:31 +0900
commit4ea28cb8377bc7b4654e6ae0216db6a7425d12c9 (patch)
tree27c63eb57a315ab5ab7596ac46da2ac840d9ef19 /test/AuthConfigFactoryTest.cc
parent02292feaba560e379acec7f7477a0c50c679d0dc (diff)
Don't send basic auth header to service operated on differenct port.
When --http-auth-challenge=true, aria2 only sends basic auth header when requested. Old implementation sends basic auth header to service operated in different port in successive request. This change avoid this bug.
Diffstat (limited to 'test/AuthConfigFactoryTest.cc')
-rw-r--r--test/AuthConfigFactoryTest.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/test/AuthConfigFactoryTest.cc b/test/AuthConfigFactoryTest.cc
index 0de3238d..ed698f6b 100644
--- a/test/AuthConfigFactoryTest.cc
+++ b/test/AuthConfigFactoryTest.cc
@@ -57,7 +57,7 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http()
// not activated
CPPUNIT_ASSERT(!factory.createAuthConfig(req, &option));
- CPPUNIT_ASSERT(factory.activateBasicCred("localhost", "/", &option));
+ CPPUNIT_ASSERT(factory.activateBasicCred("localhost", 80, "/", &option));
CPPUNIT_ASSERT_EQUAL(std::string("localhostuser:localhostpass"),
factory.createAuthConfig(req, &option)->getAuthText());
@@ -65,7 +65,7 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http()
// See default token in netrc is ignored.
req->setUri("http://mirror/");
- CPPUNIT_ASSERT(!factory.activateBasicCred("mirror", "/", &option));
+ CPPUNIT_ASSERT(!factory.activateBasicCred("mirror", 80, "/", &option));
CPPUNIT_ASSERT(!factory.createAuthConfig(req, &option));
@@ -75,7 +75,7 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http()
CPPUNIT_ASSERT(!factory.createAuthConfig(req, &option));
- CPPUNIT_ASSERT(factory.activateBasicCred("mirror", "/", &option));
+ CPPUNIT_ASSERT(factory.activateBasicCred("mirror", 80, "/", &option));
CPPUNIT_ASSERT_EQUAL(std::string("userDefinedUser:userDefinedPassword"),
factory.createAuthConfig(req, &option)->getAuthText());
@@ -204,20 +204,25 @@ void AuthConfigFactoryTest::testUpdateBasicCred()
AuthConfigFactory factory;
factory.updateBasicCred
- (AuthConfigFactory::BasicCred("myname", "mypass", "localhost", "/", true));
+ (AuthConfigFactory::BasicCred("myname", "mypass", "localhost", 80, "/", true));
factory.updateBasicCred
- (AuthConfigFactory::BasicCred("price","j38jdc","localhost","/download", true));
+ (AuthConfigFactory::BasicCred("price", "j38jdc", "localhost", 80, "/download", true));
factory.updateBasicCred
- (AuthConfigFactory::BasicCred("alice","ium8","localhost","/documents", true));
+ (AuthConfigFactory::BasicCred("soap", "planB", "localhost", 80, "/download/beta", true));
factory.updateBasicCred
- (AuthConfigFactory::BasicCred("jack", "jackx","mirror", "/doc", true));
+ (AuthConfigFactory::BasicCred("alice", "ium8", "localhost", 80, "/documents", true));
+ factory.updateBasicCred
+ (AuthConfigFactory::BasicCred("jack", "jackx", "mirror", 80, "/doc", true));
SharedHandle<Request> req(new Request());
req->setUri("http://localhost/download/v2.6/Changelog");
-
CPPUNIT_ASSERT_EQUAL(std::string("price:j38jdc"),
factory.createAuthConfig(req, &option)->getAuthText());
+ req->setUri("http://localhost/download/beta/v2.7/Changelog");
+ CPPUNIT_ASSERT_EQUAL(std::string("soap:planB"),
+ factory.createAuthConfig(req, &option)->getAuthText());
+
req->setUri("http://localhost/documents/reference.html");
CPPUNIT_ASSERT_EQUAL(std::string("alice:ium8"),
factory.createAuthConfig(req, &option)->getAuthText());
@@ -230,6 +235,9 @@ void AuthConfigFactoryTest::testUpdateBasicCred()
CPPUNIT_ASSERT_EQUAL(std::string("myname:mypass"),
factory.createAuthConfig(req, &option)->getAuthText());
+ req->setUri("http://localhost:8080/doc/readme.txt");
+ CPPUNIT_ASSERT(!factory.createAuthConfig(req, &option));
+
req->setUri("http://local/");
CPPUNIT_ASSERT(!factory.createAuthConfig(req, &option));