mirror of https://github.com/aria2/aria2
2007-10-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added ftp://USER:PASSWD@Servername automatic parsing. * src/Request.{h, cc}: Removed AuthResolvers. Added _username and _password. Recognize username and password in URI. * src/main.cc: Use AuthConfigFactory instead of RequestFactory. * src/RequestGroup.cc: Use AuthConfigFactory instead of RequestFactory. * src/RequestFactory.{h, cc}: Removed. * src/AuthConfigFactory.{h, cc}: New class. * src/FtpConnection.cc: Use AuthConfigFactory. * src/HttpRequest.cc: Use AuthConfigFactory. * test/HttpRequestTest.cc: Updated. * test/RequestTest.cc: Updated. * test/AuthConfigFactoryTest.cc: New class. * test/RequestFactoryTest.cc: Removed.pull/1/head
parent
f3f8cc593c
commit
6b7df851d3
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2007-10-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Added ftp://USER:PASSWD@Servername automatic parsing.
|
||||
* src/Request.{h, cc}: Removed AuthResolvers. Added _username and
|
||||
_password. Recognize username and password in URI.
|
||||
* src/main.cc: Use AuthConfigFactory instead of RequestFactory.
|
||||
* src/RequestGroup.cc: Use AuthConfigFactory instead of RequestFactory.
|
||||
* src/RequestFactory.{h, cc}: Removed.
|
||||
* src/AuthConfigFactory.{h, cc}: New class.
|
||||
* src/FtpConnection.cc: Use AuthConfigFactory.
|
||||
* src/HttpRequest.cc: Use AuthConfigFactory.
|
||||
* test/HttpRequestTest.cc: Updated.
|
||||
* test/RequestTest.cc: Updated.
|
||||
* test/AuthConfigFactoryTest.cc: New class.
|
||||
* test/RequestFactoryTest.cc: Removed.
|
||||
|
||||
2007-10-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Use RequestGroup::allDownloadFinished() to decide whether the control
|
||||
|
|
1
TODO
1
TODO
|
@ -52,7 +52,6 @@
|
|||
* Reimplement ChecksumCommand(validation using 1 checksum for 1 file)
|
||||
* Implement duplicate download checking in Bt
|
||||
* Add PeerListenCommand to DownloadEngine only when it is really necessary.
|
||||
* ftp://USER:PASSWD@Servername automatic parsing
|
||||
* improve --metalink-location field
|
||||
* Use content-type for PostDownloadHandler
|
||||
* Torrent information
|
||||
|
|
|
@ -32,24 +32,41 @@
|
|||
* files in the program, then also delete it here.
|
||||
*/
|
||||
/* copyright --> */
|
||||
#include "RequestFactory.h"
|
||||
#include "prefs.h"
|
||||
#include "AbstractAuthResolver.h"
|
||||
#include "NetrcAuthResolver.h"
|
||||
#include "AuthConfigFactory.h"
|
||||
#include "Option.h"
|
||||
#include "AuthConfig.h"
|
||||
#include "Netrc.h"
|
||||
#include "DefaultAuthResolver.h"
|
||||
#include "NetrcAuthResolver.h"
|
||||
#include "prefs.h"
|
||||
#include "Request.h"
|
||||
|
||||
RequestHandle RequestFactory::createRequest()
|
||||
AuthConfigFactory::AuthConfigFactory(const Option* option):
|
||||
_option(option), _netrc(0) {}
|
||||
|
||||
AuthConfigFactory::~AuthConfigFactory() {}
|
||||
|
||||
AuthConfigHandle AuthConfigFactory::createAuthConfig(const RequestHandle& request) const
|
||||
{
|
||||
RequestHandle request = new Request();
|
||||
request->setMethod(_method);
|
||||
request->setReferer(_referer);
|
||||
request->setHttpAuthResolver(createHttpAuthResolver());
|
||||
request->setHttpProxyAuthResolver(createHttpProxyAuthResolver());
|
||||
request->setFtpAuthResolver(createFtpAuthResolver());
|
||||
return request;
|
||||
if(request->getProtocol() == "http" || request->getProtocol() == "https") {
|
||||
return createHttpAuthResolver()->resolveAuthConfig(request->getHost());
|
||||
} else if(request->getProtocol() == "ftp") {
|
||||
if(!request->getUsername().empty()) {
|
||||
return createAuthConfig(request->getUsername(), request->getPassword());
|
||||
} else {
|
||||
return createFtpAuthResolver()->resolveAuthConfig(request->getHost());
|
||||
}
|
||||
} else {
|
||||
return new AuthConfig();
|
||||
}
|
||||
}
|
||||
|
||||
AuthConfigHandle RequestFactory::createAuthConfig(const string& user, const string& password) const
|
||||
AuthConfigHandle AuthConfigFactory::createAuthConfigForHttpProxy(const RequestHandle& request) const
|
||||
{
|
||||
return createHttpProxyAuthResolver()->resolveAuthConfig(request->getHost());
|
||||
}
|
||||
|
||||
AuthConfigHandle AuthConfigFactory::createAuthConfig(const string& user, const string& password) const
|
||||
{
|
||||
if(user.length() > 0) {
|
||||
return new AuthConfig(user, password);
|
||||
|
@ -58,7 +75,7 @@ AuthConfigHandle RequestFactory::createAuthConfig(const string& user, const stri
|
|||
}
|
||||
}
|
||||
|
||||
AuthResolverHandle RequestFactory::createHttpAuthResolver()
|
||||
AuthResolverHandle AuthConfigFactory::createHttpAuthResolver() const
|
||||
{
|
||||
AbstractAuthResolverHandle resolver = 0;
|
||||
if(true || _option->getAsBool(PREF_NO_NETRC)) {
|
||||
|
@ -72,7 +89,7 @@ AuthResolverHandle RequestFactory::createHttpAuthResolver()
|
|||
return resolver;
|
||||
}
|
||||
|
||||
AuthResolverHandle RequestFactory::createFtpAuthResolver()
|
||||
AuthResolverHandle AuthConfigFactory::createFtpAuthResolver() const
|
||||
{
|
||||
AbstractAuthResolverHandle resolver = 0;
|
||||
if(_option->getAsBool(PREF_NO_NETRC)) {
|
||||
|
@ -87,7 +104,7 @@ AuthResolverHandle RequestFactory::createFtpAuthResolver()
|
|||
return resolver;
|
||||
}
|
||||
|
||||
AuthResolverHandle RequestFactory::createHttpProxyAuthResolver()
|
||||
AuthResolverHandle AuthConfigFactory::createHttpProxyAuthResolver() const
|
||||
{
|
||||
AbstractAuthResolverHandle resolver = 0;
|
||||
if(true || _option->getAsBool(PREF_NO_NETRC)) {
|
||||
|
@ -100,3 +117,8 @@ AuthResolverHandle RequestFactory::createHttpProxyAuthResolver()
|
|||
resolver->setUserDefinedAuthConfig(createAuthConfig(_option->get(PREF_HTTP_PROXY_USER), _option->get(PREF_HTTP_PROXY_PASSWD)));
|
||||
return resolver;
|
||||
}
|
||||
|
||||
void AuthConfigFactory::setNetrc(const NetrcHandle& netrc)
|
||||
{
|
||||
_netrc = netrc;
|
||||
}
|
|
@ -32,59 +32,49 @@
|
|||
* files in the program, then also delete it here.
|
||||
*/
|
||||
/* copyright --> */
|
||||
#ifndef _D_REQUEST_FACTORY_H_
|
||||
#define _D_REQUEST_FACTORY_H_
|
||||
#ifndef _D_AUTH_CONFIG_FACTORY_H_
|
||||
#define _D_AUTH_CONFIG_FACTORY_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "Request.h"
|
||||
#include "Option.h"
|
||||
#include "Netrc.h"
|
||||
|
||||
class RequestFactory {
|
||||
class Option;
|
||||
class Netrc;
|
||||
extern typedef SharedHandle<Netrc> NetrcHandle;
|
||||
class AuthConfig;
|
||||
extern typedef SharedHandle<AuthConfig> AuthConfigHandle;
|
||||
class Request;
|
||||
extern typedef SharedHandle<Request> RequestHandle;
|
||||
class AuthResolver;
|
||||
extern typedef SharedHandle<AuthResolver> AuthResolverHandle;
|
||||
|
||||
class AuthConfigFactory {
|
||||
private:
|
||||
const Option* _option;
|
||||
NetrcHandle _netrc;
|
||||
string _method;
|
||||
string _referer;
|
||||
|
||||
NetrcHandle _netrc;
|
||||
|
||||
AuthConfigHandle createAuthConfig(const string& user, const string& password) const;
|
||||
|
||||
AuthResolverHandle createHttpAuthResolver() const;
|
||||
|
||||
AuthResolverHandle createHttpProxyAuthResolver() const;
|
||||
|
||||
AuthResolverHandle createFtpAuthResolver() const;
|
||||
|
||||
public:
|
||||
RequestFactory():_option(0),
|
||||
_netrc(0),
|
||||
_method(Request::METHOD_GET)
|
||||
{}
|
||||
|
||||
AuthConfigFactory(const Option* option);
|
||||
|
||||
RequestHandle createRequest();
|
||||
~AuthConfigFactory();
|
||||
|
||||
AuthResolverHandle createHttpAuthResolver();
|
||||
AuthConfigHandle createAuthConfig(const RequestHandle& request) const;
|
||||
|
||||
AuthResolverHandle createHttpProxyAuthResolver();
|
||||
AuthConfigHandle createAuthConfigForHttpProxy(const RequestHandle& request) const;
|
||||
|
||||
AuthResolverHandle createFtpAuthResolver();
|
||||
|
||||
void setOption(const Option* option)
|
||||
{
|
||||
_option = option;
|
||||
}
|
||||
|
||||
void setNetrc(const NetrcHandle& netrc)
|
||||
{
|
||||
_netrc = netrc;
|
||||
}
|
||||
|
||||
void setMethod(const string& method)
|
||||
{
|
||||
_method = method;
|
||||
}
|
||||
|
||||
void setReferer(const string& referer)
|
||||
{
|
||||
_referer = referer;
|
||||
}
|
||||
void setNetrc(const NetrcHandle& netrc);
|
||||
};
|
||||
|
||||
typedef SharedHandle<RequestFactory> RequestFactoryHandle;
|
||||
typedef SingletonHolder<RequestFactoryHandle> RequestFactorySingletonHolder;
|
||||
typedef SharedHandle<AuthConfigFactory> AuthConfigFactoryHandle;
|
||||
typedef SingletonHolder<AuthConfigFactoryHandle> AuthConfigFactorySingleton;
|
||||
|
||||
#endif // _D_REQUEST_FACTORY_H_
|
||||
#endif // _D_AUTH_CONFIG_FACTORY_H_
|
|
@ -37,6 +37,8 @@
|
|||
#include "message.h"
|
||||
#include "prefs.h"
|
||||
#include "LogFactory.h"
|
||||
#include "AuthConfigFactory.h"
|
||||
#include "AuthConfig.h"
|
||||
|
||||
FtpConnection::FtpConnection(int32_t cuid, const SocketHandle& socket,
|
||||
const RequestHandle req, const Option* op)
|
||||
|
@ -49,7 +51,7 @@ FtpConnection::~FtpConnection() {}
|
|||
void FtpConnection::sendUser() const
|
||||
throw(DlRetryEx*)
|
||||
{
|
||||
string request = "USER "+req->resolveFtpAuthConfig()->getUser()+"\r\n";
|
||||
string request = "USER "+AuthConfigFactorySingleton::instance()->createAuthConfig(req)->getUser()+"\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
|
||||
socket->writeData(request);
|
||||
}
|
||||
|
@ -57,7 +59,7 @@ void FtpConnection::sendUser() const
|
|||
void FtpConnection::sendPass() const
|
||||
throw(DlRetryEx*)
|
||||
{
|
||||
string request = "PASS "+req->resolveFtpAuthConfig()->getPassword()+"\r\n";
|
||||
string request = "PASS "+AuthConfigFactorySingleton::instance()->createAuthConfig(req)->getPassword()+"\r\n";
|
||||
logger->info(MSG_SENDING_REQUEST, cuid, "PASS ********");
|
||||
socket->writeData(request);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "Util.h"
|
||||
#include "Base64.h"
|
||||
#include "prefs.h"
|
||||
#include "AuthConfigFactory.h"
|
||||
#include "AuthConfig.h"
|
||||
|
||||
RangeHandle HttpRequest::getRange() const
|
||||
{
|
||||
|
@ -112,7 +114,7 @@ string HttpRequest::createRequest() const
|
|||
}
|
||||
if(authEnabled) {
|
||||
requestLine += "Authorization: Basic "+
|
||||
Base64::encode(request->resolveHttpAuthConfig()->getAuthText())+"\r\n";
|
||||
Base64::encode(AuthConfigFactorySingleton::instance()->createAuthConfig(request)->getAuthText())+"\r\n";
|
||||
}
|
||||
if(getPreviousURI().size()) {
|
||||
requestLine += "Referer: "+getPreviousURI()+"\r\n";
|
||||
|
@ -154,7 +156,7 @@ string HttpRequest::createProxyRequest() const
|
|||
|
||||
string HttpRequest::getProxyAuthString() const {
|
||||
return "Proxy-Authorization: Basic "+
|
||||
Base64::encode(request->resolveHttpProxyAuthConfig()->getAuthText())+"\r\n";
|
||||
Base64::encode(AuthConfigFactorySingleton::instance()->createAuthConfigForHttpProxy(request)->getAuthText())+"\r\n";
|
||||
}
|
||||
|
||||
void HttpRequest::configure(const Option* option)
|
||||
|
|
|
@ -74,7 +74,7 @@ SRCS = Socket.h\
|
|||
AbstractAuthResolver.h\
|
||||
DefaultAuthResolver.cc DefaultAuthResolver.h\
|
||||
NetrcAuthResolver.cc NetrcAuthResolver.h\
|
||||
RequestFactory.cc RequestFactory.h\
|
||||
AuthConfigFactory.cc AuthConfigFactory.h\
|
||||
OptionParser.cc OptionParser.h\
|
||||
OptionHandlerFactory.cc OptionHandlerFactory.h\
|
||||
NameResolver.cc NameResolver.h\
|
||||
|
|
|
@ -233,8 +233,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
|||
AbstractProxyResponseCommand.h Netrc.cc Netrc.h AuthConfig.cc \
|
||||
AuthConfig.h AuthResolver.h AbstractAuthResolver.h \
|
||||
DefaultAuthResolver.cc DefaultAuthResolver.h \
|
||||
NetrcAuthResolver.cc NetrcAuthResolver.h RequestFactory.cc \
|
||||
RequestFactory.h OptionParser.cc OptionParser.h \
|
||||
NetrcAuthResolver.cc NetrcAuthResolver.h AuthConfigFactory.cc \
|
||||
AuthConfigFactory.h OptionParser.cc OptionParser.h \
|
||||
OptionHandlerFactory.cc OptionHandlerFactory.h NameResolver.cc \
|
||||
NameResolver.h RequestGroup.cc RequestGroup.h \
|
||||
RequestGroupAware.cc RequestGroupAware.h RequestGroupMan.cc \
|
||||
|
@ -462,7 +462,7 @@ am__objects_12 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
|
|||
HttpRequest.$(OBJEXT) AbstractProxyRequestCommand.$(OBJEXT) \
|
||||
AbstractProxyResponseCommand.$(OBJEXT) Netrc.$(OBJEXT) \
|
||||
AuthConfig.$(OBJEXT) DefaultAuthResolver.$(OBJEXT) \
|
||||
NetrcAuthResolver.$(OBJEXT) RequestFactory.$(OBJEXT) \
|
||||
NetrcAuthResolver.$(OBJEXT) AuthConfigFactory.$(OBJEXT) \
|
||||
OptionParser.$(OBJEXT) OptionHandlerFactory.$(OBJEXT) \
|
||||
NameResolver.$(OBJEXT) RequestGroup.$(OBJEXT) \
|
||||
RequestGroupAware.$(OBJEXT) RequestGroupMan.$(OBJEXT) \
|
||||
|
@ -723,8 +723,8 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
|
|||
AbstractProxyResponseCommand.h Netrc.cc Netrc.h AuthConfig.cc \
|
||||
AuthConfig.h AuthResolver.h AbstractAuthResolver.h \
|
||||
DefaultAuthResolver.cc DefaultAuthResolver.h \
|
||||
NetrcAuthResolver.cc NetrcAuthResolver.h RequestFactory.cc \
|
||||
RequestFactory.h OptionParser.cc OptionParser.h \
|
||||
NetrcAuthResolver.cc NetrcAuthResolver.h AuthConfigFactory.cc \
|
||||
AuthConfigFactory.h OptionParser.cc OptionParser.h \
|
||||
OptionHandlerFactory.cc OptionHandlerFactory.h NameResolver.cc \
|
||||
NameResolver.h RequestGroup.cc RequestGroup.h \
|
||||
RequestGroupAware.cc RequestGroupAware.h RequestGroupMan.cc \
|
||||
|
@ -857,6 +857,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ActivePeerConnectionCommand.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AnnounceList.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AuthConfig.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AuthConfigFactory.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AutoSaveCommand.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Base64.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldMan.Po@am__quote@
|
||||
|
@ -988,7 +989,6 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PostDownloadHandler.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RealtimeCommand.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactory.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroup.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupAware.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupEntry.Po@am__quote@
|
||||
|
|
|
@ -42,9 +42,6 @@ const string Request::METHOD_GET = "get";
|
|||
const string Request::METHOD_HEAD = "head";
|
||||
|
||||
Request::Request():port(0), tryCount(0), keepAlive(false), method(METHOD_GET),
|
||||
_httpAuthResolver(0),
|
||||
_httpProxyAuthResolver(0),
|
||||
_ftpAuthResolver(0),
|
||||
cookieBox(CookieBoxFactorySingletonHolder::instance()->createNewInstance()) {}
|
||||
|
||||
Request::~Request() {}
|
||||
|
@ -84,14 +81,18 @@ bool Request::parseUrl(const string& url) {
|
|||
port = 0;
|
||||
dir = "";
|
||||
file = "";
|
||||
_username = "";
|
||||
_password = "";
|
||||
if(tempUrl.find_first_not_of(SAFE_CHARS) != string::npos) {
|
||||
return false;
|
||||
}
|
||||
// find query part
|
||||
string::size_type startQueryIndex = tempUrl.find("?");
|
||||
if(startQueryIndex != string::npos) {
|
||||
query = tempUrl.substr(startQueryIndex);
|
||||
tempUrl.erase(startQueryIndex);
|
||||
}
|
||||
// find protocol
|
||||
string::size_type hp = tempUrl.find("://");
|
||||
if(hp == string::npos) return false;
|
||||
protocol = tempUrl.substr(0, hp);
|
||||
|
@ -100,13 +101,24 @@ bool Request::parseUrl(const string& url) {
|
|||
return false;
|
||||
}
|
||||
hp += 3;
|
||||
// find host part
|
||||
if(tempUrl.size() <= hp) return false;
|
||||
string::size_type hep = tempUrl.find("/", hp);
|
||||
if(hep == string::npos) {
|
||||
hep = tempUrl.size();
|
||||
}
|
||||
string hostPart = tempUrl.substr(hp, hep-hp);
|
||||
// find username and password in host part if they exist
|
||||
string::size_type atmarkp = hostPart.find_last_of("@");
|
||||
if(atmarkp != string::npos) {
|
||||
string authPart = hostPart.substr(0, atmarkp);
|
||||
pair<string, string> userPass = Util::split(authPart, ":");
|
||||
_username = Util::urldecode(userPass.first);
|
||||
_password = Util::urldecode(userPass.second);
|
||||
hostPart.erase(0, atmarkp+1);
|
||||
}
|
||||
pair<string, string> hostAndPort;
|
||||
Util::split(hostAndPort, tempUrl.substr(hp, hep-hp), ':');
|
||||
Util::split(hostAndPort, hostPart, ':');
|
||||
host = hostAndPort.first;
|
||||
if(hostAndPort.second != "") {
|
||||
port = strtol(hostAndPort.second.c_str(), NULL, 10);
|
||||
|
@ -117,6 +129,7 @@ bool Request::parseUrl(const string& url) {
|
|||
// If port is not specified, then we set it to default port of its protocol..
|
||||
port = defPort;
|
||||
}
|
||||
// find directory and file part
|
||||
string::size_type direp = tempUrl.find_last_of("/");
|
||||
if(direp == string::npos || direp <= hep) {
|
||||
dir = "/";
|
||||
|
@ -139,18 +152,3 @@ bool Request::parseUrl(const string& url) {
|
|||
file += query;
|
||||
return true;
|
||||
}
|
||||
|
||||
AuthConfigHandle Request::resolveHttpAuthConfig()
|
||||
{
|
||||
return _httpAuthResolver->resolveAuthConfig(getHost());
|
||||
}
|
||||
|
||||
AuthConfigHandle Request::resolveFtpAuthConfig()
|
||||
{
|
||||
return _ftpAuthResolver->resolveAuthConfig(getHost());
|
||||
}
|
||||
|
||||
AuthConfigHandle Request::resolveHttpProxyAuthConfig()
|
||||
{
|
||||
return _httpProxyAuthResolver->resolveAuthConfig(getHost());
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#define _D_REQUEST_H_
|
||||
#include "common.h"
|
||||
#include "CookieBox.h"
|
||||
#include "AuthConfig.h"
|
||||
#include "AuthResolver.h"
|
||||
|
||||
#define SAFE_CHARS "abcdefghijklmnopqrstuvwxyz"\
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"\
|
||||
|
@ -80,11 +78,9 @@ private:
|
|||
bool keepAlive;
|
||||
string method;
|
||||
|
||||
AuthResolverHandle _httpAuthResolver;
|
||||
string _username;
|
||||
|
||||
AuthResolverHandle _httpProxyAuthResolver;
|
||||
|
||||
AuthResolverHandle _ftpAuthResolver;
|
||||
string _password;
|
||||
|
||||
bool parseUrl(const string& url);
|
||||
public:
|
||||
|
@ -125,27 +121,16 @@ public:
|
|||
this->method = method;
|
||||
}
|
||||
|
||||
void setHttpAuthResolver(const AuthResolverHandle& authResolver)
|
||||
const string& getUsername() const
|
||||
{
|
||||
_httpAuthResolver = authResolver;
|
||||
return _username;
|
||||
}
|
||||
|
||||
void setHttpProxyAuthResolver(const AuthResolverHandle& authResolver)
|
||||
const string& getPassword() const
|
||||
{
|
||||
_httpProxyAuthResolver = authResolver;
|
||||
return _password;
|
||||
}
|
||||
|
||||
void setFtpAuthResolver(const AuthResolverHandle& authResolver)
|
||||
{
|
||||
_ftpAuthResolver = authResolver;
|
||||
}
|
||||
|
||||
AuthConfigHandle resolveHttpAuthConfig();
|
||||
|
||||
AuthConfigHandle resolveFtpAuthConfig();
|
||||
|
||||
AuthConfigHandle resolveHttpProxyAuthConfig();
|
||||
|
||||
const string& getMethod() const {
|
||||
return method;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "SegmentManFactory.h"
|
||||
#include "Dependency.h"
|
||||
#include "prefs.h"
|
||||
#include "RequestFactory.h"
|
||||
#include "InitiateConnectionCommandFactory.h"
|
||||
#include "CUIDCounter.h"
|
||||
#include "File.h"
|
||||
|
@ -236,7 +235,7 @@ Commands RequestGroup::createNextCommand(DownloadEngine* e, int32_t numCommand,
|
|||
for(;!_uris.empty() && numCommand--; _uris.pop_front()) {
|
||||
string uri = _uris.front();
|
||||
_spentUris.push_back(uri);
|
||||
RequestHandle req = RequestFactorySingletonHolder::instance()->createRequest();
|
||||
RequestHandle req = new Request();
|
||||
req->setReferer(_option->get(PREF_REFERER));
|
||||
req->setMethod(method);
|
||||
if(req->setUrl(uri)) {
|
||||
|
|
10
src/main.cc
10
src/main.cc
|
@ -40,7 +40,7 @@
|
|||
#include "BitfieldManFactory.h"
|
||||
#include "SimpleRandomizer.h"
|
||||
#include "Netrc.h"
|
||||
#include "RequestFactory.h"
|
||||
#include "AuthConfigFactory.h"
|
||||
#include "FatalException.h"
|
||||
#include "File.h"
|
||||
#include "CUIDCounter.h"
|
||||
|
@ -58,6 +58,7 @@
|
|||
#include "SingleFileDownloadContext.h"
|
||||
#include "DefaultBtContext.h"
|
||||
#include "RequestGroup.h"
|
||||
#include "Option.h"
|
||||
#include <deque>
|
||||
#include <algorithm>
|
||||
#include <signal.h>
|
||||
|
@ -153,8 +154,7 @@ int main(int argc, char* argv[]) {
|
|||
logger->info("%s %s", PACKAGE, PACKAGE_VERSION);
|
||||
logger->info(MSG_LOGGING_STARTED);
|
||||
|
||||
RequestFactoryHandle requestFactory = new RequestFactory();
|
||||
requestFactory->setOption(op);
|
||||
AuthConfigFactoryHandle authConfigFactory = new AuthConfigFactory(op);
|
||||
File netrccf(op->get(PREF_NETRC_PATH));
|
||||
if(!op->getAsBool(PREF_NO_NETRC) && netrccf.isFile()) {
|
||||
mode_t mode = netrccf.mode();
|
||||
|
@ -164,7 +164,7 @@ int main(int argc, char* argv[]) {
|
|||
} else {
|
||||
NetrcHandle netrc = new Netrc();
|
||||
netrc->parse(op->get(PREF_NETRC_PATH));
|
||||
requestFactory->setNetrc(netrc);
|
||||
authConfigFactory->setNetrc(netrc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
RequestFactorySingletonHolder::instance(requestFactory);
|
||||
AuthConfigFactorySingleton::instance(authConfigFactory);
|
||||
CUIDCounterHandle cuidCounter = new CUIDCounter();
|
||||
CUIDCounterSingletonHolder::instance(cuidCounter);
|
||||
#ifdef SIGPIPE
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
#include "AuthConfigFactory.h"
|
||||
#include "Netrc.h"
|
||||
#include "prefs.h"
|
||||
#include "Request.h"
|
||||
#include "AuthConfig.h"
|
||||
#include "Option.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class AuthConfigFactoryTest:public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(AuthConfigFactoryTest);
|
||||
CPPUNIT_TEST(testCreateAuthConfig_http);
|
||||
CPPUNIT_TEST(testCreateAuthConfigForHttpProxy);
|
||||
CPPUNIT_TEST(testCreateAuthConfig_ftp);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void testCreateAuthConfig_http();
|
||||
void testCreateAuthConfigForHttpProxy();
|
||||
void testCreateAuthConfig_ftp();
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( AuthConfigFactoryTest );
|
||||
|
||||
void AuthConfigFactoryTest::testCreateAuthConfig_http()
|
||||
{
|
||||
RequestHandle req = new Request();
|
||||
req->setUrl("http://localhost/download/aria2-1.0.0.tar.bz2");
|
||||
|
||||
Option option;
|
||||
option.put(PREF_NO_NETRC, V_FALSE);
|
||||
|
||||
AuthConfigFactory factory(&option);
|
||||
|
||||
// without auth info
|
||||
CPPUNIT_ASSERT_EQUAL(string(":"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// with Netrc: disabled by default
|
||||
NetrcHandle netrc = new Netrc();
|
||||
netrc->addAuthenticator(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"));
|
||||
factory.setNetrc(netrc);
|
||||
CPPUNIT_ASSERT_EQUAL(string(":"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// with Netrc + user defined
|
||||
option.put(PREF_HTTP_USER, "userDefinedUser");
|
||||
option.put(PREF_HTTP_PASSWD, "userDefinedPassword");
|
||||
CPPUNIT_ASSERT_EQUAL(string("userDefinedUser:userDefinedPassword"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// username and password in URI: disabled by default.
|
||||
req->setUrl("http://aria2user:aria2password@localhost/download/aria2-1.0.0.tar.bz2");
|
||||
CPPUNIT_ASSERT_EQUAL(string("userDefinedUser:userDefinedPassword"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// CPPUNIT_ASSERT_EQUAL(string("aria2user:aria2password"),
|
||||
// factory.createAuthConfig(req)->getAuthText());
|
||||
}
|
||||
|
||||
void AuthConfigFactoryTest::testCreateAuthConfigForHttpProxy()
|
||||
{
|
||||
RequestHandle req = new Request();
|
||||
req->setUrl("http://localhost/download/aria2-1.0.0.tar.bz2");
|
||||
// with Netrc
|
||||
NetrcHandle netrc = new Netrc();
|
||||
netrc->addAuthenticator(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"));
|
||||
|
||||
Option option;
|
||||
option.put(PREF_NO_NETRC, V_FALSE);
|
||||
|
||||
AuthConfigFactory factory(&option);
|
||||
factory.setNetrc(netrc);
|
||||
|
||||
// netrc is not used in http proxy auth
|
||||
CPPUNIT_ASSERT_EQUAL(string(":"),
|
||||
factory.createAuthConfigForHttpProxy(req)->getAuthText());
|
||||
|
||||
option.put(PREF_HTTP_PROXY_USER, "userDefinedUser");
|
||||
option.put(PREF_HTTP_PROXY_PASSWD, "userDefinedPassword");
|
||||
CPPUNIT_ASSERT_EQUAL(string("userDefinedUser:userDefinedPassword"),
|
||||
factory.createAuthConfigForHttpProxy(req)->getAuthText());
|
||||
|
||||
}
|
||||
|
||||
void AuthConfigFactoryTest::testCreateAuthConfig_ftp()
|
||||
{
|
||||
RequestHandle req = new Request();
|
||||
req->setUrl("ftp://localhost/download/aria2-1.0.0.tar.bz2");
|
||||
|
||||
Option option;
|
||||
option.put(PREF_NO_NETRC, V_FALSE);
|
||||
|
||||
AuthConfigFactory factory(&option);
|
||||
|
||||
// without auth info
|
||||
CPPUNIT_ASSERT_EQUAL(string("anonymous:ARIA2USER@"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// with Netrc
|
||||
NetrcHandle netrc = new Netrc();
|
||||
netrc->addAuthenticator(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"));
|
||||
factory.setNetrc(netrc);
|
||||
CPPUNIT_ASSERT_EQUAL(string("default:defaultpassword"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// disable Netrc
|
||||
option.put(PREF_NO_NETRC, V_TRUE);
|
||||
CPPUNIT_ASSERT_EQUAL(string("anonymous:ARIA2USER@"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// with Netrc + user defined
|
||||
option.put(PREF_NO_NETRC, V_FALSE);
|
||||
option.put(PREF_FTP_USER, "userDefinedUser");
|
||||
option.put(PREF_FTP_PASSWD, "userDefinedPassword");
|
||||
CPPUNIT_ASSERT_EQUAL(string("userDefinedUser:userDefinedPassword"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
|
||||
// username and password in URI: disabled by default.
|
||||
req->setUrl("ftp://aria2user:aria2password@localhost/download/aria2-1.0.0.tar.bz2");
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2user:aria2password"),
|
||||
factory.createAuthConfig(req)->getAuthText());
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include "HttpRequest.h"
|
||||
#include "prefs.h"
|
||||
#include "RequestFactory.h"
|
||||
#include "AuthConfigFactory.h"
|
||||
#include "PiecedSegment.h"
|
||||
#include "Piece.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
@ -84,31 +84,30 @@ void HttpRequestTest::testGetEndByte()
|
|||
|
||||
void HttpRequestTest::testCreateRequest()
|
||||
{
|
||||
SharedHandle<Option> option = new Option();
|
||||
option->put(PREF_HTTP_AUTH_ENABLED, V_FALSE);
|
||||
option->put(PREF_HTTP_PROXY_ENABLED, V_FALSE);
|
||||
option->put(PREF_HTTP_PROXY_METHOD, V_TUNNEL);
|
||||
option->put(PREF_HTTP_PROXY_AUTH_ENABLED, V_FALSE);
|
||||
option->put(PREF_HTTP_USER, "aria2user");
|
||||
option->put(PREF_HTTP_PASSWD, "aria2passwd");
|
||||
option->put(PREF_HTTP_PROXY_USER, "aria2proxyuser");
|
||||
option->put(PREF_HTTP_PROXY_PASSWD, "aria2proxypasswd");
|
||||
RequestFactory requestFactory;
|
||||
requestFactory.setOption(option.get());
|
||||
Option option;
|
||||
option.put(PREF_HTTP_AUTH_ENABLED, V_FALSE);
|
||||
option.put(PREF_HTTP_PROXY_ENABLED, V_FALSE);
|
||||
option.put(PREF_HTTP_PROXY_METHOD, V_TUNNEL);
|
||||
option.put(PREF_HTTP_PROXY_AUTH_ENABLED, V_FALSE);
|
||||
option.put(PREF_HTTP_USER, "aria2user");
|
||||
option.put(PREF_HTTP_PASSWD, "aria2passwd");
|
||||
option.put(PREF_HTTP_PROXY_USER, "aria2proxyuser");
|
||||
option.put(PREF_HTTP_PROXY_PASSWD, "aria2proxypasswd");
|
||||
|
||||
RequestHandle request = requestFactory.createRequest();
|
||||
AuthConfigFactoryHandle authConfigFactory = new AuthConfigFactory(&option);
|
||||
AuthConfigFactorySingleton::instance(authConfigFactory);
|
||||
|
||||
RequestHandle request = new Request();
|
||||
request->setUrl("http://localhost:8080/archives/aria2-1.0.0.tar.bz2");
|
||||
|
||||
SegmentHandle segment = new PiecedSegment(1024, new Piece(0, 1024));
|
||||
|
||||
HttpRequest httpRequest;
|
||||
|
||||
httpRequest.setRequest(request);
|
||||
httpRequest.setSegment(segment);
|
||||
|
||||
request->setKeepAlive(true);
|
||||
|
||||
|
||||
string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
"Accept: */*\r\n"
|
||||
|
@ -158,7 +157,7 @@ void HttpRequestTest::testCreateRequest()
|
|||
"Cache-Control: no-cache\r\n"
|
||||
"Range: bytes=1048576-2097151\r\n"
|
||||
"\r\n";
|
||||
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
||||
request->setKeepAlive(false);
|
||||
|
@ -183,9 +182,9 @@ void HttpRequestTest::testCreateRequest()
|
|||
httpRequest.setSegment(segment);
|
||||
|
||||
// enable http auth
|
||||
option->put(PREF_HTTP_AUTH_ENABLED, V_TRUE);
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
option.put(PREF_HTTP_AUTH_ENABLED, V_TRUE);
|
||||
|
||||
httpRequest.configure(&option);
|
||||
|
||||
expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
@ -200,9 +199,9 @@ void HttpRequestTest::testCreateRequest()
|
|||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
||||
// enable http proxy auth
|
||||
option->put(PREF_HTTP_PROXY_AUTH_ENABLED, V_TRUE);
|
||||
option.put(PREF_HTTP_PROXY_AUTH_ENABLED, V_TRUE);
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
httpRequest.configure(&option);
|
||||
|
||||
expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
@ -216,9 +215,9 @@ void HttpRequestTest::testCreateRequest()
|
|||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
||||
option->put(PREF_HTTP_PROXY_ENABLED, V_TRUE);
|
||||
option.put(PREF_HTTP_PROXY_ENABLED, V_TRUE);
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
httpRequest.configure(&option);
|
||||
|
||||
expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
@ -232,9 +231,9 @@ void HttpRequestTest::testCreateRequest()
|
|||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
||||
option->put(PREF_HTTP_PROXY_METHOD, V_GET);
|
||||
option.put(PREF_HTTP_PROXY_METHOD, V_GET);
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
httpRequest.configure(&option);
|
||||
|
||||
expectedText = "GET http://localhost:8080/archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
@ -268,9 +267,9 @@ void HttpRequestTest::testCreateRequest()
|
|||
|
||||
request->setKeepAlive(false);
|
||||
|
||||
option->put(PREF_HTTP_PROXY_AUTH_ENABLED, V_FALSE);
|
||||
option.put(PREF_HTTP_PROXY_AUTH_ENABLED, V_FALSE);
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
httpRequest.configure(&option);
|
||||
|
||||
expectedText = "GET http://localhost:8080/archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
@ -288,20 +287,20 @@ void HttpRequestTest::testCreateRequest()
|
|||
|
||||
void HttpRequestTest::testCreateRequest_ftp()
|
||||
{
|
||||
SharedHandle<Option> option = new Option();
|
||||
option->put(PREF_HTTP_AUTH_ENABLED, V_FALSE);
|
||||
option->put(PREF_HTTP_PROXY_ENABLED, V_FALSE);
|
||||
option->put(PREF_HTTP_PROXY_METHOD, V_TUNNEL);
|
||||
option->put(PREF_HTTP_PROXY_AUTH_ENABLED, V_FALSE);
|
||||
option->put(PREF_HTTP_USER, "aria2user");
|
||||
option->put(PREF_HTTP_PASSWD, "aria2passwd");
|
||||
option->put(PREF_HTTP_PROXY_USER, "aria2proxyuser");
|
||||
option->put(PREF_HTTP_PROXY_PASSWD, "aria2proxypasswd");
|
||||
Option option;
|
||||
option.put(PREF_HTTP_AUTH_ENABLED, V_FALSE);
|
||||
option.put(PREF_HTTP_PROXY_ENABLED, V_FALSE);
|
||||
option.put(PREF_HTTP_PROXY_METHOD, V_TUNNEL);
|
||||
option.put(PREF_HTTP_PROXY_AUTH_ENABLED, V_FALSE);
|
||||
option.put(PREF_HTTP_USER, "aria2user");
|
||||
option.put(PREF_HTTP_PASSWD, "aria2passwd");
|
||||
option.put(PREF_HTTP_PROXY_USER, "aria2proxyuser");
|
||||
option.put(PREF_HTTP_PROXY_PASSWD, "aria2proxypasswd");
|
||||
|
||||
RequestFactory requestFactory;
|
||||
requestFactory.setOption(option.get());
|
||||
AuthConfigFactoryHandle authConfigFactory = new AuthConfigFactory(&option);
|
||||
AuthConfigFactorySingleton::instance(authConfigFactory);
|
||||
|
||||
RequestHandle request = requestFactory.createRequest();
|
||||
RequestHandle request = new Request();
|
||||
request->setUrl("ftp://localhost:8080/archives/aria2-1.0.0.tar.bz2");
|
||||
|
||||
HttpRequest httpRequest;
|
||||
|
@ -309,7 +308,7 @@ void HttpRequestTest::testCreateRequest_ftp()
|
|||
httpRequest.setRequest(request);
|
||||
httpRequest.setSegment(segment);
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
httpRequest.configure(&option);
|
||||
|
||||
string expectedText = "GET ftp://localhost:8080/archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
@ -323,11 +322,11 @@ void HttpRequestTest::testCreateRequest_ftp()
|
|||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
||||
// How to enable HTTP proxy authorization in FTP download via HTTP proxy
|
||||
option->put(PREF_HTTP_PROXY_ENABLED, V_TRUE);
|
||||
option->put(PREF_HTTP_PROXY_METHOD, V_GET);
|
||||
option->put(PREF_HTTP_PROXY_AUTH_ENABLED, V_TRUE);
|
||||
option.put(PREF_HTTP_PROXY_ENABLED, V_TRUE);
|
||||
option.put(PREF_HTTP_PROXY_METHOD, V_GET);
|
||||
option.put(PREF_HTTP_PROXY_AUTH_ENABLED, V_TRUE);
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
httpRequest.configure(&option);
|
||||
|
||||
expectedText = "GET ftp://localhost:8080/archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
@ -505,17 +504,17 @@ void HttpRequestTest::testIsRangeSatisfied()
|
|||
|
||||
void HttpRequestTest::testUserAgent()
|
||||
{
|
||||
SharedHandle<Option> option = new Option();
|
||||
RequestFactory requestFactory;
|
||||
requestFactory.setOption(option.get());
|
||||
Option option;
|
||||
|
||||
RequestHandle request = requestFactory.createRequest();
|
||||
AuthConfigFactoryHandle authConfigFactory = new AuthConfigFactory(&option);
|
||||
AuthConfigFactorySingleton::instance(authConfigFactory);
|
||||
|
||||
RequestHandle request = new Request();
|
||||
request->setUrl("http://localhost:8080/archives/aria2-1.0.0.tar.bz2");
|
||||
|
||||
SegmentHandle segment = new PiecedSegment(1024, new Piece(0, 1024));
|
||||
|
||||
HttpRequest httpRequest;
|
||||
|
||||
httpRequest.setRequest(request);
|
||||
httpRequest.setSegment(segment);
|
||||
httpRequest.setUserAgent("aria2 (Linux)");
|
||||
|
|
|
@ -22,7 +22,7 @@ aria2c_SOURCES = AllTest.cc\
|
|||
HttpRequestTest.cc\
|
||||
CookieBoxFactoryTest.cc\
|
||||
RequestGroupManTest.cc\
|
||||
RequestFactoryTest.cc\
|
||||
AuthConfigFactoryTest.cc\
|
||||
NetrcAuthResolverTest.cc\
|
||||
DefaultAuthResolverTest.cc\
|
||||
OptionHandlerTest.cc\
|
||||
|
|
|
@ -121,7 +121,7 @@ am__aria2c_SOURCES_DIST = AllTest.cc PieceTest.cc \
|
|||
FileUriListParserTest.cc StreamUriListParserTest.cc \
|
||||
HttpHeaderProcessorTest.cc CookieBoxTest.cc RequestTest.cc \
|
||||
CookieParserTest.cc HttpRequestTest.cc CookieBoxFactoryTest.cc \
|
||||
RequestGroupManTest.cc RequestFactoryTest.cc \
|
||||
RequestGroupManTest.cc AuthConfigFactoryTest.cc \
|
||||
NetrcAuthResolverTest.cc DefaultAuthResolverTest.cc \
|
||||
OptionHandlerTest.cc SegmentManTest.cc BitfieldManTest.cc \
|
||||
NetrcTest.cc SingletonHolderTest.cc HttpHeaderTest.cc \
|
||||
|
@ -215,7 +215,7 @@ am_aria2c_OBJECTS = AllTest.$(OBJEXT) PieceTest.$(OBJEXT) \
|
|||
HttpHeaderProcessorTest.$(OBJEXT) CookieBoxTest.$(OBJEXT) \
|
||||
RequestTest.$(OBJEXT) CookieParserTest.$(OBJEXT) \
|
||||
HttpRequestTest.$(OBJEXT) CookieBoxFactoryTest.$(OBJEXT) \
|
||||
RequestGroupManTest.$(OBJEXT) RequestFactoryTest.$(OBJEXT) \
|
||||
RequestGroupManTest.$(OBJEXT) AuthConfigFactoryTest.$(OBJEXT) \
|
||||
NetrcAuthResolverTest.$(OBJEXT) \
|
||||
DefaultAuthResolverTest.$(OBJEXT) OptionHandlerTest.$(OBJEXT) \
|
||||
SegmentManTest.$(OBJEXT) BitfieldManTest.$(OBJEXT) \
|
||||
|
@ -422,7 +422,7 @@ aria2c_SOURCES = AllTest.cc PieceTest.cc DefaultPieceStorageTest.cc \
|
|||
FileUriListParserTest.cc StreamUriListParserTest.cc \
|
||||
HttpHeaderProcessorTest.cc CookieBoxTest.cc RequestTest.cc \
|
||||
CookieParserTest.cc HttpRequestTest.cc CookieBoxFactoryTest.cc \
|
||||
RequestGroupManTest.cc RequestFactoryTest.cc \
|
||||
RequestGroupManTest.cc AuthConfigFactoryTest.cc \
|
||||
NetrcAuthResolverTest.cc DefaultAuthResolverTest.cc \
|
||||
OptionHandlerTest.cc SegmentManTest.cc BitfieldManTest.cc \
|
||||
NetrcTest.cc SingletonHolderTest.cc HttpHeaderTest.cc \
|
||||
|
@ -497,6 +497,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AlphaNumberDecoratorTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AnnounceListTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AuthConfigFactoryTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Base64Test.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldManTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtAllowedFastMessageTest.Po@am__quote@
|
||||
|
@ -563,7 +564,6 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtilTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PieceTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactoryTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupManTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupTest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestTest.Po@am__quote@
|
||||
|
|
|
@ -1,128 +0,0 @@
|
|||
#include "RequestFactory.h"
|
||||
#include "prefs.h"
|
||||
#include "NetrcAuthResolver.h"
|
||||
#include "DefaultAuthResolver.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class RequestFactoryTest : public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(RequestFactoryTest);
|
||||
CPPUNIT_TEST(testCreateHttpAuthResolver_netrc);
|
||||
CPPUNIT_TEST(testCreateHttpAuthResolver_def);
|
||||
CPPUNIT_TEST(testCreateFtpAuthResolver_netrc);
|
||||
CPPUNIT_TEST(testCreateFtpAuthResolver_def);
|
||||
CPPUNIT_TEST(testCreateHttpProxyAuthResolver_netrc);
|
||||
CPPUNIT_TEST(testCreateHttpProxyAuthResolver_def);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
NetrcHandle _netrc;
|
||||
SharedHandle<Option> _option;
|
||||
RequestFactoryHandle _factory;
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
_netrc = new Netrc();
|
||||
_option = new Option();
|
||||
_factory = new RequestFactory();
|
||||
_factory->setNetrc(_netrc);
|
||||
_factory->setOption(_option.get());
|
||||
}
|
||||
|
||||
void testCreateHttpAuthResolver_netrc();
|
||||
void testCreateHttpAuthResolver_def();
|
||||
void testCreateFtpAuthResolver_netrc();
|
||||
void testCreateFtpAuthResolver_def();
|
||||
void testCreateHttpProxyAuthResolver_netrc();
|
||||
void testCreateHttpProxyAuthResolver_def();
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( RequestFactoryTest );
|
||||
|
||||
void RequestFactoryTest::testCreateHttpAuthResolver_netrc()
|
||||
{
|
||||
_option->put(PREF_NO_NETRC, V_FALSE);
|
||||
_option->put(PREF_HTTP_USER, "foo");
|
||||
_option->put(PREF_HTTP_PASSWD, "bar");
|
||||
DefaultAuthResolverHandle defResolver = _factory->createHttpAuthResolver();
|
||||
CPPUNIT_ASSERT(!defResolver.isNull());
|
||||
CPPUNIT_ASSERT(!defResolver->getUserDefinedAuthConfig().isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("foo:bar"),
|
||||
defResolver->getUserDefinedAuthConfig()->getAuthText());
|
||||
/*
|
||||
NetrcAuthResolverHandle netrcResolver = _factory->createHttpAuthResolver();
|
||||
CPPUNIT_ASSERT(!netrcResolver.isNull());
|
||||
CPPUNIT_ASSERT(!netrcResolver->getNetrc().isNull());
|
||||
CPPUNIT_ASSERT(netrcResolver->getUserDefinedAuthConfig().isNull());
|
||||
*/
|
||||
}
|
||||
|
||||
void RequestFactoryTest::testCreateHttpAuthResolver_def()
|
||||
{
|
||||
_option->put(PREF_NO_NETRC, V_TRUE);
|
||||
_option->put(PREF_HTTP_USER, "foo");
|
||||
_option->put(PREF_HTTP_PASSWD, "bar");
|
||||
DefaultAuthResolverHandle defResolver = _factory->createHttpAuthResolver();
|
||||
CPPUNIT_ASSERT(!defResolver.isNull());
|
||||
CPPUNIT_ASSERT(!defResolver->getUserDefinedAuthConfig().isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("foo:bar"),
|
||||
defResolver->getUserDefinedAuthConfig()->getAuthText());
|
||||
}
|
||||
|
||||
void RequestFactoryTest::testCreateFtpAuthResolver_netrc()
|
||||
{
|
||||
_option->put(PREF_NO_NETRC, V_FALSE);
|
||||
NetrcAuthResolverHandle netrcResolver = _factory->createFtpAuthResolver();
|
||||
CPPUNIT_ASSERT(!netrcResolver.isNull());
|
||||
CPPUNIT_ASSERT(!netrcResolver->getNetrc().isNull());
|
||||
CPPUNIT_ASSERT(netrcResolver->getUserDefinedAuthConfig().isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("anonymous:ARIA2USER@"),
|
||||
netrcResolver->getDefaultAuthConfig()->getAuthText());
|
||||
}
|
||||
|
||||
void RequestFactoryTest::testCreateFtpAuthResolver_def()
|
||||
{
|
||||
_option->put(PREF_NO_NETRC, V_TRUE);
|
||||
_option->put(PREF_FTP_USER, "foo");
|
||||
_option->put(PREF_FTP_PASSWD, "bar");
|
||||
DefaultAuthResolverHandle defResolver = _factory->createFtpAuthResolver();
|
||||
CPPUNIT_ASSERT(!defResolver.isNull());
|
||||
CPPUNIT_ASSERT(!defResolver->getUserDefinedAuthConfig().isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("foo:bar"),
|
||||
defResolver->getUserDefinedAuthConfig()->getAuthText());
|
||||
CPPUNIT_ASSERT_EQUAL(string("anonymous:ARIA2USER@"),
|
||||
defResolver->getDefaultAuthConfig()->getAuthText());
|
||||
}
|
||||
|
||||
void RequestFactoryTest::testCreateHttpProxyAuthResolver_netrc()
|
||||
{
|
||||
_option->put(PREF_NO_NETRC, V_FALSE);
|
||||
_option->put(PREF_HTTP_PROXY_USER, "foo");
|
||||
_option->put(PREF_HTTP_PROXY_PASSWD, "bar");
|
||||
DefaultAuthResolverHandle defResolver = _factory->createHttpProxyAuthResolver();
|
||||
CPPUNIT_ASSERT(!defResolver.isNull());
|
||||
CPPUNIT_ASSERT(!defResolver->getUserDefinedAuthConfig().isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("foo:bar"),
|
||||
defResolver->getUserDefinedAuthConfig()->getAuthText());
|
||||
/*
|
||||
NetrcAuthResolverHandle netrcResolver = _factory->createHttpProxyAuthResolver();
|
||||
CPPUNIT_ASSERT(!netrcResolver.isNull());
|
||||
CPPUNIT_ASSERT(!netrcResolver->getNetrc().isNull());
|
||||
CPPUNIT_ASSERT(netrcResolver->getUserDefinedAuthConfig().isNull());
|
||||
*/
|
||||
}
|
||||
|
||||
void RequestFactoryTest::testCreateHttpProxyAuthResolver_def()
|
||||
{
|
||||
_option->put(PREF_NO_NETRC, V_TRUE);
|
||||
_option->put(PREF_HTTP_PROXY_USER, "foo");
|
||||
_option->put(PREF_HTTP_PROXY_PASSWD, "bar");
|
||||
DefaultAuthResolverHandle defResolver = _factory->createHttpProxyAuthResolver();
|
||||
CPPUNIT_ASSERT(!defResolver.isNull());
|
||||
CPPUNIT_ASSERT(!defResolver->getUserDefinedAuthConfig().isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("foo:bar"),
|
||||
defResolver->getUserDefinedAuthConfig()->getAuthText());
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#include "RequestGroupMan.h"
|
||||
#include "CUIDCounter.h"
|
||||
#include "prefs.h"
|
||||
#include "RequestFactory.h"
|
||||
#include "SingleFileDownloadContext.h"
|
||||
#include "RequestGroup.h"
|
||||
#include "Option.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace std;
|
||||
|
@ -64,28 +64,4 @@ void RequestGroupManTest::testIsSameFileBeingDownloaded()
|
|||
void RequestGroupManTest::testGetInitialCommands()
|
||||
{
|
||||
// TODO implement later
|
||||
/*
|
||||
Option option;
|
||||
option.put(PREF_SPLIT, "1");
|
||||
option.put(PREF_TIMEOUT, "10");
|
||||
|
||||
RequestFactoryHandle requestFactory = new RequestFactory();
|
||||
requestFactory->setOption(&option);
|
||||
RequestFactorySingletonHolder::instance(requestFactory);
|
||||
|
||||
RequestGroupMan gm;
|
||||
|
||||
RequestGroupHandle rg1 = new RequestGroup("aria2.tar.bz2.metalink",
|
||||
&option);
|
||||
RequestGroupHandle rg2 = new RequestGroup("http://localhost/aria2.tar.bz2",
|
||||
&option);
|
||||
|
||||
gm.addRequestGroup(rg1);
|
||||
gm.addRequestGroup(rg2);
|
||||
|
||||
ConsoleDownloadEngine e;
|
||||
e.option = &option;
|
||||
Commands commands = gm.getInitialCommands(&e);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, commands.size());
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -23,16 +23,15 @@ class RequestTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testSetUrl14);
|
||||
CPPUNIT_TEST(testSetUrl15);
|
||||
CPPUNIT_TEST(testSetUrl16);
|
||||
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(testResolveHttpAuthConfig);
|
||||
CPPUNIT_TEST(testResolveHttpAuthConfig_noCandidate);
|
||||
CPPUNIT_TEST(testResolveHttpProxyAuthConfig);
|
||||
CPPUNIT_TEST(testResolveFtpAuthConfig);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
@ -52,16 +51,15 @@ public:
|
|||
void testSetUrl14();
|
||||
void testSetUrl15();
|
||||
void testSetUrl16();
|
||||
void testSetUrl_username();
|
||||
void testSetUrl_usernamePassword();
|
||||
void testSetUrl_zeroUsername();
|
||||
void testRedirectUrl();
|
||||
void testRedirectUrl2();
|
||||
void testResetUrl();
|
||||
void testSafeChar();
|
||||
void testInnerLink();
|
||||
void testMetalink();
|
||||
void testResolveHttpAuthConfig();
|
||||
void testResolveHttpAuthConfig_noCandidate();
|
||||
void testResolveHttpProxyAuthConfig();
|
||||
void testResolveFtpAuthConfig();
|
||||
};
|
||||
|
||||
|
||||
|
@ -80,6 +78,8 @@ void RequestTest::testSetUrl1() {
|
|||
CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL(string("/"), req.getDir());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getFile());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getUsername());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getPassword());
|
||||
}
|
||||
|
||||
void RequestTest::testSetUrl2() {
|
||||
|
@ -341,77 +341,66 @@ void RequestTest::testMetalink() {
|
|||
#endif // ENABLE_METALINK
|
||||
}
|
||||
|
||||
void RequestTest::testResolveHttpAuthConfig()
|
||||
void RequestTest::testSetUrl_zeroUsername()
|
||||
{
|
||||
Request req;
|
||||
req.setUrl("http://localhost/download/aria2-1.0.0.tar.bz2");
|
||||
// with DefaultAuthResolver
|
||||
DefaultAuthResolverHandle defaultAuthResolver = new DefaultAuthResolver();
|
||||
req.setHttpAuthResolver(defaultAuthResolver);
|
||||
CPPUNIT_ASSERT(!req.resolveHttpAuthConfig().isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string(":"),
|
||||
req.resolveHttpAuthConfig()->getAuthText());
|
||||
CPPUNIT_ASSERT(req.setUrl("ftp://@localhost/download/aria2-1.0.0.tar.bz2"));
|
||||
CPPUNIT_ASSERT_EQUAL(string("ftp"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)21, req.getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2-1.0.0.tar.bz2"), req.getFile());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getUsername());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getPassword());
|
||||
|
||||
// with Netrc
|
||||
NetrcHandle netrc = new Netrc();
|
||||
netrc->addAuthenticator(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"));
|
||||
NetrcAuthResolverHandle netrcAuthResolver = new NetrcAuthResolver();
|
||||
netrcAuthResolver->setNetrc(netrc);
|
||||
req.setHttpAuthResolver(netrcAuthResolver);
|
||||
AuthConfigHandle authConfig1 = req.resolveHttpAuthConfig();
|
||||
CPPUNIT_ASSERT(!authConfig1.isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("default:defaultpassword"),
|
||||
authConfig1->getAuthText());
|
||||
CPPUNIT_ASSERT(req.setUrl("ftp://:@localhost/download/aria2-1.0.0.tar.bz2"));
|
||||
CPPUNIT_ASSERT_EQUAL(string("ftp"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)21, req.getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2-1.0.0.tar.bz2"), req.getFile());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getUsername());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getPassword());
|
||||
|
||||
CPPUNIT_ASSERT(req.setUrl("ftp://:pass@localhost/download/aria2-1.0.0.tar.bz2"));
|
||||
CPPUNIT_ASSERT_EQUAL(string("ftp"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)21, req.getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2-1.0.0.tar.bz2"), req.getFile());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getUsername());
|
||||
CPPUNIT_ASSERT_EQUAL(string("pass"), req.getPassword());
|
||||
|
||||
// with Netrc + user defined
|
||||
AuthConfigHandle authConfig =
|
||||
new AuthConfig("userDefinedUser", "userDefinedPassword");
|
||||
netrcAuthResolver->setUserDefinedAuthConfig(authConfig);
|
||||
AuthConfigHandle authConfig2 = req.resolveHttpAuthConfig();
|
||||
CPPUNIT_ASSERT(!authConfig2.isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("userDefinedUser:userDefinedPassword"),
|
||||
authConfig2->getAuthText());
|
||||
}
|
||||
|
||||
void RequestTest::testResolveHttpAuthConfig_noCandidate()
|
||||
void RequestTest::testSetUrl_username()
|
||||
{
|
||||
Request req;
|
||||
req.setUrl("http://localhost/download/aria2-1.0.0.tar.bz2");
|
||||
|
||||
DefaultAuthResolverHandle defaultAuthResolver = new DefaultAuthResolver();
|
||||
req.setHttpAuthResolver(defaultAuthResolver);
|
||||
CPPUNIT_ASSERT_EQUAL(string(":"),
|
||||
req.resolveHttpAuthConfig()->getAuthText());
|
||||
CPPUNIT_ASSERT(req.setUrl("ftp://aria2user@localhost/download/aria2-1.0.0.tar.bz2"));
|
||||
CPPUNIT_ASSERT_EQUAL(string("ftp"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)21, req.getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2-1.0.0.tar.bz2"), req.getFile());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2user"), req.getUsername());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getPassword());
|
||||
}
|
||||
|
||||
void RequestTest::testResolveHttpProxyAuthConfig()
|
||||
void RequestTest::testSetUrl_usernamePassword()
|
||||
{
|
||||
Request req;
|
||||
req.setUrl("http://localhost/download/aria2-1.0.0.tar.bz2");
|
||||
// with Netrc
|
||||
NetrcHandle netrc = new Netrc();
|
||||
netrc->addAuthenticator(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"));
|
||||
NetrcAuthResolverHandle netrcAuthResolver = new NetrcAuthResolver();
|
||||
netrcAuthResolver->setNetrc(netrc);
|
||||
req.setHttpProxyAuthResolver(netrcAuthResolver);
|
||||
AuthConfigHandle authConfig1 = req.resolveHttpProxyAuthConfig();
|
||||
CPPUNIT_ASSERT(!authConfig1.isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("default:defaultpassword"),
|
||||
authConfig1->getAuthText());
|
||||
}
|
||||
CPPUNIT_ASSERT(req.setUrl("ftp://aria2user%40:aria2pass%40@localhost/download/aria2-1.0.0.tar.bz2"));
|
||||
CPPUNIT_ASSERT_EQUAL(string("ftp"), req.getProtocol());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)21, req.getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2-1.0.0.tar.bz2"), req.getFile());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2user@"), req.getUsername());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2pass@"), req.getPassword());
|
||||
|
||||
// make sure that after new url is set, username and password are updated.
|
||||
CPPUNIT_ASSERT(req.setUrl("ftp://localhost/download/aria2-1.0.0.tar.bz2"));
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getUsername());
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), req.getPassword());
|
||||
|
||||
void RequestTest::testResolveFtpAuthConfig()
|
||||
{
|
||||
Request req;
|
||||
req.setUrl("http://localhost/download/aria2-1.0.0.tar.bz2");
|
||||
// with Netrc
|
||||
NetrcHandle netrc = new Netrc();
|
||||
netrc->addAuthenticator(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"));
|
||||
NetrcAuthResolverHandle netrcAuthResolver = new NetrcAuthResolver();
|
||||
netrcAuthResolver->setNetrc(netrc);
|
||||
req.setFtpAuthResolver(netrcAuthResolver);
|
||||
AuthConfigHandle authConfig1 = req.resolveFtpAuthConfig();
|
||||
CPPUNIT_ASSERT(!authConfig1.isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(string("default:defaultpassword"),
|
||||
authConfig1->getAuthText());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue