diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-09-25 14:37:28 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-09-25 14:37:28 +0000 |
| commit | 92d702fa5349c722c6b59256bafe552c8b5cd8a1 (patch) | |
| tree | 43dd76d729ceaf937351f15a428680f3a290f5a5 /test/AuthConfigFactoryTest.cc | |
| parent | 6bc233f414b74bf3acf4abf5d5655c236e78ae41 (diff) | |
2008-09-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use netrc for HTTP.
Now FTP user/password is sent in Authorization header when
--ftp-via-http-proxy=get is given.
* src/AuthConfigFactory.cc
* src/HttpRequest.cc
* src/HttpRequest.h
* src/NetrcAuthResolver.cc
* src/NetrcAuthResolver.h
* src/OptionHandlerFactory.cc
* src/option_processing.cc
* src/prefs.cc
* src/prefs.h
* test/AuthConfigFactoryTest.cc
* test/HttpRequestTest.cc
* test/NetrcAuthResolverTest.cc
Diffstat (limited to 'test/AuthConfigFactoryTest.cc')
| -rw-r--r-- | test/AuthConfigFactoryTest.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/test/AuthConfigFactoryTest.cc b/test/AuthConfigFactoryTest.cc index 8a9fcd44..67eaac18 100644 --- a/test/AuthConfigFactoryTest.cc +++ b/test/AuthConfigFactoryTest.cc @@ -39,14 +39,26 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http() CPPUNIT_ASSERT_EQUAL(std::string(":"), factory.createAuthConfig(req)->getAuthText()); - // with Netrc: disabled by default + // with Netrc SharedHandle<Netrc> netrc(new Netrc()); netrc->addAuthenticator + (SharedHandle<Authenticator>(new Authenticator("localhost", + "localhostuser", + "localhostpass", + "localhostacct"))); + netrc->addAuthenticator (SharedHandle<Authenticator>(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"))); factory.setNetrc(netrc); - CPPUNIT_ASSERT_EQUAL(std::string(":"), + + CPPUNIT_ASSERT_EQUAL(std::string("localhostuser:localhostpass"), factory.createAuthConfig(req)->getAuthText()); + // See default token in netrc is ignored. + SharedHandle<Request> mirrorReq(new Request()); + req->setUrl("http://mirror/"); + CPPUNIT_ASSERT_EQUAL(std::string(":"), + factory.createAuthConfig(mirrorReq)->getAuthText()); + // with Netrc + user defined option.put(PREF_HTTP_USER, "userDefinedUser"); option.put(PREF_HTTP_PASSWD, "userDefinedPassword"); @@ -56,10 +68,7 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http() // username and password in URI: disabled by default. req->setUrl("http://aria2user:aria2password@localhost/download/aria2-1.0.0.tar.bz2"); CPPUNIT_ASSERT_EQUAL(std::string("userDefinedUser:userDefinedPassword"), - factory.createAuthConfig(req)->getAuthText()); - -// CPPUNIT_ASSERT_EQUAL(std::string("aria2user:aria2password"), -// factory.createAuthConfig(req)->getAuthText()); + factory.createAuthConfig(req)->getAuthText()); } void AuthConfigFactoryTest::testCreateAuthConfigForHttpProxy() |
