Imported Upstream version 15.0.0
[platform/upstream/libzypp.git] / tests / media / CredentialFileReader_test.cc
1 #include <iostream>
2 #include <boost/test/auto_unit_test.hpp>
3 #include <set>
4
5 #include "zypp/Url.h"
6 #include "zypp/PathInfo.h"
7 #include "zypp/base/Easy.h"
8 #include "zypp/media/MediaUserAuth.h"
9
10 #include "zypp/media/CredentialFileReader.h"
11
12 using namespace std;
13 using namespace zypp;
14 using namespace zypp::media;
15
16 typedef std::set<AuthData_Ptr> CredentialSet;
17
18 struct CredCollector
19 {
20   bool collect(AuthData_Ptr & cred)
21   {
22     cout << "got: " << endl << *cred << endl;
23     creds.insert(cred);
24     return true;
25   }
26
27   CredentialSet creds;
28 };
29
30 BOOST_AUTO_TEST_CASE(read_cred)
31 {
32   CredCollector collector;
33   Pathname credfile = TESTS_SRC_DIR "/media/data/credentials.cat";
34   CredentialFileReader reader(credfile,
35       bind( &CredCollector::collect, &collector, _1 ));
36
37   BOOST_CHECK(collector.creds.size() == 2);
38 }