From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kio/tests/kionetrctest.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 kio/tests/kionetrctest.cpp (limited to 'kio/tests/kionetrctest.cpp') diff --git a/kio/tests/kionetrctest.cpp b/kio/tests/kionetrctest.cpp new file mode 100644 index 000000000..977603426 --- /dev/null +++ b/kio/tests/kionetrctest.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +#include "authinfo.h" + +void output( const KURL& u ) +{ + kdDebug() << "Looking up auto login for: " << u.url() << endl; + KIO::NetRC::AutoLogin l; + bool result = KIO::NetRC::self()->lookup( u, l, true ); + if ( !result ) + { + kdDebug() << "Either no .netrc and/or .kionetrc file was " + "found or there was problem when attempting to " + "read from them! Please make sure either or both " + "of the above files exist and have the correct " + "permission, i.e. a regular file owned by you with " + "with a read/write permission (0600)" << endl; + return; + } + + kdDebug() << "Type: " << l.type << endl + << "Machine: " << l.machine << endl + << "Login: " << l.login << endl + << "Password: " << l.password << endl; + + QMap::ConstIterator it = l.macdef.begin(); + for ( ; it != l.macdef.end(); ++it ) + { + kdDebug() << "Macro: " << it.key() << "= " + << it.data().join(" ") << endl; + } +} + +int main(int argc, char **argv) +{ + const char *version = "0.5"; + const char *description = "Unit test for .netrc and kionetrc parser."; + KCmdLineOptions options[] = + { + { "+command", "[url1,url2 ,...]", 0 }, + KCmdLineLastOption + }; + + KCmdLineArgs::init( argc, argv, "kionetrctest", description, version ); + KCmdLineArgs::addCmdLineOptions( options ); + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + int count = args->count(); + KApplication app; + + if ( !count ) + args->usage(); + else + { + KURL u; + for( int i=0 ; i < count; i++ ) + { + u = args->arg(i); + if ( !u.isValid() ) + { + kdDebug() << u.url() << " is invalid! Ignoring..." << endl; + continue; + } + output( u ); + } + } + args->clear(); + return 0; +} -- cgit v1.2.1