comparison 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
comparison
equal deleted inserted replaced
294:d95fd88f6616 295:02df89a275a6
45 VERIFY_PROC_DEBUG(proc->exitCode() == exitCode); 45 VERIFY_PROC_DEBUG(proc->exitCode() == exitCode);
46 delete proc; 46 delete proc;
47 } 47 }
48 48
49 void CinstProcessTest::testValidInput() { 49 void CinstProcessTest::testValidInput() {
50 QProcess* installerProcess = startCinstProcess(); 50 QStringList args;
51 QVERIFY(installerProcess->state() == QProcess::Running); 51 args << "list=" + validListFile.fileName();
52 52
53 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n"); 53 QTemporaryFile instructions;
54 installerProcess->write(validList.rawData().toLatin1()); 54 instructions.open();
55 installerProcess->write("-----END CERTIFICATE LIST-----\r\n"); 55 foreach (const Certificate &cert, validList.getCertificates()) {
56 instructions.write(cert.base64Line().toLatin1());
57 instructions.write("\n");
58 }
59 instructions.close();
56 60
57 foreach (const Certificate &cert, validList.getCertificates()) { 61 args << "instructions=" + instructions.fileName();
58 installerProcess->write(cert.base64Line().toLatin1());
59 installerProcess->write("\r\n");
60 }
61 62
63 QProcess* installerProcess = startCinstProcess(args);
62 finishVerify(installerProcess, ERR_NO_ERROR); 64 finishVerify(installerProcess, ERR_NO_ERROR);
63 } 65 }
64 66
65 void CinstProcessTest::initTestCase() { 67 void CinstProcessTest::initTestCase() {
66 QDir dataDir = QDir(SOURCE_DIR"/data/"); 68 QFile valid(":/list-valid-signed.txt");
67 QString fileName = dataDir.absoluteFilePath("list-valid-signed.txt"); 69 valid.open(QIODevice::ReadOnly);
68 validList = CertificateList(fileName.toLocal8Bit().data()); 70 validListFile.open();
71 validListFile.write(valid.readAll());
72 valid.close();
73 validListFile.close();
74 validList = CertificateList(validListFile.fileName().toLocal8Bit().data());
75
76 QVERIFY(validList.isValid());
77
78 QFile invalid(":/list-invalid-signed.txt");
79 invalid.open(QIODevice::ReadOnly);
80 invalidListFile.open();
81 invalidListFile.write(invalid.readAll());
82 invalid.close();
83 invalidListFile.close();
84 invalidList = CertificateList(invalidListFile.fileName().toLocal8Bit().data());
85
86 QVERIFY(!invalidList.isValid());
87
88 QFile other(":/list-valid-other-signature.txt");
89 other.open(QIODevice::ReadOnly);
90 otherListFile.open();
91 otherListFile.write(other.readAll());
92 other.close();
93 otherListFile.close();
94 otherList = CertificateList(otherListFile.fileName().toLocal8Bit().data());
95
96 QVERIFY(!otherList.isValid());
69 } 97 }
70 98
71 void CinstProcessTest::testNoList() { 99 void CinstProcessTest::testNoList() {
72 /* No list */ 100 /* No list */
73 QProcess* installerProcess = startCinstProcess(); 101 QProcess* installerProcess = startCinstProcess();
74 QVERIFY(installerProcess->state() == QProcess::Running); 102 QVERIFY(installerProcess->state() == QProcess::Running);
75 installerProcess->write("-----BEGIN CERTIFICATE LIST-----\r\n");
76 installerProcess->write("-----END CERTIFICATE LIST-----\r\n");
77 103
78 foreach (const Certificate &cert, validList.getCertificates()) { 104 foreach (const Certificate &cert, validList.getCertificates()) {
79 installerProcess->write(cert.base64Line().toLatin1()); 105 installerProcess->write(cert.base64Line().toLatin1());
80 installerProcess->write("\r\n"); 106 installerProcess->write("\r\n");
81 } 107 }

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