AuthData cr2("pat","vymetheny");
cr2.setUrl(Url("ftp://filesuck.org"));
- // should creat a new file
+ // should create a new file
cm1.saveInGlobal(cr1);
CredCollector collector;
cm1.saveInGlobal(cr2);
- filesystem::copy(opts.globalCredFilePath, "/home/jkupec/tmp/foo");
-
CredentialFileReader reader1(opts.globalCredFilePath,
bind( &CredCollector::collect, &collector, _1 ));
BOOST_CHECK(collector.creds.size() == 2);
BOOST_CHECK(collector.creds.size() == 2);
// todo check created file permissions
-}
\ No newline at end of file
+}
+
+BOOST_AUTO_TEST_CASE(service_base_url)
+{
+ filesystem::TmpDir tmp;
+
+ CredManagerOptions opts;
+ opts.globalCredFilePath = tmp / "fooha";
+
+ CredentialManager cm1(opts);
+ AuthData cr1("benson","absolute");
+ cr1.setUrl(Url("http://joooha.com/service/path"));
+ cm1.addGlobalCred(cr1);
+
+ AuthData_Ptr creds;
+ creds = cm1.getCred(Url("http://joooha.com/service/path/repo/repofoo"));
+
+ BOOST_CHECK(creds.get() != NULL);
+ if (!creds)
+ return;
+ BOOST_CHECK(creds->username() == "benson");
+
+ creds = cm1.getCred(Url("http://benson@joooha.com/service/path/repo/repofoo"));
+
+ BOOST_CHECK(creds.get() != NULL);
+ if (!creds)
+ return;
+ BOOST_CHECK(creds->username() == "benson");
+
+ creds = cm1.getCred(Url("http://nobody@joooha.com/service/path/repo/repofoo"));
+ BOOST_CHECK(creds.get() == NULL);
+}
using std::endl;
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "parser"
+
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
const Url & url,
url::ViewOption vopt)
{
+ const string & username = url.getUsername();
for(CredentialManager::CredentialIterator it = set.begin(); it != set.end(); ++it)
{
- if (url.asString(vopt) == (*it)->url().asString(vopt))
- return *it;
+ // this ignores url params - not sure if it is good or bad...
+ if (url.asString(vopt).find((*it)->url().asString(vopt)) == 0)
+ {
+ if (username.empty() || username == (*it)->username())
+ return *it;
+ }
}
-
+
return AuthData_Ptr();
}
// if the wanted URL does not contain username, ignore that, too
url::ViewOption vopt;
// if (url.getUsername().empty())
- vopt = vopt - url::ViewOption::WITH_USERNAME;
+ vopt = vopt
+ - url::ViewOption::WITH_USERNAME
+ - url::ViewOption::WITH_QUERY_STR;
// search in global credentials
result = findIn(_credsGlobal, url, vopt);
void CredentialManager::addCred(const AuthData & cred)
{
+#warning addCred(const AuthData & cred) not implemented
// add with user callbacks
}
AuthData_Ptr c_ptr;
c_ptr.reset(new AuthData(cred)); // FIX for child classes if needed
if (_pimpl->_credsGlobal.insert(c_ptr).second)
- {
_pimpl->_globalDirty = true;
- INT << "changed/new:" << cred << endl;
- }
- else
- INT << "already there: " << cred << endl;
}
AuthData_Ptr c_ptr;
c_ptr.reset(new AuthData(cred)); // FIX for child classes if needed
if (_pimpl->_credsUser.insert(c_ptr).second)
- {
_pimpl->_userDirty = true;
- INT << "changed/new:" << cred << endl;
- }
- else
- INT << "already there: " << cred << endl;
}