From 666bb1544b038be8343696ac7c23646bb3cd935f Mon Sep 17 00:00:00 2001 From: ubbo Date: Sat, 10 Dec 2011 13:13:35 +0000 Subject: add some unit test code git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@688 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- test/bin | 1 + test/runtest.sh | 11 ++++++++++ test/testgpgcontext.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ test/todo.txt | 4 ++++ 4 files changed, 74 insertions(+) create mode 120000 test/bin create mode 100755 test/runtest.sh create mode 100644 test/testgpgcontext.cpp create mode 100644 test/todo.txt (limited to 'test') diff --git a/test/bin b/test/bin new file mode 120000 index 0000000..40d9fed --- /dev/null +++ b/test/bin @@ -0,0 +1 @@ +../release/bin/ \ No newline at end of file diff --git a/test/runtest.sh b/test/runtest.sh new file mode 100755 index 0000000..56a0183 --- /dev/null +++ b/test/runtest.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +rm keydb/* +rmdir keydb +mkdir keydb + +#make clean +#qmake +make + +./test 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 +#include +#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 = "\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" + ""; + + /*qDebug() << "gen:"; + mCtx->generateKey(¶ms); + QVERIFY(mCtx->listKeys().size() == 1); + qDebug() << "done.";*/ +} + +QTEST_MAIN(TestGpgContext) +#include "testgpgcontext.moc" diff --git a/test/todo.txt b/test/todo.txt new file mode 100644 index 0000000..ee00699 --- /dev/null +++ b/test/todo.txt @@ -0,0 +1,4 @@ +gpgcontext.cpp: +- generateKey() should have parameters, not just a string +- constructor should have app path as param (or path to gpg binary) + -- path for keydb should be configurable separatly, for using empty db for testing -- cgit v1.2.3