aboutsummaryrefslogtreecommitdiffstats
path: root/test/testgpgcontext.cpp
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-12-10 13:13:35 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-12-10 13:13:35 +0000
commit666bb1544b038be8343696ac7c23646bb3cd935f (patch)
treea8cd322df2ff0c56e044f3acb96e752840a49d90 /test/testgpgcontext.cpp
parentupdate TODO (diff)
downloadgpg4usb-666bb1544b038be8343696ac7c23646bb3cd935f.tar.gz
gpg4usb-666bb1544b038be8343696ac7c23646bb3cd935f.zip
add some unit test code
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@688 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'test/testgpgcontext.cpp')
-rw-r--r--test/testgpgcontext.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/testgpgcontext.cpp b/test/testgpgcontext.cpp
new file mode 100644
index 0000000..429bdf9
--- /dev/null
+++ b/test/testgpgcontext.cpp
@@ -0,0 +1,58 @@
+#include <QObject>
+#include <QtTest/QtTest>
+#include <../gpgcontext.h>
+
+class TestGpgContext : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestGpgContext();
+
+private:
+ GpgME::GpgContext* mCtx;
+
+private slots:
+ void passwordSize();
+
+};
+
+TestGpgContext::TestGpgContext() {
+ mCtx = new GpgME::GpgContext();
+}
+
+void TestGpgContext::passwordSize() {
+
+ QVERIFY(mCtx->listKeys().size() == 0);
+
+ qDebug() << "import:";
+ QFile* file = new QFile("../testdata/seckey-1.asc");
+ file->open(QIODevice::ReadOnly);
+ mCtx->importKey(file->readAll());
+
+ qDebug() << "list:";
+ foreach(GpgKey key, mCtx->listKeys()) {
+ qDebug() << key.id;
+ }
+
+ QVERIFY(mCtx->listKeys().size() == 1);
+
+ QString password = "abcabc";
+ QString params = "<GnupgKeyParms format=\"internal\">\n"
+ "Key-Type: DSA\n"
+ "Key-Length: 1024\n"
+ "Subkey-Type: ELG-E\n"
+ "Subkey-Length: 1024\n"
+ "Name-Real: testa\n"
+ "Expire-Date: 0\n";
+ "Passphrase: " + password + "\n"
+ "</GnupgKeyParms>";
+
+ /*qDebug() << "gen:";
+ mCtx->generateKey(&params);
+ QVERIFY(mCtx->listKeys().size() == 1);
+ qDebug() << "done.";*/
+}
+
+QTEST_MAIN(TestGpgContext)
+#include "testgpgcontext.moc"