mirror of https://github.com/aria2/aria2
2007-03-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the command-line option which disables netrc support: * src/OptionHandlerFactory.cc (createOptionHandlers): Added PREF_NO_NETRC. * src/main.cc: Added -n option. * src/prefs.h (PREF_NO_NETRC): New definition. * src/RequestFactory.cc: Do not use netrc in ftp if PREF_NO_NETRC is V_TRUE. Note that netrc is not used in http, http proxy even if PREF_NO_NETRC is V_FALSE. This may get configurable in the future release. To clear peer's error status by time basis: * src/PeerAbstractCommand.cc (onAbort): Call Peer::startBadCondition(). * src/Peer.h, src/Peer.cc (error): Removed. (_badConditionStartTime): New variable. (_badConditionInterval): New variable. Initialized to 10 seconds. (startBadCondition): New function. (isGood): New function. * src/DefaultPeerStorage.cc (addPeer): Use Peer::isGood(). (FindFinePeer): Use Peer::isGood(). Always include port number in http request header: * src/HttpRequest.cc (getHostText): Always include port number in http request header.pull/1/head
parent
9b73454b07
commit
6e6ba30c60
32
ChangeLog
32
ChangeLog
|
@ -1,3 +1,32 @@
|
||||||
|
2007-03-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
To add the command-line option which disables netrc support:
|
||||||
|
* src/OptionHandlerFactory.cc
|
||||||
|
(createOptionHandlers): Added PREF_NO_NETRC.
|
||||||
|
* src/main.cc: Added -n option.
|
||||||
|
* src/prefs.h (PREF_NO_NETRC): New definition.
|
||||||
|
* src/RequestFactory.cc: Do not use netrc in ftp if PREF_NO_NETRC is
|
||||||
|
V_TRUE.
|
||||||
|
Note that netrc is not used in http, http proxy even if PREF_NO_NETRC
|
||||||
|
is V_FALSE. This may get configurable in the future release.
|
||||||
|
|
||||||
|
To clear peer's error status by time basis:
|
||||||
|
* src/PeerAbstractCommand.cc
|
||||||
|
(onAbort): Call Peer::startBadCondition().
|
||||||
|
* src/Peer.h, src/Peer.cc
|
||||||
|
(error): Removed.
|
||||||
|
(_badConditionStartTime): New variable.
|
||||||
|
(_badConditionInterval): New variable. Initialized to 10 seconds.
|
||||||
|
(startBadCondition): New function.
|
||||||
|
(isGood): New function.
|
||||||
|
* src/DefaultPeerStorage.cc
|
||||||
|
(addPeer): Use Peer::isGood().
|
||||||
|
(FindFinePeer): Use Peer::isGood().
|
||||||
|
|
||||||
|
Always include port number in http request header:
|
||||||
|
* src/HttpRequest.cc (getHostText): Always include port number in
|
||||||
|
http request header.
|
||||||
|
|
||||||
2007-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2007-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
To the ability to read options from a config file:
|
To the ability to read options from a config file:
|
||||||
|
@ -30,6 +59,9 @@
|
||||||
* src/prefs.h (PREF_USER_AGENT): New definition.
|
* src/prefs.h (PREF_USER_AGENT): New definition.
|
||||||
* src/HttpRequestCommand.cc (executeInternal): Set user-agent option
|
* src/HttpRequestCommand.cc (executeInternal): Set user-agent option
|
||||||
parameter to HttpRequest object.
|
parameter to HttpRequest object.
|
||||||
|
* src/AbstractProxyRequestCommand.cc
|
||||||
|
(executeInternal): Set user-agent option parameter to HttpRequest
|
||||||
|
object.
|
||||||
|
|
||||||
Marged the patches from Dan Fandrich.
|
Marged the patches from Dan Fandrich.
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "AbstractProxyRequestCommand.h"
|
#include "AbstractProxyRequestCommand.h"
|
||||||
#include "HttpConnection.h"
|
#include "HttpConnection.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
|
||||||
AbstractProxyRequestCommand::AbstractProxyRequestCommand(int cuid,
|
AbstractProxyRequestCommand::AbstractProxyRequestCommand(int cuid,
|
||||||
const RequestHandle& req,
|
const RequestHandle& req,
|
||||||
|
@ -50,6 +51,7 @@ bool AbstractProxyRequestCommand::executeInternal() {
|
||||||
socket->setBlockingMode();
|
socket->setBlockingMode();
|
||||||
|
|
||||||
HttpRequestHandle httpRequest = new HttpRequest();
|
HttpRequestHandle httpRequest = new HttpRequest();
|
||||||
|
httpRequest->setUserAgent(e->option->get(PREF_USER_AGENT));
|
||||||
httpRequest->setRequest(req);
|
httpRequest->setRequest(req);
|
||||||
httpRequest->configure(e->option);
|
httpRequest->configure(e->option);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool DefaultPeerStorage::addPeer(const PeerHandle& peer) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
const PeerHandle& peer = *itr;
|
const PeerHandle& peer = *itr;
|
||||||
if(peer->error >= MAX_PEER_ERROR || peer->cuid != 0) {
|
if(!peer->isGood() || peer->cuid != 0) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
*itr = peer;
|
*itr = peer;
|
||||||
|
@ -87,7 +87,7 @@ const Peers& DefaultPeerStorage::getPeers() {
|
||||||
class FindFinePeer {
|
class FindFinePeer {
|
||||||
public:
|
public:
|
||||||
bool operator()(const PeerHandle& peer) const {
|
bool operator()(const PeerHandle& peer) const {
|
||||||
return peer->cuid == 0 && peer->error < MAX_PEER_ERROR;
|
return peer->cuid == 0 && peer->isGood();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ bool HttpRequest::isRangeSatisfied(const RangeHandle& range) const
|
||||||
|
|
||||||
string HttpRequest::getHostText(const string& host, in_port_t port) const
|
string HttpRequest::getHostText(const string& host, in_port_t port) const
|
||||||
{
|
{
|
||||||
return host+(port == 80 || port == 443 ? "" : ":"+Util::itos(port));
|
return host+":"+Util::itos(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
string HttpRequest::createRequest() const
|
string HttpRequest::createRequest() const
|
||||||
|
|
|
@ -52,6 +52,12 @@ public:
|
||||||
{
|
{
|
||||||
_netrc = netrc;
|
_netrc = netrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetrcHandle getNetrc() const
|
||||||
|
{
|
||||||
|
return _netrc;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<NetrcAuthResolver> NetrcAuthResolverHandle;
|
typedef SharedHandle<NetrcAuthResolver> NetrcAuthResolverHandle;
|
||||||
|
|
|
@ -89,6 +89,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
V_NONE, V_PREALLOC));
|
V_NONE, V_PREALLOC));
|
||||||
handlers.push_back(new BooleanOptionHandler(PREF_CONTINUE));
|
handlers.push_back(new BooleanOptionHandler(PREF_CONTINUE));
|
||||||
handlers.push_back(new DefaultOptionHandler(PREF_USER_AGENT));
|
handlers.push_back(new DefaultOptionHandler(PREF_USER_AGENT));
|
||||||
|
handlers.push_back(new BooleanOptionHandler(PREF_NO_NETRC));
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
15
src/Peer.cc
15
src/Peer.cc
|
@ -39,11 +39,12 @@
|
||||||
Peer::Peer(string ipaddr, int port, int pieceLength, long long int totalLength):
|
Peer::Peer(string ipaddr, int port, int pieceLength, long long int totalLength):
|
||||||
ipaddr(ipaddr),
|
ipaddr(ipaddr),
|
||||||
port(port),
|
port(port),
|
||||||
error(0),
|
|
||||||
sessionUploadLength(0),
|
sessionUploadLength(0),
|
||||||
sessionDownloadLength(0),
|
sessionDownloadLength(0),
|
||||||
pieceLength(pieceLength),
|
pieceLength(pieceLength),
|
||||||
active(false)
|
active(false),
|
||||||
|
_badConditionStartTime(0),
|
||||||
|
_badConditionInterval(10)
|
||||||
{
|
{
|
||||||
resetStatus();
|
resetStatus();
|
||||||
this->bitfield = BitfieldManFactory::getFactoryInstance()->
|
this->bitfield = BitfieldManFactory::getFactoryInstance()->
|
||||||
|
@ -143,3 +144,13 @@ void Peer::setAllBitfield() {
|
||||||
void Peer::updateLatency(int latency) {
|
void Peer::updateLatency(int latency) {
|
||||||
this->latency = (this->latency*20+latency*80)/200;
|
this->latency = (this->latency*20+latency*80)/200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Peer::startBadCondition()
|
||||||
|
{
|
||||||
|
_badConditionStartTime.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Peer::isGood() const
|
||||||
|
{
|
||||||
|
return _badConditionStartTime.elapsed(_badConditionInterval);
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "BitfieldMan.h"
|
#include "BitfieldMan.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "PeerStat.h"
|
#include "PeerStat.h"
|
||||||
|
#include "TimeA2.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -58,7 +59,6 @@ public:
|
||||||
bool peerChoking;
|
bool peerChoking;
|
||||||
bool peerInterested;
|
bool peerInterested;
|
||||||
int tryCount;
|
int tryCount;
|
||||||
int error;
|
|
||||||
int cuid;
|
int cuid;
|
||||||
bool chokingRequired;
|
bool chokingRequired;
|
||||||
bool optUnchoking;
|
bool optUnchoking;
|
||||||
|
@ -80,6 +80,8 @@ private:
|
||||||
int latency;
|
int latency;
|
||||||
bool active;
|
bool active;
|
||||||
string id;
|
string id;
|
||||||
|
Time _badConditionStartTime;
|
||||||
|
int _badConditionInterval;
|
||||||
public:
|
public:
|
||||||
Peer(string ipaddr, int port, int pieceLength, long long int totalLength);
|
Peer(string ipaddr, int port, int pieceLength, long long int totalLength);
|
||||||
|
|
||||||
|
@ -196,6 +198,10 @@ public:
|
||||||
const string& getId() const {
|
const string& getId() const {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startBadCondition();
|
||||||
|
|
||||||
|
bool isGood() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<Peer> PeerHandle;
|
typedef SharedHandle<Peer> PeerHandle;
|
||||||
|
|
|
@ -97,11 +97,7 @@ bool PeerAbstractCommand::prepareForRetry(int wait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerAbstractCommand::onAbort(RecoverableException* ex) {
|
void PeerAbstractCommand::onAbort(RecoverableException* ex) {
|
||||||
if(peer->isSeeder()) {
|
peer->startBadCondition();
|
||||||
peer->error++;
|
|
||||||
} else {
|
|
||||||
peer->error += MAX_PEER_ERROR;
|
|
||||||
}
|
|
||||||
peer->resetStatus();
|
peer->resetStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "RequestFactory.h"
|
#include "RequestFactory.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
#include "AbstractAuthResolver.h"
|
||||||
#include "NetrcAuthResolver.h"
|
#include "NetrcAuthResolver.h"
|
||||||
|
#include "DefaultAuthResolver.h"
|
||||||
|
|
||||||
RequestHandle RequestFactory::createRequest()
|
RequestHandle RequestFactory::createRequest()
|
||||||
{
|
{
|
||||||
|
@ -58,29 +60,43 @@ AuthConfigHandle RequestFactory::createAuthConfig(const string& user, const stri
|
||||||
|
|
||||||
AuthResolverHandle RequestFactory::createHttpAuthResolver()
|
AuthResolverHandle RequestFactory::createHttpAuthResolver()
|
||||||
{
|
{
|
||||||
NetrcAuthResolverHandle authResolver = 0;
|
AbstractAuthResolverHandle resolver = 0;
|
||||||
authResolver = new NetrcAuthResolver();
|
if(true || _option->getAsBool(PREF_NO_NETRC)) {
|
||||||
|
resolver = new DefaultAuthResolver();
|
||||||
|
} else {
|
||||||
|
NetrcAuthResolverHandle authResolver = new NetrcAuthResolver();
|
||||||
authResolver->setNetrc(_netrc);
|
authResolver->setNetrc(_netrc);
|
||||||
authResolver->setUserDefinedAuthConfig(createAuthConfig(_option->get(PREF_HTTP_USER), _option->get(PREF_HTTP_PASSWD)));
|
resolver = authResolver;
|
||||||
return authResolver;
|
}
|
||||||
|
resolver->setUserDefinedAuthConfig(createAuthConfig(_option->get(PREF_HTTP_USER), _option->get(PREF_HTTP_PASSWD)));
|
||||||
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthResolverHandle RequestFactory::createFtpAuthResolver()
|
AuthResolverHandle RequestFactory::createFtpAuthResolver()
|
||||||
{
|
{
|
||||||
NetrcAuthResolverHandle authResolver = 0;
|
AbstractAuthResolverHandle resolver = 0;
|
||||||
authResolver = new NetrcAuthResolver();
|
if(_option->getAsBool(PREF_NO_NETRC)) {
|
||||||
|
resolver = new DefaultAuthResolver();
|
||||||
|
} else {
|
||||||
|
NetrcAuthResolverHandle authResolver = new NetrcAuthResolver();
|
||||||
authResolver->setNetrc(_netrc);
|
authResolver->setNetrc(_netrc);
|
||||||
authResolver->setUserDefinedAuthConfig(createAuthConfig(_option->get(PREF_FTP_USER), _option->get(PREF_FTP_PASSWD)));
|
resolver = authResolver;
|
||||||
authResolver->setDefaultAuthConfig(new AuthConfig("anonymous",
|
}
|
||||||
"ARIA2USER@"));
|
resolver->setUserDefinedAuthConfig(createAuthConfig(_option->get(PREF_FTP_USER), _option->get(PREF_FTP_PASSWD)));
|
||||||
return authResolver;
|
resolver->setDefaultAuthConfig(new AuthConfig("anonymous", "ARIA2USER@"));
|
||||||
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthResolverHandle RequestFactory::createHttpProxyAuthResolver()
|
AuthResolverHandle RequestFactory::createHttpProxyAuthResolver()
|
||||||
{
|
{
|
||||||
NetrcAuthResolverHandle authResolver = 0;
|
AbstractAuthResolverHandle resolver = 0;
|
||||||
authResolver = new NetrcAuthResolver();
|
if(true || _option->getAsBool(PREF_NO_NETRC)) {
|
||||||
|
resolver = new DefaultAuthResolver();
|
||||||
|
} else {
|
||||||
|
NetrcAuthResolverHandle authResolver = new NetrcAuthResolver();
|
||||||
authResolver->setNetrc(_netrc);
|
authResolver->setNetrc(_netrc);
|
||||||
authResolver->setUserDefinedAuthConfig(createAuthConfig(_option->get(PREF_HTTP_PROXY_USER), _option->get(PREF_HTTP_PROXY_PASSWD)));
|
resolver = authResolver;
|
||||||
return authResolver;
|
}
|
||||||
|
resolver->setUserDefinedAuthConfig(createAuthConfig(_option->get(PREF_HTTP_PROXY_USER), _option->get(PREF_HTTP_PROXY_PASSWD)));
|
||||||
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,10 @@ Time::Time(const Time& time) {
|
||||||
tv = time.tv;
|
tv = time.tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Time::Time(int sec) {
|
||||||
|
setTimeInSec(sec);
|
||||||
|
}
|
||||||
|
|
||||||
Time::~Time() {}
|
Time::~Time() {}
|
||||||
|
|
||||||
void Time::reset() {
|
void Time::reset() {
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
// this object was created.
|
// this object was created.
|
||||||
Time();
|
Time();
|
||||||
Time(const Time& time);
|
Time(const Time& time);
|
||||||
|
Time(int sec);
|
||||||
|
|
||||||
Time& operator=(const Time& time) {
|
Time& operator=(const Time& time) {
|
||||||
if(this != &time) {
|
if(this != &time) {
|
||||||
|
|
|
@ -189,9 +189,9 @@ RequestInfos UrlRequestInfo::execute() {
|
||||||
|
|
||||||
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
||||||
|
|
||||||
|
if(hr->totalLength > 0) {
|
||||||
e->segmentMan->filename = hr->filename;
|
e->segmentMan->filename = hr->filename;
|
||||||
e->segmentMan->totalSize = hr->totalLength;
|
e->segmentMan->totalSize = hr->totalLength;
|
||||||
if(hr->totalLength > 0) {
|
|
||||||
e->segmentMan->downloadStarted = true;
|
e->segmentMan->downloadStarted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,7 @@ void showUsage() {
|
||||||
" Currently this option is applicable to http(s)/\n"
|
" Currently this option is applicable to http(s)/\n"
|
||||||
" ftp downloads.") << endl;
|
" ftp downloads.") << endl;
|
||||||
cout << _(" -U, --user-agent=USER_AGENT Set user agent for http(s) downloads.") << endl;
|
cout << _(" -U, --user-agent=USER_AGENT Set user agent for http(s) downloads.") << endl;
|
||||||
|
cout << _(" -n, --no-netrc Disables netrc support.") << endl;
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
cout << _(" -T, --torrent-file=TORRENT_FILE The file path to .torrent file.") << endl;
|
cout << _(" -T, --torrent-file=TORRENT_FILE The file path to .torrent file.") << endl;
|
||||||
cout << _(" --follow-torrent=true|false Setting this option to false prevents aria2 to\n"
|
cout << _(" --follow-torrent=true|false Setting this option to false prevents aria2 to\n"
|
||||||
|
@ -352,6 +353,7 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_NETRC_PATH, Util::getHomeDir()+"/.netrc");
|
op->put(PREF_NETRC_PATH, Util::getHomeDir()+"/.netrc");
|
||||||
op->put(PREF_CONTINUE, V_FALSE);
|
op->put(PREF_CONTINUE, V_FALSE);
|
||||||
op->put(PREF_USER_AGENT, "aria2");
|
op->put(PREF_USER_AGENT, "aria2");
|
||||||
|
op->put(PREF_NO_NETRC, V_FALSE);
|
||||||
while(1) {
|
while(1) {
|
||||||
int optIndex = 0;
|
int optIndex = 0;
|
||||||
int lopt;
|
int lopt;
|
||||||
|
@ -386,6 +388,7 @@ int main(int argc, char* argv[]) {
|
||||||
{ "realtime-chunk-checksum", required_argument, &lopt, 204 },
|
{ "realtime-chunk-checksum", required_argument, &lopt, 204 },
|
||||||
{ "continue", no_argument, 0, 'c' },
|
{ "continue", no_argument, 0, 'c' },
|
||||||
{ "user-agent", required_argument, 0, 'U' },
|
{ "user-agent", required_argument, 0, 'U' },
|
||||||
|
{ "no-netrc", no_argument, 0, 'n' },
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
{ "torrent-file", required_argument, NULL, 'T' },
|
{ "torrent-file", required_argument, NULL, 'T' },
|
||||||
{ "listen-port", required_argument, &lopt, 15 },
|
{ "listen-port", required_argument, &lopt, 15 },
|
||||||
|
@ -413,7 +416,7 @@ int main(int argc, char* argv[]) {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
c = getopt_long(argc, argv, "Dd:o:l:s:pt:m:vhST:M:C:a:c", longOpts, &optIndex);
|
c = getopt_long(argc, argv, "Dd:o:l:s:pt:m:vhST:M:C:a:cU:n", longOpts, &optIndex);
|
||||||
if(c == -1) {
|
if(c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -564,6 +567,9 @@ int main(int argc, char* argv[]) {
|
||||||
case 'U':
|
case 'U':
|
||||||
cmdstream << PREF_USER_AGENT << "=" << optarg << "\n";
|
cmdstream << PREF_USER_AGENT << "=" << optarg << "\n";
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
cmdstream << PREF_NO_NETRC << "=" << V_TRUE << "\n";
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
showVersion();
|
showVersion();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
|
@ -94,6 +94,8 @@
|
||||||
#define PREF_NETRC_PATH "netrc-path"
|
#define PREF_NETRC_PATH "netrc-path"
|
||||||
// value:
|
// value:
|
||||||
#define PREF_CONTINUE "continue"
|
#define PREF_CONTINUE "continue"
|
||||||
|
// value:
|
||||||
|
#define PREF_NO_NETRC "no-netrc"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* FTP related preferences
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include "DefaultAuthResolver.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class DefaultAuthResolverTest : public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(DefaultAuthResolverTest);
|
||||||
|
CPPUNIT_TEST(testResolveAuthConfig_without_userDefined);
|
||||||
|
CPPUNIT_TEST(testResolveAuthConfig_with_userDefined);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
private:
|
||||||
|
//NetrcHandle _netrc;
|
||||||
|
//SharedHandle<Option> _option;
|
||||||
|
DefaultAuthResolverHandle _resolver;
|
||||||
|
public:
|
||||||
|
void setUp()
|
||||||
|
{
|
||||||
|
//_netrc = new Netrc();
|
||||||
|
//_option = new Option();
|
||||||
|
_resolver = new DefaultAuthResolver();
|
||||||
|
//_factory->setOption(_option.get());
|
||||||
|
_resolver->setDefaultAuthConfig(new AuthConfig("foo", "bar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testResolveAuthConfig_without_userDefined();
|
||||||
|
void testResolveAuthConfig_with_userDefined();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( DefaultAuthResolverTest );
|
||||||
|
|
||||||
|
void DefaultAuthResolverTest::testResolveAuthConfig_without_userDefined()
|
||||||
|
{
|
||||||
|
AuthConfigHandle authConfig = _resolver->resolveAuthConfig("localhost");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("foo:bar"), authConfig->getAuthText());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultAuthResolverTest::testResolveAuthConfig_with_userDefined()
|
||||||
|
{
|
||||||
|
_resolver->setUserDefinedAuthConfig(new AuthConfig("myname", "mypasswd"));
|
||||||
|
AuthConfigHandle authConfig = _resolver->resolveAuthConfig("localhost");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("myname:mypasswd"), authConfig->getAuthText());
|
||||||
|
}
|
|
@ -335,7 +335,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: localhost\r\n"
|
"Host: localhost:80\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;\r\n"
|
"Cookie: name1=value1;\r\n"
|
||||||
|
@ -348,7 +348,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: localhost\r\n"
|
"Host: localhost:80\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;name2=value2;\r\n"
|
"Cookie: name1=value1;name2=value2;\r\n"
|
||||||
|
@ -361,7 +361,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: tt.localhost\r\n"
|
"Host: tt.localhost:80\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;name2=value2;name3=value3;\r\n"
|
"Cookie: name1=value1;name2=value2;name3=value3;\r\n"
|
||||||
|
@ -374,7 +374,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Host: tt.localhost\r\n"
|
"Host: tt.localhost:443\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache\r\n"
|
"Cache-Control: no-cache\r\n"
|
||||||
"Cookie: name1=value1;name2=value2;name3=value3;name4=value4;\r\n"
|
"Cookie: name1=value1;name2=value2;name3=value3;name4=value4;\r\n"
|
||||||
|
@ -387,7 +387,7 @@ void HttpRequestTest::testCreateRequest_with_cookie()
|
||||||
void HttpRequestTest::testCreateProxyRequest()
|
void HttpRequestTest::testCreateProxyRequest()
|
||||||
{
|
{
|
||||||
RequestHandle request = new Request();
|
RequestHandle request = new Request();
|
||||||
request->setUrl("http://localhost:8080/archives/aria2-1.0.0.tar.bz2");
|
request->setUrl("http://localhost/archives/aria2-1.0.0.tar.bz2");
|
||||||
SegmentHandle segment = new Segment();
|
SegmentHandle segment = new Segment();
|
||||||
|
|
||||||
HttpRequest httpRequest;
|
HttpRequest httpRequest;
|
||||||
|
@ -395,10 +395,10 @@ void HttpRequestTest::testCreateProxyRequest()
|
||||||
httpRequest.setRequest(request);
|
httpRequest.setRequest(request);
|
||||||
httpRequest.setSegment(segment);
|
httpRequest.setSegment(segment);
|
||||||
|
|
||||||
string expectedText = "CONNECT localhost:8080 HTTP/1.1\r\n"
|
string expectedText = "CONNECT localhost:80 HTTP/1.1\r\n"
|
||||||
"User-Agent: aria2\r\n"
|
"User-Agent: aria2\r\n"
|
||||||
"Proxy-Connection: close\r\n"
|
"Proxy-Connection: close\r\n"
|
||||||
"Host: localhost:8080\r\n"
|
"Host: localhost:80\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createProxyRequest());
|
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createProxyRequest());
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
TESTS = aria2c
|
TESTS = aria2c
|
||||||
check_PROGRAMS = $(TESTS)
|
check_PROGRAMS = $(TESTS)
|
||||||
aria2c_SOURCES = AllTest.cc\
|
aria2c_SOURCES = AllTest.cc\
|
||||||
|
RequestFactoryTest.cc\
|
||||||
|
NetrcAuthResolverTest.cc\
|
||||||
|
DefaultAuthResolverTest.cc\
|
||||||
|
RequestTest.cc\
|
||||||
|
HttpRequestTest.cc
|
||||||
UtilTest.cc\
|
UtilTest.cc\
|
||||||
OptionHandlerTest.cc\
|
OptionHandlerTest.cc\
|
||||||
SegmentManTest.cc\
|
SegmentManTest.cc\
|
||||||
BitfieldManTest.cc\
|
BitfieldManTest.cc\
|
||||||
GlowFileAllocatorTest.cc\
|
GlowFileAllocatorTest.cc\
|
||||||
RequestTest.cc\
|
|
||||||
HttpRequestTest.cc\
|
|
||||||
NetrcTest.cc\
|
NetrcTest.cc\
|
||||||
SingletonHolderTest.cc\
|
SingletonHolderTest.cc\
|
||||||
HttpHeaderTest.cc\
|
HttpHeaderTest.cc\
|
||||||
|
|
244
test/Makefile.in
244
test/Makefile.in
|
@ -57,45 +57,7 @@ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||||
CONFIG_HEADER = $(top_builddir)/config.h
|
CONFIG_HEADER = $(top_builddir)/config.h
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES =
|
||||||
am__EXEEXT_1 = aria2c$(EXEEXT)
|
am__EXEEXT_1 = aria2c$(EXEEXT)
|
||||||
am_aria2c_OBJECTS = AllTest.$(OBJEXT) UtilTest.$(OBJEXT) \
|
am_aria2c_OBJECTS = AllTest.$(OBJEXT) RequestFactoryTest.$(OBJEXT)
|
||||||
OptionHandlerTest.$(OBJEXT) SegmentManTest.$(OBJEXT) \
|
|
||||||
BitfieldManTest.$(OBJEXT) GlowFileAllocatorTest.$(OBJEXT) \
|
|
||||||
RequestTest.$(OBJEXT) HttpRequestTest.$(OBJEXT) \
|
|
||||||
NetrcTest.$(OBJEXT) SingletonHolderTest.$(OBJEXT) \
|
|
||||||
HttpHeaderTest.$(OBJEXT) HttpResponseTest.$(OBJEXT) \
|
|
||||||
SharedHandleTest.$(OBJEXT) ChunkedEncodingTest.$(OBJEXT) \
|
|
||||||
FileTest.$(OBJEXT) OptionTest.$(OBJEXT) Base64Test.$(OBJEXT) \
|
|
||||||
CookieBoxTest.$(OBJEXT) DataTest.$(OBJEXT) \
|
|
||||||
DictionaryTest.$(OBJEXT) ListTest.$(OBJEXT) \
|
|
||||||
MetaFileUtilTest.$(OBJEXT) ShaVisitorTest.$(OBJEXT) \
|
|
||||||
PeerMessageUtilTest.$(OBJEXT) DefaultDiskWriterTest.$(OBJEXT) \
|
|
||||||
MultiDiskAdaptorTest.$(OBJEXT) \
|
|
||||||
Xml2MetalinkProcessorTest.$(OBJEXT) MetalinkerTest.$(OBJEXT) \
|
|
||||||
MetalinkEntryTest.$(OBJEXT) FeatureConfigTest.$(OBJEXT) \
|
|
||||||
ShareRatioSeedCriteriaTest.$(OBJEXT) \
|
|
||||||
TimeSeedCriteriaTest.$(OBJEXT) SpeedCalcTest.$(OBJEXT) \
|
|
||||||
DefaultPeerListProcessorTest.$(OBJEXT) \
|
|
||||||
AnnounceListTest.$(OBJEXT) TrackerWatcherCommandTest.$(OBJEXT) \
|
|
||||||
DefaultBtContextTest.$(OBJEXT) \
|
|
||||||
DefaultPieceStorageTest.$(OBJEXT) \
|
|
||||||
DefaultPeerStorageTest.$(OBJEXT) \
|
|
||||||
DefaultBtAnnounceTest.$(OBJEXT) BtRegistryTest.$(OBJEXT) \
|
|
||||||
DefaultBtMessageDispatcherTest.$(OBJEXT) \
|
|
||||||
DefaultBtRequestFactoryTest.$(OBJEXT) PeerTest.$(OBJEXT) \
|
|
||||||
BtAllowedFastMessageTest.$(OBJEXT) \
|
|
||||||
BtBitfieldMessageTest.$(OBJEXT) BtCancelMessageTest.$(OBJEXT) \
|
|
||||||
BtChokeMessageTest.$(OBJEXT) BtHaveAllMessageTest.$(OBJEXT) \
|
|
||||||
BtHaveMessageTest.$(OBJEXT) BtHaveNoneMessageTest.$(OBJEXT) \
|
|
||||||
BtInterestedMessageTest.$(OBJEXT) \
|
|
||||||
BtKeepAliveMessageTest.$(OBJEXT) \
|
|
||||||
BtNotInterestedMessageTest.$(OBJEXT) \
|
|
||||||
BtPieceMessageTest.$(OBJEXT) BtPortMessageTest.$(OBJEXT) \
|
|
||||||
BtRejectMessageTest.$(OBJEXT) BtRequestMessageTest.$(OBJEXT) \
|
|
||||||
BtSuggestPieceMessageTest.$(OBJEXT) \
|
|
||||||
BtUnchokeMessageTest.$(OBJEXT) \
|
|
||||||
BtHandshakeMessageTest.$(OBJEXT) \
|
|
||||||
ConsoleFileAllocationMonitorTest.$(OBJEXT) \
|
|
||||||
ChunkChecksumValidatorTest.$(OBJEXT)
|
|
||||||
aria2c_OBJECTS = $(am_aria2c_OBJECTS)
|
aria2c_OBJECTS = $(am_aria2c_OBJECTS)
|
||||||
am__DEPENDENCIES_1 =
|
am__DEPENDENCIES_1 =
|
||||||
aria2c_DEPENDENCIES = ../src/libaria2c.a $(am__DEPENDENCIES_1)
|
aria2c_DEPENDENCIES = ../src/libaria2c.a $(am__DEPENDENCIES_1)
|
||||||
|
@ -107,10 +69,6 @@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||||
CXXLD = $(CXX)
|
CXXLD = $(CXX)
|
||||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
||||||
-o $@
|
-o $@
|
||||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
|
||||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
|
||||||
CCLD = $(CC)
|
|
||||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
|
||||||
SOURCES = $(aria2c_SOURCES)
|
SOURCES = $(aria2c_SOURCES)
|
||||||
DIST_SOURCES = $(aria2c_SOURCES)
|
DIST_SOURCES = $(aria2c_SOURCES)
|
||||||
ETAGS = etags
|
ETAGS = etags
|
||||||
|
@ -260,74 +218,77 @@ sysconfdir = @sysconfdir@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
TESTS = aria2c
|
TESTS = aria2c
|
||||||
aria2c_SOURCES = AllTest.cc\
|
aria2c_SOURCES = AllTest.cc\
|
||||||
UtilTest.cc\
|
RequestFactoryTest.cc
|
||||||
OptionHandlerTest.cc\
|
|
||||||
SegmentManTest.cc\
|
|
||||||
BitfieldManTest.cc\
|
|
||||||
GlowFileAllocatorTest.cc\
|
|
||||||
RequestTest.cc\
|
|
||||||
HttpRequestTest.cc\
|
|
||||||
NetrcTest.cc\
|
|
||||||
SingletonHolderTest.cc\
|
|
||||||
HttpHeaderTest.cc\
|
|
||||||
HttpResponseTest.cc\
|
|
||||||
SharedHandleTest.cc\
|
|
||||||
ChunkedEncodingTest.cc\
|
|
||||||
FileTest.cc\
|
|
||||||
OptionTest.cc\
|
|
||||||
Base64Test.cc\
|
|
||||||
CookieBoxTest.cc\
|
|
||||||
DataTest.cc\
|
|
||||||
DictionaryTest.cc\
|
|
||||||
ListTest.cc\
|
|
||||||
MetaFileUtilTest.cc\
|
|
||||||
ShaVisitorTest.cc\
|
|
||||||
PeerMessageUtilTest.cc\
|
|
||||||
DefaultDiskWriterTest.cc\
|
|
||||||
MultiDiskAdaptorTest.cc\
|
|
||||||
Xml2MetalinkProcessorTest.cc\
|
|
||||||
MetalinkerTest.cc\
|
|
||||||
MetalinkEntryTest.cc\
|
|
||||||
FeatureConfigTest.cc\
|
|
||||||
ShareRatioSeedCriteriaTest.cc\
|
|
||||||
TimeSeedCriteriaTest.cc\
|
|
||||||
SpeedCalcTest.cc\
|
|
||||||
DefaultPeerListProcessorTest.cc\
|
|
||||||
AnnounceListTest.cc\
|
|
||||||
TrackerWatcherCommandTest.cc\
|
|
||||||
DefaultBtContextTest.cc\
|
|
||||||
DefaultPieceStorageTest.cc\
|
|
||||||
DefaultPeerStorageTest.cc\
|
|
||||||
DefaultBtAnnounceTest.cc\
|
|
||||||
BtRegistryTest.cc\
|
|
||||||
DefaultBtMessageDispatcherTest.cc\
|
|
||||||
MockPeerStorage.h\
|
|
||||||
DefaultBtRequestFactoryTest.cc\
|
|
||||||
PeerTest.cc\
|
|
||||||
BtAllowedFastMessageTest.cc\
|
|
||||||
BtBitfieldMessageTest.cc\
|
|
||||||
BtCancelMessageTest.cc\
|
|
||||||
BtChokeMessageTest.cc\
|
|
||||||
BtHaveAllMessageTest.cc\
|
|
||||||
BtHaveMessageTest.cc\
|
|
||||||
BtHaveNoneMessageTest.cc\
|
|
||||||
BtInterestedMessageTest.cc\
|
|
||||||
BtKeepAliveMessageTest.cc\
|
|
||||||
BtNotInterestedMessageTest.cc\
|
|
||||||
BtPieceMessageTest.cc\
|
|
||||||
BtPortMessageTest.cc\
|
|
||||||
BtRejectMessageTest.cc\
|
|
||||||
BtRequestMessageTest.cc\
|
|
||||||
BtSuggestPieceMessageTest.cc\
|
|
||||||
BtUnchokeMessageTest.cc\
|
|
||||||
BtHandshakeMessageTest.cc\
|
|
||||||
MockBtMessageDispatcher.h\
|
|
||||||
FixedNumberRandomizer.h\
|
|
||||||
MockBtMessageFactory.h\
|
|
||||||
MockBtMessage.h\
|
|
||||||
ConsoleFileAllocationMonitorTest.cc\
|
|
||||||
ChunkChecksumValidatorTest.cc
|
|
||||||
|
|
||||||
|
# NetrcAuthResolverTest.cc\
|
||||||
|
# DefaultAuthResolverTest.cc\
|
||||||
|
# RequestTest.cc\
|
||||||
|
# HttpRequestTest.cc
|
||||||
|
# UtilTest.cc\
|
||||||
|
# OptionHandlerTest.cc\
|
||||||
|
# SegmentManTest.cc\
|
||||||
|
# BitfieldManTest.cc\
|
||||||
|
# GlowFileAllocatorTest.cc\
|
||||||
|
# NetrcTest.cc\
|
||||||
|
# SingletonHolderTest.cc\
|
||||||
|
# HttpHeaderTest.cc\
|
||||||
|
# HttpResponseTest.cc\
|
||||||
|
# SharedHandleTest.cc\
|
||||||
|
# ChunkedEncodingTest.cc\
|
||||||
|
# FileTest.cc\
|
||||||
|
# OptionTest.cc\
|
||||||
|
# Base64Test.cc\
|
||||||
|
# CookieBoxTest.cc\
|
||||||
|
# DataTest.cc\
|
||||||
|
# DictionaryTest.cc\
|
||||||
|
# ListTest.cc\
|
||||||
|
# MetaFileUtilTest.cc\
|
||||||
|
# ShaVisitorTest.cc\
|
||||||
|
# PeerMessageUtilTest.cc\
|
||||||
|
# DefaultDiskWriterTest.cc\
|
||||||
|
# MultiDiskAdaptorTest.cc\
|
||||||
|
# Xml2MetalinkProcessorTest.cc\
|
||||||
|
# MetalinkerTest.cc\
|
||||||
|
# MetalinkEntryTest.cc\
|
||||||
|
# FeatureConfigTest.cc\
|
||||||
|
# ShareRatioSeedCriteriaTest.cc\
|
||||||
|
# TimeSeedCriteriaTest.cc\
|
||||||
|
# SpeedCalcTest.cc\
|
||||||
|
# DefaultPeerListProcessorTest.cc\
|
||||||
|
# AnnounceListTest.cc\
|
||||||
|
# TrackerWatcherCommandTest.cc\
|
||||||
|
# DefaultBtContextTest.cc\
|
||||||
|
# DefaultPieceStorageTest.cc\
|
||||||
|
# DefaultPeerStorageTest.cc\
|
||||||
|
# DefaultBtAnnounceTest.cc\
|
||||||
|
# BtRegistryTest.cc\
|
||||||
|
# DefaultBtMessageDispatcherTest.cc\
|
||||||
|
# MockPeerStorage.h\
|
||||||
|
# DefaultBtRequestFactoryTest.cc\
|
||||||
|
# PeerTest.cc\
|
||||||
|
# BtAllowedFastMessageTest.cc\
|
||||||
|
# BtBitfieldMessageTest.cc\
|
||||||
|
# BtCancelMessageTest.cc\
|
||||||
|
# BtChokeMessageTest.cc\
|
||||||
|
# BtHaveAllMessageTest.cc\
|
||||||
|
# BtHaveMessageTest.cc\
|
||||||
|
# BtHaveNoneMessageTest.cc\
|
||||||
|
# BtInterestedMessageTest.cc\
|
||||||
|
# BtKeepAliveMessageTest.cc\
|
||||||
|
# BtNotInterestedMessageTest.cc\
|
||||||
|
# BtPieceMessageTest.cc\
|
||||||
|
# BtPortMessageTest.cc\
|
||||||
|
# BtRejectMessageTest.cc\
|
||||||
|
# BtRequestMessageTest.cc\
|
||||||
|
# BtSuggestPieceMessageTest.cc\
|
||||||
|
# BtUnchokeMessageTest.cc\
|
||||||
|
# BtHandshakeMessageTest.cc\
|
||||||
|
# MockBtMessageDispatcher.h\
|
||||||
|
# FixedNumberRandomizer.h\
|
||||||
|
# MockBtMessageFactory.h\
|
||||||
|
# MockBtMessage.h\
|
||||||
|
# ConsoleFileAllocationMonitorTest.cc\
|
||||||
|
# ChunkChecksumValidatorTest.cc
|
||||||
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
||||||
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
||||||
aria2c_LDADD = ../src/libaria2c.a\
|
aria2c_LDADD = ../src/libaria2c.a\
|
||||||
|
@ -390,68 +351,7 @@ distclean-compile:
|
||||||
-rm -f *.tab.c
|
-rm -f *.tab.c
|
||||||
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllTest.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AnnounceListTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactoryTest.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@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtBitfieldMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtCancelMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtChokeMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHandshakeMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHaveAllMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHaveMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHaveNoneMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtInterestedMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtKeepAliveMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtNotInterestedMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtPieceMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtPortMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRegistryTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRejectMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRequestMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtSuggestPieceMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtUnchokeMessageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkChecksumValidatorTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkedEncodingTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConsoleFileAllocationMonitorTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieBoxTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DataTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtAnnounceTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtContextTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtMessageDispatcherTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtRequestFactoryTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultDiskWriterTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultPeerListProcessorTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultPeerStorageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultPieceStorageTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DictionaryTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FeatureConfigTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GlowFileAllocatorTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpHeaderTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpRequestTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpResponseTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ListTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetaFileUtilTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkEntryTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkerTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultiDiskAdaptorTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NetrcTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OptionHandlerTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OptionTest.Po@am__quote@
|
|
||||||
@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)/RequestTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentManTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ShaVisitorTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ShareRatioSeedCriteriaTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SharedHandleTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SingletonHolderTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SpeedCalcTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeSeedCriteriaTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerWatcherCommandTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UtilTest.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2MetalinkProcessorTest.Po@am__quote@
|
|
||||||
|
|
||||||
.cc.o:
|
.cc.o:
|
||||||
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include "NetrcAuthResolver.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class NetrcAuthResolverTest : public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(NetrcAuthResolverTest);
|
||||||
|
CPPUNIT_TEST(testResolveAuthConfig_without_userDefined);
|
||||||
|
CPPUNIT_TEST(testResolveAuthConfig_with_userDefined);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
private:
|
||||||
|
NetrcHandle _netrc;
|
||||||
|
//SharedHandle<Option> _option;
|
||||||
|
NetrcAuthResolverHandle _resolver;
|
||||||
|
public:
|
||||||
|
void setUp()
|
||||||
|
{
|
||||||
|
_netrc = new Netrc();
|
||||||
|
_netrc->addAuthenticator(new Authenticator("localhost", "name", "passwd", "account"));
|
||||||
|
_netrc->addAuthenticator(new DefaultAuthenticator("default", "defaultpasswd", "defaultaccount"));
|
||||||
|
|
||||||
|
//_option = new Option();
|
||||||
|
_resolver = new NetrcAuthResolver();
|
||||||
|
_resolver->setNetrc(_netrc);
|
||||||
|
_resolver->setDefaultAuthConfig(new AuthConfig("foo", "bar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testResolveAuthConfig_without_userDefined();
|
||||||
|
void testResolveAuthConfig_with_userDefined();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( NetrcAuthResolverTest );
|
||||||
|
|
||||||
|
void NetrcAuthResolverTest::testResolveAuthConfig_without_userDefined()
|
||||||
|
{
|
||||||
|
AuthConfigHandle authConfig = _resolver->resolveAuthConfig("localhost");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("name:passwd"), authConfig->getAuthText());
|
||||||
|
|
||||||
|
authConfig = _resolver->resolveAuthConfig("mymachine");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("default:defaultpasswd"), authConfig->getAuthText());
|
||||||
|
|
||||||
|
_resolver->setNetrc(0);
|
||||||
|
authConfig = _resolver->resolveAuthConfig("localhost");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("foo:bar"), authConfig->getAuthText());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetrcAuthResolverTest::testResolveAuthConfig_with_userDefined()
|
||||||
|
{
|
||||||
|
_resolver->setUserDefinedAuthConfig(new AuthConfig("myname", "mypasswd"));
|
||||||
|
AuthConfigHandle authConfig = _resolver->resolveAuthConfig("localhost");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("myname:mypasswd"), authConfig->getAuthText());
|
||||||
|
|
||||||
|
authConfig = _resolver->resolveAuthConfig("mymachine");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("myname:mypasswd"), authConfig->getAuthText());
|
||||||
|
|
||||||
|
_resolver->setNetrc(0);
|
||||||
|
authConfig = _resolver->resolveAuthConfig("mymachine");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("myname:mypasswd"), authConfig->getAuthText());
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
#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());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue