-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple changes to support glib API
- Create shadow API for repomanager related types - Get rid of ZConfig::instance in repo code - Make MediaManager and classes context aware - Adapt test cases where needed - Make Auth Manager context aware
- Loading branch information
Showing
198 changed files
with
6,531 additions
and
3,346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,16 @@ | |
#include <zypp/Url.h> | ||
#include <zypp/TmpPath.h> | ||
#include <zypp-media/auth/CredentialFileReader> | ||
#include <zypp-media/auth/CredentialManager> | ||
#include <zypp-media/ng/auth/credentialmanager.h> | ||
|
||
#include <zypp/PathInfo.h> | ||
#include <zypp/ng/context.h> | ||
|
||
using std::cout; | ||
using std::endl; | ||
using namespace zypp; | ||
using namespace zypp::media; | ||
using zyppng::media::CredentialManager; | ||
|
||
inline void testGetCreds( CredentialManager & cm_r, const std::string & url_r, | ||
const std::string & user_r = "", | ||
|
@@ -34,19 +36,22 @@ inline void testGetCreds( CredentialManager & cm_r, const std::string & url_r, | |
|
||
BOOST_AUTO_TEST_CASE(read_cred_for_url) | ||
{ | ||
CredManagerOptions opts; | ||
auto ctx = zyppng::SyncContext::create(); | ||
ctx->initialize().unwrap (); | ||
|
||
CredManagerSettings opts(ctx); | ||
opts.globalCredFilePath = TESTS_SRC_DIR "/media/data/credentials.cat"; | ||
opts.userCredFilePath = Pathname(); | ||
CredentialManager cm( opts ); | ||
auto cm = CredentialManager::create( opts ); | ||
|
||
BOOST_CHECK_EQUAL( cm.credsGlobalSize(), 3 ); | ||
BOOST_CHECK_EQUAL( cm->credsGlobalSize(), 3 ); | ||
|
||
testGetCreds( cm, "https://drink.it/repo/roots", "ginger", "ale" ); | ||
testGetCreds( cm, "ftp://weprovidesoft.fr/download/opensuse/110", "agda", "ichard" ); | ||
testGetCreds( cm, "ftp://[email protected]/download/opensuse/110", "magda", "richard" ); | ||
testGetCreds( cm, "ftp://[email protected]/download/opensuse/110", "agda", "ichard" ); | ||
testGetCreds( cm, "ftp://[email protected]/download/opensuse/110" ); // NULL | ||
testGetCreds( cm, "http://url.ok/but/not/creds" ); // NULL | ||
testGetCreds( *cm, "https://drink.it/repo/roots", "ginger", "ale" ); | ||
testGetCreds( *cm, "ftp://weprovidesoft.fr/download/opensuse/110", "agda", "ichard" ); | ||
testGetCreds( *cm, "ftp://[email protected]/download/opensuse/110", "magda", "richard" ); | ||
testGetCreds( *cm, "ftp://[email protected]/download/opensuse/110", "agda", "ichard" ); | ||
testGetCreds( *cm, "ftp://[email protected]/download/opensuse/110" ); // NULL | ||
testGetCreds( *cm, "http://url.ok/but/not/creds" ); // NULL | ||
} | ||
|
||
struct CredCollector | ||
|
@@ -64,10 +69,15 @@ struct CredCollector | |
|
||
BOOST_AUTO_TEST_CASE(save_creds) | ||
{ | ||
auto ctx = zyppng::SyncContext::create(); | ||
ctx->initialize().unwrap (); | ||
|
||
CredManagerSettings opts(ctx); | ||
|
||
filesystem::TmpDir tmp; | ||
CredManagerOptions opts; | ||
opts.globalCredFilePath = tmp / "fooha"; | ||
CredentialManager cm1(opts); | ||
|
||
auto cm1 = CredentialManager::create(opts); | ||
|
||
AuthData cr1("benson","absolute"); | ||
cr1.setUrl(Url("http://joooha.com")); | ||
|
@@ -76,20 +86,20 @@ BOOST_AUTO_TEST_CASE(save_creds) | |
cr2.setUrl(Url("ftp://filesuck.org")); | ||
|
||
// should create a new file | ||
cm1.saveInGlobal(cr1); | ||
cm1->saveInGlobal(cr1); | ||
|
||
CredCollector collector; | ||
CredentialFileReader( opts.globalCredFilePath, bind( &CredCollector::collect, &collector, _1 ) ); | ||
BOOST_CHECK_EQUAL( collector.creds.size(), 1 ); | ||
|
||
collector.creds.clear(); | ||
cm1.saveInGlobal(cr2); | ||
cm1->saveInGlobal(cr2); | ||
CredentialFileReader( opts.globalCredFilePath, bind( &CredCollector::collect, &collector, _1 ) ); | ||
BOOST_CHECK_EQUAL(collector.creds.size(), 2 ); | ||
|
||
collector.creds.clear(); | ||
// save the same creds again | ||
cm1.saveInGlobal(cr2); | ||
cm1->saveInGlobal(cr2); | ||
CredentialFileReader( opts.globalCredFilePath, bind( &CredCollector::collect, &collector, _1 ) ); | ||
BOOST_CHECK_EQUAL(collector.creds.size(), 2 ); | ||
|
||
|
@@ -98,16 +108,21 @@ BOOST_AUTO_TEST_CASE(save_creds) | |
|
||
BOOST_AUTO_TEST_CASE(service_base_url) | ||
{ | ||
auto ctx = zyppng::SyncContext::create(); | ||
ctx->initialize().unwrap (); | ||
|
||
CredManagerSettings opts(ctx); | ||
|
||
filesystem::TmpDir tmp; | ||
CredManagerOptions opts; | ||
opts.globalCredFilePath = tmp / "fooha"; | ||
CredentialManager cm( opts ); | ||
|
||
auto cm = CredentialManager::create( opts ); | ||
|
||
AuthData cred( "benson","absolute" ); | ||
cred.setUrl( Url( "http://joooha.com/service/path" ) ); | ||
cm.addGlobalCred( cred ); | ||
cm->addGlobalCred( cred ); | ||
|
||
testGetCreds( cm, "http://joooha.com/service/path/repo/repofoo", "benson", "absolute" ); | ||
testGetCreds( cm, "http://[email protected]/service/path/repo/repofoo", "benson", "absolute" ); | ||
testGetCreds( cm, "http://[email protected]/service/path/repo/repofoo" ); // NULL | ||
testGetCreds( *cm, "http://joooha.com/service/path/repo/repofoo", "benson", "absolute" ); | ||
testGetCreds( *cm, "http://[email protected]/service/path/repo/repofoo", "benson", "absolute" ); | ||
testGetCreds( *cm, "http://[email protected]/service/path/repo/repofoo" ); // NULL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <list> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.