[PATCH 3 of 3] Add a test for text signature creation with createinstallerdialog

Wald Commits scm-commit at wald.intevation.org
Tue Aug 5 17:45:09 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1407253503 -7200
# Node ID b1df9621c89c48a14fab57871f573bc7cec8c4b6
# Parent  ae571e7ecdc9c721c775fcd1d930d4126b1a8b54
Add a test for text signature creation with createinstallerdialog

diff -r ae571e7ecdc9 -r b1df9621c89c ui/tests/binverifytest.cpp
--- a/ui/tests/binverifytest.cpp	Tue Aug 05 17:44:31 2014 +0200
+++ b/ui/tests/binverifytest.cpp	Tue Aug 05 17:45:03 2014 +0200
@@ -7,8 +7,13 @@
  */
 #include "binverify.h"
 #include "binverifytest.h"
+#include "createinstallerdialog.h"
+#include "common.h"
+#include "mainwindow.h"
 
-#include <QTest>
+#include <QtTest>
+#include <QSettings>
+#include <QTemporaryFile>
 
 #ifdef Q_OS_WIN
 # define EXE_SUFFIX ".exe"
@@ -16,6 +21,12 @@
 # define EXE_SUFFIX ""
 #endif
 
+#ifdef Q_OS_WIN
+ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+#else
+ Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
+#endif
+
 /* Some general robustness checks */
 void BinVerifyTest::testMiscErrors()
 {
@@ -71,4 +82,21 @@
                                          strlen("fakeinst-signed" EXE_SUFFIX)));
 }
 
-QTEST_GUILESS_MAIN (BinVerifyTest);
+void BinVerifyTest::testSignatureCreation()
+{
+  QSettings testsettings;
+  testsettings.setValue("CodeSignCert", SOURCE_DIR"/data/codesign/codesigning-combined.pem");
+  testsettings.sync();
+  CreateInstallerDialog *theDialog = new CreateInstallerDialog(NULL);
+  QString garbage = getRandomDataFile(21*1024*1024);
+  QTemporaryFile outfile;
+  outfile.open();
+  outfile.close();
+  bool ret = theDialog->appendTextSignatureToFile (garbage, outfile.fileName());
+  QVERIFY(QFile::remove(garbage));
+  QVERIFY(ret == true);
+  QVERIFY(VerifyValid == verify_binary (outfile.fileName().toUtf8().constData(),
+                                        outfile.fileName().toUtf8().size()));
+}
+
+QTEST_MAIN (BinVerifyTest);
diff -r ae571e7ecdc9 -r b1df9621c89c ui/tests/binverifytest.h
--- a/ui/tests/binverifytest.h	Tue Aug 05 17:44:31 2014 +0200
+++ b/ui/tests/binverifytest.h	Tue Aug 05 17:45:03 2014 +0200
@@ -23,6 +23,7 @@
   void testOtherCert();
 #endif
   void testInvalidSig();
+  void testSignatureCreation();
 };
 #endif
 


More information about the Trustbridge-commits mailing list