-ADD_EXECUTABLE( Downloader Downloader_test.cc )
+ADD_EXECUTABLE(
+ Downloader
+ Downloader_test.cc
+)
TARGET_LINK_LIBRARIES( Downloader zypp boost_unit_test_framework )
ADD_TEST(Downloader ${CMAKE_CURRENT_BINARY_DIR}/Downloader ${CMAKE_CURRENT_SOURCE_DIR}/data )
\ No newline at end of file
#include "zypp/TmpPath.h"
#include "zypp/repo/susetags/Downloader.h"
+#include "tests/zypp/KeyRingTestReceiver.h"
using std::cout;
using std::endl;
void susetags_download_test(const string &dir)
{
+ KeyRingTestReceiver keyring_callbacks;
+ keyring_callbacks.answerTrustKey(true);
+
Pathname p = dir + "/stable-x86-subset";
Url url("dir:" + p.asString());
MediaSetAccess media(url);
void susetags_gz_download_test(const string &dir)
{
+ KeyRingTestReceiver keyring_callbacks;
+ keyring_callbacks.answerTrustKey(true);
+
Pathname p = dir + "/stable-x86-subset-gz";
Url url("dir:" + p.asString());
MediaSetAccess media(url);
------BEGIN PGP MESSAGE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.9.22 (GNU/Linux)
-owGdlsuLI1UUxtsZRAkozMaNm4sLQZxU7vvRjkjSST8wdsZUMs64ae4zHTupCqkK
-3T1LF4PuZi+I4MKV6MY/QBcD7gSX4sqtGxFEXHkr6XaSVhkYSKpInXN+de93vlOp
-hy9c37p245Nfv/vm56/FnWe+fP7UPGfzrPRZufv9w+ntfq893BmAfOazdJh26kHb
-Mp+f1+50+ulB7xAgmJBa+yAdXGami5jVHWeLs3o6aLa6nfpdyZcZayU4oXgNddju
-9UGFB92Dw+FdcHueu4UtC7A3Nfs3weHCzzPj56ObYM/Ppzo7r/U73cPeoJMO+11w
-XJaz7Ubj9PQ0KRaFT2w+bcz9JMtLXzTGRPLG5eobu82dQa9/rwp7Xfj6MieZz6a1
-Zn9nPzmT/IhTcHEac8nBmFUHWh0iCWS5ntvjVfYq/qQk9oQ4/f8QuXK13dltDruD
-VjMK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ef55PkbDpZq49KxIEX1gsaoHUk
-WE1lNXqismJ0mAhWMewAGGdFqScTXT2krkC4dMrErsVeVgJJ7KUkNK4knqkOUX/B
-EJYCgKl3Y52gxjgLeVKelbXaR29df3areuW4fBe5ce2Hl7c+fe2P7Qfdvx7RVz9P
-XvntpW97b4wfgK3PPvzqxdGDax8//OLR77+8//pPZ7daf/74Nw==
-=3cih
------END PGP MESSAGE-----
+iD8DBQBGzZ7Vm+zCtd2wN1YRAvrYAJ4or9MtpTiRk57EiGkd3YBvgoIN5QCfX969
+j0d5j3iteCP3nR/N39nrdMo=
+=w2Lh
+-----END PGP SIGNATURE-----
------BEGIN PGP MESSAGE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.9.22 (GNU/Linux)
-owGdVjuPG1UU3iRCIEsUaaCguYIiEort+35EvLxr70Mx6+CxQ6BZ3eeuWXtsecba
-3TR0CLr0FKmJhKBBoqZBlCAigQQVLRI/AAlxZr1LvAEUKZI9V55zvu/e833njOfe
-81fWLl/99Pdvvvr1S3X70ufPRfesn+ZlzMvN7+69cavfaw83Bmg6i3k2zDr1ZH05
-nZ/Ubnf62U5vFxHcYLX2TjY4z8wWkNUd5YvjejZorXc79TtanmasQGiD0xWq3Xav
-jyp61N3ZHd5Bt+bTsPBlgbYmbvs62l3Eee7ifP862orzic1Pav1Od7c36GTDfhcd
-lOXsRrN5dHTUKBZFbPjppDmP43xaxqI5Ylo2z0/f3GxtDHr996pwtEWsn+Y05rNJ
-rdXf2G4ca7knOTpbRlJLNBLVhVcXYEL51M79wTJ7GX9SknhCnP9/iD12t93ZbA27
-g/UWCFVRggrvDHf6neyRPWeFoddPjUEzW5ag3Q0H94qTooyTGvh0e6cNmNlS5Bvn
-2CWmcqbWW8963c5gJalK2Fua8y/ca0tgDcJbw1aGfIGCRSGimMNnb2sdxQKlEUpz
-dLBAoxJ9YNHhBOVjlDs0G6NZubfeR3cP9jZ2q+vg3Vq23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fyFunb8x88frd133z544eFPv3y49v3ll1595bcf//rkrYd/Aw==
-=/aaM
------END PGP MESSAGE-----
+iD8DBQBGzZ7Im+zCtd2wN1YRAvQ2AJ9S5chSnjnFR0P2IZO7485uodmb1QCeJzuj
+Ta+M4yWexFiqyaFmWRjdAuQ=
+=lrpc
+-----END PGP SIGNATURE-----
#include <boost/test/parameterized_test.hpp>
#include <boost/test/unit_test_log.hpp>
+#include "zypp/base/Logger.h"
#include "zypp/Url.h"
#include "zypp/PathInfo.h"
#include "zypp/TmpPath.h"
#include "zypp/repo/yum/Downloader.h"
-
using std::cout;
using std::endl;
using std::string;
using namespace zypp::repo;
+#include "tests/zypp/KeyRingTestReceiver.h"
+
void yum_download_test(const string &dir)
{
+ KeyRingTestReceiver keyring_callbacks;
+ keyring_callbacks.answerTrustKey(true);
+
Pathname p = dir + "/10.2-updates-subset";
Url url("dir:" + p.asString());
MediaSetAccess media(url);
KeyRing keyring( tmp_dir.path() );
BOOST_CHECK_EQUAL( keyring.readSignatureKeyId( Pathname(dir) + "repomd.xml.asc" ), "BD61D89BD98821BE" );
- BOOST_CHECK_EQUAL( keyring.readSignatureKeyId(Pathname()), "" );
+ BOOST_CHECK_THROW( keyring.readSignatureKeyId(Pathname()), Exception );
+ TmpFile tmp;
+ BOOST_CHECK_EQUAL( keyring.readSignatureKeyId(tmp.path()), "" );
}
}
#include <list>
#include "zypp/base/Logger.h"
+#include "zypp/base/PtrTypes.h"
#include "zypp/base/DefaultIntegral.h"
#include "zypp/Fetcher.h"
#include "zypp/base/UserRequestException.h"
FetcherJob( const OnMediaLocation &loc )
: location(loc)
{
+ //MIL << location << endl;
+ }
+ ~FetcherJob()
+ {
+ //MIL << location << " | * " << checkers.size() << endl;
}
OnMediaLocation location;
- CompositeFileChecker checkers;
+ //CompositeFileChecker checkers;
+ list<FileChecker> checkers;
};
+ typedef shared_ptr<FetcherJob> FetcherJob_Ptr;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Fetcher::Impl
Impl * clone() const
{ return new Impl( *this ); }
- std::list<FetcherJob> _resources;
+ std::list<FetcherJob_Ptr> _resources;
std::list<Pathname> _caches;
};
///////////////////////////////////////////////////////////////////
void Fetcher::Impl::enqueueDigested( const OnMediaLocation &resource, const FileChecker &checker )
{
- CompositeFileChecker composite;
- composite.add(ChecksumFileChecker(resource.checksum()));
- composite.add(checker);
- FetcherJob job(resource);
- job.checkers = composite;
+ FetcherJob_Ptr job;
+ job.reset(new FetcherJob(resource));
+ ChecksumFileChecker digest_check(resource.checksum());
+ job->checkers.push_back(digest_check);
+ if ( checker )
+ job->checkers.push_back(checker);
_resources.push_back(job);
}
void Fetcher::Impl::enqueue( const OnMediaLocation &resource, const FileChecker &checker )
{
- FetcherJob job(resource);
- job.checkers.add(checker);
+ FetcherJob_Ptr job;
+ job.reset(new FetcherJob(resource));
+ if ( checker )
+ job->checkers.push_back(checker);
_resources.push_back(job);
}
ProgressData progress(_resources.size());
progress.sendTo(progress_receiver);
- for ( list<FetcherJob>::const_iterator it_res = _resources.begin(); it_res != _resources.end(); ++it_res )
+ for ( list<FetcherJob_Ptr>::const_iterator it_res = _resources.begin(); it_res != _resources.end(); ++it_res )
{
bool got_from_cache = false;
for ( list<Pathname>::const_iterator it_cache = _caches.begin(); it_cache != _caches.end(); ++it_cache )
{
// does the current file exists in the current cache?
- Pathname cached_file = *it_cache + (*it_res).location.filename();
+ Pathname cached_file = *it_cache + (*it_res)->location.filename();
if ( PathInfo( cached_file ).isExist() )
{
// check the checksum
- if ( is_checksum( cached_file, (*it_res).location.checksum() ) && (! (*it_res).location.checksum().empty() ) )
+ if ( is_checksum( cached_file, (*it_res)->location.checksum() ) && (! (*it_res)->location.checksum().empty() ) )
{
// cached
- MIL << "file " << (*it_res).location.filename() << " found in previous cache. Using cached copy." << endl;
+ MIL << "file " << (*it_res)->location.filename() << " found in previous cache. Using cached copy." << endl;
// checksum is already checked.
// we could later implement double failover and try to download if file copy fails.
// replicate the complete path in the target directory
- Pathname dest_full_path = dest_dir + (*it_res).location.filename();
+ Pathname dest_full_path = dest_dir + (*it_res)->location.filename();
if ( assert_dir( dest_full_path.dirname() ) != 0 )
ZYPP_THROW( Exception("Can't create " + dest_full_path.dirname().asString()));
// try to get the file from the net
try
{
- Pathname tmp_file = media.provideFile((*it_res).location);
- Pathname dest_full_path = dest_dir + (*it_res).location.filename();
+ Pathname tmp_file = media.provideFile((*it_res)->location);
+ Pathname dest_full_path = dest_dir + (*it_res)->location.filename();
if ( assert_dir( dest_full_path.dirname() ) != 0 )
ZYPP_THROW( Exception("Can't create " + dest_full_path.dirname().asString()));
if ( filesystem::copy(tmp_file, dest_full_path ) != 0 )
}
catch (const Exception & excpt_r)
{
- ZYPP_CAUGHT(excpt_r);
- Exception nexcpt("Can't provide " + (*it_res).location.filename().asString() + " : " + excpt_r.msg());
- nexcpt.remember(excpt_r);
- ZYPP_THROW(nexcpt);
+ ZYPP_CAUGHT(excpt_r);
+ Exception nexcpt("Can't provide " + (*it_res)->location.filename().asString() + " : " + excpt_r.msg());
+ nexcpt.remember(excpt_r);
+ ZYPP_THROW(nexcpt);
}
}
else
}
// no matter where did we got the file, try to validate it:
- Pathname localfile = dest_dir + (*it_res).location.filename();
+ Pathname localfile = dest_dir + (*it_res)->location.filename();
// call the checker function
try {
- MIL << "Checking " << localfile << endl;
- (*it_res).checkers(localfile);
+ MIL << "Checking job [" << localfile << "] (" << (*it_res)->checkers.size() << " checkers )" << endl;
+ for ( list<FileChecker>::const_iterator it = (*it_res)->checkers.begin();
+ it != (*it_res)->checkers.end();
+ ++it )
+ {
+ if (*it)
+ {
+ (*it)(localfile);
+ }
+ else
+ {
+ ERR << "Invalid checker for '" << localfile << "'" << endl;
+ }
+ }
+
}
catch ( const FileCheckException &e )
{
}
catch (...)
{
- ZYPP_THROW(Exception("Unknown error while validating " + (*it_res).location.filename().asString()));
+ ZYPP_THROW(Exception("Unknown error while validating " + (*it_res)->location.filename().asString()));
}
if ( ! progress.incr() )
void Fetcher::enqueueDigested( const OnMediaLocation &resource, const FileChecker &checker )
{
- _pimpl->enqueue(resource, checker);
+ _pimpl->enqueueDigested(resource, checker);
}
void Fetcher::enqueue( const OnMediaLocation &resource, const FileChecker &checker )
*
*/
void enqueue( const OnMediaLocation &resource,
- const FileChecker &checker = NullFileChecker() );
+ const FileChecker &checker = FileChecker() );
/**
* Enqueue a object for transferal, they will not
* \todo FIXME implement checker == operator to avoid this.
*/
void enqueueDigested( const OnMediaLocation &resource,
- const FileChecker &checker = NullFileChecker() );
+ const FileChecker &checker = FileChecker() );
/**
* adds a directory to the list of directories
void ChecksumFileChecker::operator()( const Pathname &file ) const
{
+ MIL << "checking " << file << " file against checksum '" << _checksum << "'" << endl;
callback::SendReport<DigestReport> report;
CheckSum real_checksum( _checksum.type(), filesystem::checksum( file, _checksum.type() ));
void NullFileChecker::operator()(const Pathname &file ) const
{
+ MIL << "+ null check on " << file << endl;
return;
}
void CompositeFileChecker::operator()(const Pathname &file ) const
{
- MIL << _checkers.size() << " checkers" << endl;
+ //MIL << _checkers.size() << " checkers" << endl;
for ( list<FileChecker>::const_iterator it = _checkers.begin(); it != _checkers.end(); ++it )
- {
- MIL << "checking..." << endl;
- (*it)(file);
+ {
+ if ( *it )
+ {
+ //MIL << "+ chk" << endl;
+ (*it)(file);
+ }
+ else
+ {
+ ERR << "Invalid checker" << endl;
+ }
}
}
string KeyRing::Impl::readSignatureKeyId(const Pathname &signature )
{
- MIL << "Deetermining key id if signature " << signature << endl;
+ if ( ! PathInfo(signature).isFile() )
+ ZYPP_THROW(Exception("Signature file " + signature.asString() + " not found"));
+
+ MIL << "Determining key id if signature " << signature << endl;
// HACK create a tmp keyring with no keys
TmpDir dir(_base_dir, "fake-keyring");
TmpFile fakeData(_base_dir, "fake-data");
id = what[1];
//dumpRegexpResults(what);
}
+ else
+ {
+ MIL << "'" << line << "'" << endl;
+ }
}
+
+ if ( count == 0 )
+ {
+ MIL << "no output" << endl;
+ }
+
MIL << "Determined key id [" << id << "] for signature " << signature << endl;
prog.close();
return id;