}
}
+BOOST_AUTO_TEST_CASE(fetcher_enqueuedir_autoindex_untrustedkey)
+{
+ MediaSetAccess media( ( DATADIR).asUrl(), "/" );
+ // do the test by trusting the SHA1SUMS file signature key
+ {
+ filesystem::TmpDir dest;
+
+ // add the key as untrusted, which is the same as not adding it and
+ // let autodiscovery to add it
+
+ Fetcher fetcher;
+ fetcher.setOptions( Fetcher::AutoAddIndexes );
+ fetcher.enqueueDir(OnMediaLocation("/complexdir"), true);
+ BOOST_CHECK_THROW( fetcher.start( dest.path(), media ), Exception);
+
+ BOOST_CHECK( ! PathInfo(dest.path() + "/complexdir/subdir2").isExist() );
+ BOOST_CHECK( ! PathInfo(dest.path() + "/complexdir/subdir2/subdir2-file1.txt").isExist() );
+ BOOST_CHECK( ! PathInfo(dest.path() + "/complexdir/subdir1/subdir1-file1.txt").isExist() );
+ BOOST_CHECK( ! PathInfo(dest.path() + "/complexdir/subdir1/subdir1-file2.txt").isExist() );
+
+ fetcher.reset();
+ }
+}
+
BOOST_AUTO_TEST_CASE(fetcher_enqueuedir_autoindex)
{
- base::LogControl::TmpLineWriter shutUp( new zypp::log::FileLineWriter( "/tmp/YLOG" ) );
- MIL << "GO" << endl;
MediaSetAccess media( ( DATADIR).asUrl(), "/" );
// do the test by trusting the SHA1SUMS file signature key
{
// it should throw because unsigned file throws
BOOST_CHECK_THROW( fetcher.start( dest.path(), media ), FileCheckException);
fetcher.reset();
- // the target file was NOT transfered
+ // the target file was NOT transferred
BOOST_CHECK( ! PathInfo(dest.path() + "/images/images.xml").isExist() );
fetcher.reset();
}
BOOST_AUTO_TEST_CASE(enqueuedir_http)
{
+ WebServer web((Pathname(TESTS_SRC_DIR) + "/zypp/data/Fetcher/remote-site").c_str(), 10001);
+ web.start();
+
// at this point the key is already trusted
{
- // add the key as trusted
- //getZYpp()->keyRing()->importKey(PublicKey(DATADIR + "/complexdir/subdir1/SHA1SUMS.key"), true);
-
- WebServer web((Pathname(TESTS_SRC_DIR) + "/zypp/data/Fetcher/remote-site").c_str() );
- web.start();
-
- MediaSetAccess media( Url("http://localhost:9099"), "/" );
+ MediaSetAccess media( web.url(), "/" );
Fetcher fetcher;
filesystem::TmpDir dest;
BOOST_CHECK( PathInfo(dest.path() + "/complexdir/subdir2/subdir2-file1.txt").isExist() );
BOOST_CHECK( PathInfo(dest.path() + "/complexdir/subdir1/subdir1-file1.txt").isExist() );
BOOST_CHECK( PathInfo(dest.path() + "/complexdir/subdir1/subdir1-file2.txt").isExist() );
-
- web.stop();
}
-}
-BOOST_AUTO_TEST_CASE(enqueuedir_http_broken)
-{
- // at this point the key is already trusted
+ // test broken tree
{
- // add the key as trusted
- //getZYpp()->keyRing()->importKey(PublicKey(DATADIR + "/complexdir/subdir1/SHA1SUMS.key"), true);
-
- WebServer web((Pathname(TESTS_SRC_DIR) + "/zypp/data/Fetcher/remote-site").c_str() );
- web.start();
-
- MediaSetAccess media( Url("http://localhost:9099"), "/" );
+ MediaSetAccess media( web.url(), "/" );
Fetcher fetcher;
filesystem::TmpDir dest;
BOOST_CHECK( ! PathInfo(dest.path() + "/complexdir-broken/subdir2/subdir2-file1.txt").isExist() );
- // this one got transfered before the failure, so it is there
+ // this one got transferred before the failure, so it is there
BOOST_CHECK( PathInfo(dest.path() + "/complexdir-broken/subdir1/subdir1-file1.txt").isExist() );
BOOST_CHECK( ! PathInfo(dest.path() + "/complexdir-broken/subdir1/subdir1-file2.txt").isExist() );
fetcher.reset();
-
- web.stop();
}
+
+ web.stop();
}
-
BOOST_AUTO_TEST_SUITE_END();
// vim: set ts=2 sts=2 sw=2 ai et: