Ticket #44473: kwallettest.patch
File kwallettest.patch, 4.5 KB (added by RJVB (René Bertin), 10 years ago) |
---|
-
kdelibs-4.12.5//kdeui/tests/
old new 7 7 # The alternative (which requires Qt>=4.6) is #include <QTestGui> 8 8 add_definitions(-DQT_GUI_LIB) 9 9 10 option(MAC_USE_OSXKEYCHAIN "On OS X, use the keychain as backend for kwallet, instead of kwalletd.") 10 11 11 12 MACRO(KDEUI_UNIT_TESTS) 12 13 FOREACH(_testname ${ARGN}) … … 154 155 kpixmapsequenceoverlaypaintertest 155 156 ) 156 157 158 if (Q_WS_MAC AND MAC_USE_OSXKEYCHAIN) 159 set_source_files_properties(kwallettest.cpp PROPERTIES 160 COMPILE_FLAGS -DMAC_USE_OSXKEYCHAIN) 161 endif(Q_WS_MAC AND MAC_USE_OSXKEYCHAIN) 162 157 163 if (NOT KDE_NO_DEPRECATED) 158 164 KDEUI_EXECUTABLE_TESTS( 159 165 keditlistboxtest -
kdelibs-4.12.5/kdeui/tests/
old new 32 32 33 33 void KWalletTest::testWallet() 34 34 { 35 QString testWallet = "k dewallet";35 QString testWallet = "kwallettestWallet"; 36 36 QString testFolder = "wallettestfolder"; 37 37 QString testKeys[] = { "testKey", "account-302948", "\\", "/abc", 38 38 "a@b.c" }; 39 39 QByteArray testValues[] = { "test", "@(!§\"%&", "", ".test", "\\" }; 40 QMap<QString,QString> pwmap; 40 41 int numTests = 5; 41 42 42 43 // Start kdeinit4, so that the wallet damon is started in the background … … 49 50 50 51 // open 51 52 Wallet *wallet = Wallet::openWallet( testWallet, w->winId(), Wallet::Synchronous ); 52 if ( wallet == 0 ) 53 kDebug() << "Couldn't open the wallet. Maybe the wallet daemon is not running?"; 53 if ( wallet == 0 ){ 54 kWarning() << "Couldn't open the wallet. Maybe the wallet daemon is not running?"; 55 } 56 else{ 57 kWarning() << "Opened wallet" << wallet->walletName(); 58 } 54 59 QVERIFY( wallet != 0 ); 55 60 QVERIFY( Wallet::isOpen( testWallet ) ); 61 kWarning() << "Wallet list:" << Wallet::walletList(); 62 63 // check on a couple of existing items, preferably at least 1 "internet account" and 1 "application password" 64 // OSXKeychain::readEntry( "existing name", "existing account", &value, NULL, NULL ) 56 65 57 66 // create folder 58 67 wallet->createFolder( testFolder ); 59 68 QVERIFY( wallet->hasFolder( testFolder ) ); 60 69 wallet->setFolder( testFolder ); 70 kWarning() << "Wallet's folder list:" << wallet->folderList(); 61 71 QVERIFY( wallet->currentFolder() == testFolder ); 62 72 QVERIFY( wallet->folderList().contains( testFolder ) ); 63 73 … … 70 80 QVERIFY( readEntry == testValues[i] ); 71 81 } 72 82 83 pwmap[QString("Bugzilla_login")] = QString("bugs@kde.org"); 84 pwmap[QString("Bugzilla_password")] = QString("buggyPassw0rd"); 85 kWarning() << "pwmap=" << pwmap; 86 87 QMap<QString,QString> v; 88 QVERIFY( !wallet->writeMap( "https://bugs.kde.org/#", pwmap ) ); 89 QVERIFY( wallet->hasEntry("https://bugs.kde.org/#") ); 90 QVERIFY( !wallet->readMap( "https://bugs.kde.org/#", v ) ); 91 QVERIFY( v == pwmap ); 92 // do it again 93 QVERIFY( !wallet->writeMap( "https://bugs.kde.org/#", pwmap ) ); 94 QVERIFY( wallet->hasEntry("https://bugs.kde.org/#") ); 95 QVERIFY( !wallet->readMap( "https://bugs.kde.org/#", v ) ); 96 QVERIFY( v == pwmap ); 97 98 QVERIFY( wallet->entryType( testKeys[0] ) == Wallet::Stream ); 99 QVERIFY( wallet->entryType( "https://bugs.kde.org/#" ) == Wallet::Map ); 100 101 QVERIFY( !wallet->renameEntry( "https://bugs.kde.org/#", "kdeBugs" ) ); 102 QVERIFY( wallet->hasEntry("kdeBugs") ); 103 QVERIFY( !wallet->readMap( "kdeBugs", v ) ); 104 QVERIFY( v == pwmap ); 105 73 106 // close 74 107 wallet->sync(); 75 Wallet::closeWallet( "kdewallet", true ); 76 QVERIFY( !Wallet::isOpen( "kdewallet" ) ); 108 QStringList l = wallet->entryList(); 109 kWarning() << "Entry list:" << l; 110 QVERIFY( l.size() == 6 ); 111 Wallet::closeWallet( testWallet, true ); 112 QVERIFY( !Wallet::isOpen( testWallet ) ); 77 113 78 114 // test for key - closed wallet 79 115 for ( int i = 0; i < 5; i++ ) { … … 108 144 QVERIFY( readEntry == testValues[i] ); 109 145 } 110 146 147 // remove those many test keys 148 for ( int i = 0; i < numTests; i++ ) { 149 QVERIFY( !wallet->removeEntry( testKeys[i] ) ); 150 } 151 152 #ifndef MAC_USE_OSXKEYCHAIN 111 153 // delete folder 112 154 wallet->removeFolder( testFolder ); 113 155 QVERIFY( !wallet->hasFolder( testFolder ) ); 156 #endif 114 157 115 158 // close 116 Wallet::closeWallet( "kdewallet", true ); 117 QVERIFY( !Wallet::isOpen( "kdewallet" ) ); 159 Wallet::closeWallet( testWallet, true ); 160 QVERIFY( !Wallet::isOpen( testWallet ) ); 161 QVERIFY( !Wallet::deleteWallet( testWallet ) ); 118 162 } 119 163 120 164 QTEST_KDEMAIN(KWalletTest, GUI)