- real fix for bug #390535
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 28 Aug 2007 10:44:03 +0000 (10:44 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 28 Aug 2007 10:44:03 +0000 (10:44 +0000)
tests/zypp/KeyRing.cc
zypp/KeyRing.cc

index 43387648a8c0ba8b7e7f2c4549987baceb2141a2..08e8a834fac5e3b7352e6db0c2c9bfa3ef7d0cc0 100644 (file)
@@ -193,6 +193,13 @@ void keyring_test( const string &dir )
   //BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), 1 );
 
   /* check signature id can be extracted */
+  
+}
+
+void keyring_signature_test( const string &dir )
+{
+  PublicKey key( Pathname(dir) + "public.asc" );
+
   {
     KeyRingTestReceiver keyring_callbacks;
     KeyRingTestSignalReceiver receiver;
@@ -204,6 +211,11 @@ void keyring_test( const string &dir )
     BOOST_CHECK_THROW( keyring.readSignatureKeyId(Pathname()), Exception );
     TmpFile tmp;
     BOOST_CHECK_EQUAL( keyring.readSignatureKeyId(tmp.path()), "" );
+
+    keyring.importKey(key);
+
+    BOOST_CHECK(keyring.verifyFileSignature( Pathname(dir) + "repomd.xml", Pathname(dir) + "repomd.xml.asc"));
+    BOOST_CHECK( ! keyring.verifyFileSignature( Pathname(dir) + "repomd.xml.corrupted", Pathname(dir) + "repomd.xml.asc"));
   }
 }
 
@@ -229,6 +241,8 @@ init_unit_test_suite( int argc, char* argv[] )
   test_suite* test= BOOST_TEST_SUITE( "PublicKeyTest" );
   test->add(BOOST_PARAM_TEST_CASE( &keyring_test,
                               (std::string const*)params, params+1));
+  test->add(BOOST_PARAM_TEST_CASE( &keyring_signature_test,
+                              (std::string const*)params, params+1));
   return test;
 }
 
index 13fdbf5a4ad2ddac5edc2a5066d3b9731e6f11f2..39aecd0ee8aa12f780a05b6f5e759bd2ffc9bdbc 100644 (file)
@@ -540,7 +540,6 @@ namespace zypp
     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");
 
     const char* argv[] =
     {
@@ -554,9 +553,7 @@ namespace zypp
       "1",
       "--homedir",
       dir.path().asString().c_str(),
-      "--verify",
       signature.asString().c_str(),
-      fakeData.path().asString().c_str(),
       NULL
     };