aboutsummaryrefslogtreecommitdiffstats
path: root/test/testgpgcontext.cpp
blob: 429bdf9fb33c6b184e8aacbd91b1e9c2f33c7d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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"