diff ui/tests/cinstprocesstest.cpp @ 295:02df89a275a6

Fix cinstprocesstest testValid with usage of arguments
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 02 Apr 2014 15:42:35 +0000
parents d95fd88f6616
children 0b1453070561
line wrap: on
line diff
--- a/ui/tests/cinstprocesstest.cpp	Wed Apr 02 15:41:31 2014 +0000
+++ b/ui/tests/cinstprocesstest.cpp	Wed Apr 02 15:42:35 2014 +0000
@@ -47,33 +47,59 @@
 }
 
 void CinstProcessTest::testValidInput() {
-    QProcess* installerProcess = startCinstProcess();
-    QVERIFY(installerProcess->state() == QProcess::Running);
+    QStringList args;
+    args << "list=" + validListFile.fileName();
 
-    installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n");
-    installerProcess->write(validList.rawData().toLatin1());
-    installerProcess->write("-----END CERTIFICATE LIST-----\r\n");
+    QTemporaryFile instructions;
+    instructions.open();
+    foreach (const Certificate &cert, validList.getCertificates()) {
+        instructions.write(cert.base64Line().toLatin1());
+        instructions.write("\n");
+    }
+    instructions.close();
 
-    foreach (const Certificate &cert, validList.getCertificates()) {
-        installerProcess->write(cert.base64Line().toLatin1());
-        installerProcess->write("\r\n");
-    }
+    args << "instructions=" + instructions.fileName();
 
+    QProcess* installerProcess = startCinstProcess(args);
     finishVerify(installerProcess, ERR_NO_ERROR);
 }
 
 void CinstProcessTest::initTestCase() {
-    QDir dataDir = QDir(SOURCE_DIR"/data/");
-    QString fileName = dataDir.absoluteFilePath("list-valid-signed.txt");
-    validList = CertificateList(fileName.toLocal8Bit().data());
+    QFile valid(":/list-valid-signed.txt");
+    valid.open(QIODevice::ReadOnly);
+    validListFile.open();
+    validListFile.write(valid.readAll());
+    valid.close();
+    validListFile.close();
+    validList = CertificateList(validListFile.fileName().toLocal8Bit().data());
+
+    QVERIFY(validList.isValid());
+
+    QFile invalid(":/list-invalid-signed.txt");
+    invalid.open(QIODevice::ReadOnly);
+    invalidListFile.open();
+    invalidListFile.write(invalid.readAll());
+    invalid.close();
+    invalidListFile.close();
+    invalidList = CertificateList(invalidListFile.fileName().toLocal8Bit().data());
+
+    QVERIFY(!invalidList.isValid());
+
+    QFile other(":/list-valid-other-signature.txt");
+    other.open(QIODevice::ReadOnly);
+    otherListFile.open();
+    otherListFile.write(other.readAll());
+    other.close();
+    otherListFile.close();
+    otherList = CertificateList(otherListFile.fileName().toLocal8Bit().data());
+
+    QVERIFY(!otherList.isValid());
 }
 
 void CinstProcessTest::testNoList() {
     /* No list */
     QProcess* installerProcess = startCinstProcess();
     QVERIFY(installerProcess->state() == QProcess::Running);
-    installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n");
-    installerProcess->write("-----END CERTIFICATE LIST-----\r\n");
 
     foreach (const Certificate &cert, validList.getCertificates()) {
         installerProcess->write(cert.base64Line().toLatin1());

http://wald.intevation.org/projects/trustbridge/