2007-03-27 16:16:44 +00:00
|
|
|
#include "DefaultAuthResolver.h"
|
|
|
|
#include "prefs.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "AuthConfig.h"
|
2007-03-27 16:16:44 +00:00
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
2007-03-27 16:16:44 +00:00
|
|
|
|
|
|
|
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;
|
2010-06-21 13:51:56 +00:00
|
|
|
SharedHandle<DefaultAuthResolver> resolver_;
|
2007-03-27 16:16:44 +00:00
|
|
|
public:
|
|
|
|
void setUp()
|
|
|
|
{
|
|
|
|
//_netrc = new Netrc();
|
|
|
|
//_option = new Option();
|
2010-06-21 13:51:56 +00:00
|
|
|
resolver_.reset(new DefaultAuthResolver());
|
2007-03-27 16:16:44 +00:00
|
|
|
//_factory->setOption(_option.get());
|
2010-06-21 13:51:56 +00:00
|
|
|
resolver_->setDefaultAuthConfig
|
2008-04-20 00:50:22 +00:00
|
|
|
(SharedHandle<AuthConfig>(new AuthConfig("foo", "bar")));
|
2007-03-27 16:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void testResolveAuthConfig_without_userDefined();
|
|
|
|
void testResolveAuthConfig_with_userDefined();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( DefaultAuthResolverTest );
|
|
|
|
|
|
|
|
void DefaultAuthResolverTest::testResolveAuthConfig_without_userDefined()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
SharedHandle<AuthConfig> authConfig = resolver_->resolveAuthConfig("localhost");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("foo:bar"), authConfig->getAuthText());
|
2007-03-27 16:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultAuthResolverTest::testResolveAuthConfig_with_userDefined()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
resolver_->setUserDefinedAuthConfig
|
2008-04-20 00:50:22 +00:00
|
|
|
(SharedHandle<AuthConfig>(new AuthConfig("myname", "mypasswd")));
|
2010-06-21 13:51:56 +00:00
|
|
|
SharedHandle<AuthConfig> authConfig = resolver_->resolveAuthConfig("localhost");
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("myname:mypasswd"), authConfig->getAuthText());
|
2007-03-27 16:16:44 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|