comparison ui/tests/binverifytest.cpp @ 636:2fd4f9980a2a

Add test for authenticode verificate (binverify) Still incomplete
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 23 Jun 2014 18:00:45 +0200
parents
children be30d50bc4f0
comparison
equal deleted inserted replaced
635:ed1887be5170 636:2fd4f9980a2a
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=2)
5 * and comes with ABSOLUTELY NO WARRANTY!
6 * See LICENSE.txt for details.
7 */
8 #include "binverify.h"
9 #include "binverifytest.h"
10
11 #include <QTest>
12
13 #ifdef Q_OS_WIN
14 # define EXE_SUFFIX ".exe"
15 #else
16 # define EXE_SUFFIX ""
17 #endif
18
19 /* Some general robustness checks */
20 void BinVerifyTest::testMiscErrors()
21 {
22 QVERIFY (verify_binary (NULL, 10) != VerifyValid);
23 QVERIFY (verify_binary ("foo", 10) != VerifyValid);
24 QVERIFY (verify_binary ("bar", -1) != VerifyValid);
25 /* On windows the next line will check that a valid microsoft
26 * signed executable is not valid for us (pinning). On linux
27 * it will just fail with a read error. */
28 QVERIFY (verify_binary ("c:\\Windows\\System32\\mmc.exe",
29 strlen("c:\\Windows\\System32\\mmc.exe")) != VerifyValid);
30 QVERIFY (verify_binary ("/dev/null", strlen("/dev/null")) != VerifyValid);
31 }
32
33 /* Check that no signature is not validated */
34 /* Check that an invalid signature is not validated */
35 /* Check that a signature with only a different key (of the same size)
36 * is not validated */
37 /* Check that a signature with a different certificate is not validated */
38 void BinVerifyTest::testNoSignature()
39 {
40 QVERIFY(VerifyInvalidSignature == verify_binary ("fakeinst" EXE_SUFFIX,
41 strlen("fakeinst" EXE_SUFFIX)));
42 }
43
44 /* Check that a valid signed executable is verified */
45 void BinVerifyTest::testValidBinary()
46 {
47 QVERIFY (VerifyValid == verify_binary ("fakeinst-signed" EXE_SUFFIX,
48 strlen("fakeinst-signed" EXE_SUFFIX)));
49 }
50
51 QTEST_GUILESS_MAIN (BinVerifyTest);

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