summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/domain/mimetreeparser/tests/CMakeLists.txt6
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/CMakeLists.txt10
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/DIR.txt3
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.dbbin0 -> 2130 bytes
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.dbbin0 -> 2048 bytes
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/dirmngr.conf8
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/gpg-agent.conf.in10
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/gpg.conf244
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/gpgsm.conf.in10
-rwxr-xr-xframework/domain/mimetreeparser/tests/gnupg_home/pinentry-fake.sh9
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.keybin0 -> 528 bytes
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/pubring.gpgbin0 -> 6757 bytes
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/pubring.kbxbin0 -> 2017 bytes
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/scdaemon.conf8
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/secring.gpgbin0 -> 5163 bytes
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/trustdb.gpgbin0 -> 1440 bytes
-rw-r--r--framework/domain/mimetreeparser/tests/gnupg_home/trustlist.txt11
-rw-r--r--framework/domain/mimetreeparser/tests/interfacetest.cpp21
-rw-r--r--framework/domain/mimetreeparser/tests/kdepim_add_gpg_crypto_test.cmake60
-rw-r--r--framework/domain/mimetreeparser/tests/kdepim_generate_crypto_test_wrapper.cmake45
20 files changed, 442 insertions, 3 deletions
diff --git a/framework/domain/mimetreeparser/tests/CMakeLists.txt b/framework/domain/mimetreeparser/tests/CMakeLists.txt
index d3549215..7945c5a0 100644
--- a/framework/domain/mimetreeparser/tests/CMakeLists.txt
+++ b/framework/domain/mimetreeparser/tests/CMakeLists.txt
@@ -1,10 +1,12 @@
1add_subdirectory(gnupg_home)
1add_definitions( -DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" ) 2add_definitions( -DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
3include(${CMAKE_CURRENT_SOURCE_DIR}/kdepim_add_gpg_crypto_test.cmake)
2include_directories( 4include_directories(
3 ${CMAKE_CURRENT_BINARY_DIR} 5 ${CMAKE_CURRENT_BINARY_DIR}
4 ${CMAKE_CURRENT_SOURCE_DIR}/.. 6 ${CMAKE_CURRENT_SOURCE_DIR}/..
5 ) 7 )
6 8
7add_executable(mimetreeparsertest interfacetest.cpp) 9add_executable(mimetreeparsertest interfacetest.cpp)
8add_test(mimetreeparsertest mimetreeparsertest) 10add_gpg_crypto_test(mimetreeparsertest mimetreeparsertest)
9qt5_use_modules(mimetreeparsertest Core Test) 11qt5_use_modules(mimetreeparsertest Core Test)
10target_link_libraries(mimetreeparsertest mimetreeparser) \ No newline at end of file 12target_link_libraries(mimetreeparsertest mimetreeparser)
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/CMakeLists.txt b/framework/domain/mimetreeparser/tests/gnupg_home/CMakeLists.txt
new file mode 100644
index 00000000..9c64a008
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/CMakeLists.txt
@@ -0,0 +1,10 @@
1configure_file( gpg-agent.conf.in
2 "${CMAKE_CURRENT_BINARY_DIR}/gpg-agent.conf" @ONLY )
3
4configure_file( gpgsm.conf.in
5 "${CMAKE_CURRENT_BINARY_DIR}/gpgsm.conf" @ONLY )
6
7file( COPY
8 ${CMAKE_CURRENT_SOURCE_DIR}
9 DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/../"
10)
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/DIR.txt b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/DIR.txt
new file mode 100644
index 00000000..1a45a6b3
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/DIR.txt
@@ -0,0 +1,3 @@
1v:1:
2c:4E31CEB57DDD4A7B9991AB05507B1ED4293FF952:CN=Test-ZS 7,O=Intevation GmbH,C=DE:ldap%3A//ca.intevation.org/cn=Test-ZS 7, o=Intevation GmbH, c=DE?certificateRevocationList:20100615T181523:20100707T181523:72FEF3FD88455A1D4C6796A6499D4422::::
3c:7F2A402CBB016A9146D613568C89D3596A4111AA:CN=Wurzel ZS 3,O=Intevation GmbH,C=DE:ldap%3A//ca.intevation.org/cn=Wurzel ZS 3, o=Intevation GmbH, c=DE?certificateRevocationList:20100625T102134:20100814T102134:44E60EEC02EF2FBF7A5C77E9BD565667::::
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db
new file mode 100644
index 00000000..0b7e2dd4
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db
Binary files differ
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db
new file mode 100644
index 00000000..47474a26
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db
Binary files differ
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr.conf b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr.conf
new file mode 100644
index 00000000..a17a0354
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/dirmngr.conf
@@ -0,0 +1,8 @@
1
2###+++--- GPGConf ---+++###
3debug-level basic
4log-file socket:///home/leo/kde/src/kdepim/messagecomposer/tests/gnupg_home/log-socket
5###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
6# GPGConf edited this configuration file.
7# It will disable options before this marked block, but it will
8# never change anything below these lines.
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/gpg-agent.conf.in b/framework/domain/mimetreeparser/tests/gnupg_home/gpg-agent.conf.in
new file mode 100644
index 00000000..ece69255
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/gpg-agent.conf.in
@@ -0,0 +1,10 @@
1pinentry-program @CMAKE_CURRENT_BINARY_DIR@/pinentry-fake.sh
2###+++--- GPGConf ---+++###
3allow-mark-trusted
4debug-level basic
5faked-system-time 20130110T154812
6log-file @CMAKE_CURRENT_BINARY_DIR@/gpg-agent.log
7###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
8# GPGConf edited this configuration file.
9# It will disable options before this marked block, but it will
10# never change anything below these lines.
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/gpg.conf b/framework/domain/mimetreeparser/tests/gnupg_home/gpg.conf
new file mode 100644
index 00000000..f1760823
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/gpg.conf
@@ -0,0 +1,244 @@
1# Options for GnuPG
2# Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3#
4# This file is free software; as a special exception the author gives
5# unlimited permission to copy and/or distribute it, with or without
6# modifications, as long as this notice is preserved.
7#
8# This file is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11#
12# Unless you specify which option file to use (with the command line
13# option "--options filename"), GnuPG uses the file ~/.gnupg/gpg.conf
14# by default.
15#
16# An options file can contain any long options which are available in
17# GnuPG. If the first non white space character of a line is a '#',
18# this line is ignored. Empty lines are also ignored.
19#
20# See the man page for a list of options.
21
22# Uncomment the following option to get rid of the copyright notice
23
24#no-greeting
25
26# If you have more than 1 secret key in your keyring, you may want to
27# uncomment the following option and set your preferred keyid.
28
29#default-key 621CC013
30
31# If you do not pass a recipient to gpg, it will ask for one. Using
32# this option you can encrypt to a default key. Key validation will
33# not be done in this case. The second form uses the default key as
34# default recipient.
35
36#default-recipient some-user-id
37#default-recipient-self
38
39# Use --encrypt-to to add the specified key as a recipient to all
40# messages. This is useful, for example, when sending mail through a
41# mail client that does not automatically encrypt mail to your key.
42# In the example, this option allows you to read your local copy of
43# encrypted mail that you've sent to others.
44
45#encrypt-to some-key-id
46
47# By default GnuPG creates version 3 signatures for data files. This
48# is not strictly OpenPGP compliant but PGP 6 and most versions of PGP
49# 7 require them. To disable this behavior, you may use this option
50# or --openpgp.
51
52#no-force-v3-sigs
53
54# Because some mailers change lines starting with "From " to ">From "
55# it is good to handle such lines in a special way when creating
56# cleartext signatures; all other PGP versions do it this way too.
57
58#no-escape-from-lines
59
60# If you do not use the Latin-1 (ISO-8859-1) charset, you should tell
61# GnuPG which is the native character set. Please check the man page
62# for supported character sets. This character set is only used for
63# metadata and not for the actual message which does not undergo any
64# translation. Note that future version of GnuPG will change to UTF-8
65# as default character set. In most cases this option is not required
66# as GnuPG is able to figure out the correct charset at runtime.
67
68#charset utf-8
69
70# Group names may be defined like this:
71# group mynames = paige 0x12345678 joe patti
72#
73# Any time "mynames" is a recipient (-r or --recipient), it will be
74# expanded to the names "paige", "joe", and "patti", and the key ID
75# "0x12345678". Note there is only one level of expansion - you
76# cannot make an group that points to another group. Note also that
77# if there are spaces in the recipient name, this will appear as two
78# recipients. In these cases it is better to use the key ID.
79
80#group mynames = paige 0x12345678 joe patti
81
82# Lock the file only once for the lifetime of a process. If you do
83# not define this, the lock will be obtained and released every time
84# it is needed, which is usually preferable.
85
86#lock-once
87
88# GnuPG can send and receive keys to and from a keyserver. These
89# servers can be HKP, email, or LDAP (if GnuPG is built with LDAP
90# support).
91#
92# Example HKP keyserver:
93# hkp://keys.gnupg.net
94# hkp://subkeys.pgp.net
95#
96# Example email keyserver:
97# mailto:pgp-public-keys@keys.pgp.net
98#
99# Example LDAP keyservers:
100# ldap://keyserver.pgp.com
101#
102# Regular URL syntax applies, and you can set an alternate port
103# through the usual method:
104# hkp://keyserver.example.net:22742
105#
106# Most users just set the name and type of their preferred keyserver.
107# Note that most servers (with the notable exception of
108# ldap://keyserver.pgp.com) synchronize changes with each other. Note
109# also that a single server name may actually point to multiple
110# servers via DNS round-robin. hkp://keys.gnupg.net is an example of
111# such a "server", which spreads the load over a number of physical
112# servers. To see the IP address of the server actually used, you may use
113# the "--keyserver-options debug".
114
115keyserver hkp://keys.gnupg.net
116#keyserver mailto:pgp-public-keys@keys.nl.pgp.net
117#keyserver ldap://keyserver.pgp.com
118
119# Common options for keyserver functions:
120#
121# include-disabled : when searching, include keys marked as "disabled"
122# on the keyserver (not all keyservers support this).
123#
124# no-include-revoked : when searching, do not include keys marked as
125# "revoked" on the keyserver.
126#
127# verbose : show more information as the keys are fetched.
128# Can be used more than once to increase the amount
129# of information shown.
130#
131# use-temp-files : use temporary files instead of a pipe to talk to the
132# keyserver. Some platforms (Win32 for one) always
133# have this on.
134#
135# keep-temp-files : do not delete temporary files after using them
136# (really only useful for debugging)
137#
138# http-proxy="proxy" : set the proxy to use for HTTP and HKP keyservers.
139# This overrides the "http_proxy" environment variable,
140# if any.
141#
142# auto-key-retrieve : automatically fetch keys as needed from the keyserver
143# when verifying signatures or when importing keys that
144# have been revoked by a revocation key that is not
145# present on the keyring.
146#
147# no-include-attributes : do not include attribute IDs (aka "photo IDs")
148# when sending keys to the keyserver.
149
150#keyserver-options auto-key-retrieve
151
152# Display photo user IDs in key listings
153
154# list-options show-photos
155
156# Display photo user IDs when a signature from a key with a photo is
157# verified
158
159# verify-options show-photos
160
161# Use this program to display photo user IDs
162#
163# %i is expanded to a temporary file that contains the photo.
164# %I is the same as %i, but the file isn't deleted afterwards by GnuPG.
165# %k is expanded to the key ID of the key.
166# %K is expanded to the long OpenPGP key ID of the key.
167# %t is expanded to the extension of the image (e.g. "jpg").
168# %T is expanded to the MIME type of the image (e.g. "image/jpeg").
169# %f is expanded to the fingerprint of the key.
170# %% is %, of course.
171#
172# If %i or %I are not present, then the photo is supplied to the
173# viewer on standard input. If your platform supports it, standard
174# input is the best way to do this as it avoids the time and effort in
175# generating and then cleaning up a secure temp file.
176#
177# If no photo-viewer is provided, GnuPG will look for xloadimage, eog,
178# or display (ImageMagick). On Mac OS X and Windows, the default is
179# to use your regular JPEG image viewer.
180#
181# Some other viewers:
182# photo-viewer "qiv %i"
183# photo-viewer "ee %i"
184#
185# This one saves a copy of the photo ID in your home directory:
186# photo-viewer "cat > ~/photoid-for-key-%k.%t"
187#
188# Use your MIME handler to view photos:
189# photo-viewer "metamail -q -d -b -c %T -s 'KeyID 0x%k' -f GnuPG"
190
191# Passphrase agent
192#
193# We support the old experimental passphrase agent protocol as well as
194# the new Assuan based one (currently available in the "newpg" package
195# at ftp.gnupg.org/gcrypt/alpha/aegypten/). To make use of the agent,
196# you have to run an agent as daemon and use the option
197#
198# use-agent
199#
200# which tries to use the agent but will fallback to the regular mode
201# if there is a problem connecting to the agent. The normal way to
202# locate the agent is by looking at the environment variable
203# GPG_AGENT_INFO which should have been set during gpg-agent startup.
204# In certain situations the use of this variable is not possible, thus
205# the option
206#
207# --gpg-agent-info=<path>:<pid>:1
208#
209# may be used to override it.
210
211# Automatic key location
212#
213# GnuPG can automatically locate and retrieve keys as needed using the
214# auto-key-locate option. This happens when encrypting to an email
215# address (in the "user@example.com" form), and there are no
216# user@example.com keys on the local keyring. This option takes the
217# following arguments, in the order they are to be tried:
218#
219# cert = locate a key using DNS CERT, as specified in RFC-4398.
220# GnuPG can handle both the PGP (key) and IPGP (URL + fingerprint)
221# CERT methods.
222#
223# pka = locate a key using DNS PKA.
224#
225# ldap = locate a key using the PGP Universal method of checking
226# "ldap://keys.(thedomain)". For example, encrypting to
227# user@example.com will check ldap://keys.example.com.
228#
229# keyserver = locate a key using whatever keyserver is defined using
230# the keyserver option.
231#
232# You may also list arbitrary keyservers here by URL.
233#
234# Try CERT, then PKA, then LDAP, then hkp://subkeys.net:
235#auto-key-locate cert pka ldap hkp://subkeys.pgp.net
236
237###+++--- GPGConf ---+++###
238utf8-strings
239#debug-level basic
240#log-file socket:///home/leo/kde/src/kdepim/messagecomposer/tests/gnupg_home/log-socket
241###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
242# GPGConf edited this configuration file.
243# It will disable options before this marked block, but it will
244# never change anything below these lines.
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/gpgsm.conf.in b/framework/domain/mimetreeparser/tests/gnupg_home/gpgsm.conf.in
new file mode 100644
index 00000000..92b6119d
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/gpgsm.conf.in
@@ -0,0 +1,10 @@
1
2###+++--- GPGConf ---+++###
3disable-crl-checks
4debug-level basic
5faked-system-time 20130110T154812
6log-file @CMAKE_CURRENT_BINARY_DIR@/gpgsm.log
7###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
8# GPGConf edited this configuration file.
9# It will disable options before this marked block, but it will
10# never change anything below these lines.
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/pinentry-fake.sh b/framework/domain/mimetreeparser/tests/gnupg_home/pinentry-fake.sh
new file mode 100755
index 00000000..7135a942
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/pinentry-fake.sh
@@ -0,0 +1,9 @@
1#!/bin/sh
2
3echo "OK Your orders please"
4while :
5do
6 read cmd
7 echo "OK"
8 [ "$cmd" = "BYE" ] && break
9done
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key b/framework/domain/mimetreeparser/tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key
new file mode 100644
index 00000000..39ac307b
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key
Binary files differ
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/pubring.gpg b/framework/domain/mimetreeparser/tests/gnupg_home/pubring.gpg
new file mode 100644
index 00000000..2e00fa24
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/pubring.gpg
Binary files differ
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/pubring.kbx b/framework/domain/mimetreeparser/tests/gnupg_home/pubring.kbx
new file mode 100644
index 00000000..0230f313
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/pubring.kbx
Binary files differ
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/scdaemon.conf b/framework/domain/mimetreeparser/tests/gnupg_home/scdaemon.conf
new file mode 100644
index 00000000..a17a0354
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/scdaemon.conf
@@ -0,0 +1,8 @@
1
2###+++--- GPGConf ---+++###
3debug-level basic
4log-file socket:///home/leo/kde/src/kdepim/messagecomposer/tests/gnupg_home/log-socket
5###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
6# GPGConf edited this configuration file.
7# It will disable options before this marked block, but it will
8# never change anything below these lines.
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/secring.gpg b/framework/domain/mimetreeparser/tests/gnupg_home/secring.gpg
new file mode 100644
index 00000000..cfd3387d
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/secring.gpg
Binary files differ
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/trustdb.gpg b/framework/domain/mimetreeparser/tests/gnupg_home/trustdb.gpg
new file mode 100644
index 00000000..70089c15
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/trustdb.gpg
Binary files differ
diff --git a/framework/domain/mimetreeparser/tests/gnupg_home/trustlist.txt b/framework/domain/mimetreeparser/tests/gnupg_home/trustlist.txt
new file mode 100644
index 00000000..bbb0442d
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/gnupg_home/trustlist.txt
@@ -0,0 +1,11 @@
15E:7C:B2:F4:9F:70:05:43:42:32:5D:75:74:70:00:09:B9:D8:08:61 S
2
3
4
5# CN=unittest cert
6# O=KDAB
7# C=US
8# EMail=test@example.com
924:D2:FC:A2:2E:B3:B8:0A:1E:37:71:D1:4C:C6:58:E3:21:2B:49:DC S
10
11
diff --git a/framework/domain/mimetreeparser/tests/interfacetest.cpp b/framework/domain/mimetreeparser/tests/interfacetest.cpp
index 83de97f7..615d5742 100644
--- a/framework/domain/mimetreeparser/tests/interfacetest.cpp
+++ b/framework/domain/mimetreeparser/tests/interfacetest.cpp
@@ -30,6 +30,19 @@ QByteArray readMailFromFile(const QString &mailFile)
30 return file.readAll(); 30 return file.readAll();
31} 31}
32 32
33QByteArray join(QVector<QByteArray> vec, QByteArray sep)
34{
35 QByteArray ret;
36 bool bInit = true;
37 foreach(const auto &entry, vec) {
38 if (!bInit) {
39 ret += sep;
40 }
41 bInit = false;
42 ret += entry;
43 }
44 return ret;
45}
33 46
34class InterfaceTest : public QObject 47class InterfaceTest : public QObject
35{ 48{
@@ -38,7 +51,10 @@ private:
38 void printTree(const Part::Ptr &start, QString pre) 51 void printTree(const Part::Ptr &start, QString pre)
39 { 52 {
40 foreach (const auto &part, start->subParts()) { 53 foreach (const auto &part, start->subParts()) {
41 qWarning() << QStringLiteral("%1* %2").arg(pre).arg(QString::fromLatin1(part->type())); 54 qWarning() << QStringLiteral("%1* %2(%3)")
55 .arg(pre)
56 .arg(QString::fromLatin1(part->type()))
57 .arg(QString::fromLatin1(join(part->availableContents(),", ")));
42 printTree(part,pre + QStringLiteral(" ")); 58 printTree(part,pre + QStringLiteral(" "));
43 } 59 }
44 } 60 }
@@ -48,6 +64,7 @@ private slots:
48 void testTextMail() 64 void testTextMail()
49 { 65 {
50 Parser parser(readMailFromFile("plaintext.mbox")); 66 Parser parser(readMailFromFile("plaintext.mbox"));
67 printTree(parser.d->mTree,QString());
51 auto contentPartList = parser.collectContentParts(); 68 auto contentPartList = parser.collectContentParts();
52 QCOMPARE(contentPartList.size(), 1); 69 QCOMPARE(contentPartList.size(), 1);
53 auto contentPart = contentPartList[0]; 70 auto contentPart = contentPartList[0];
@@ -67,6 +84,7 @@ private slots:
67 void testTextAlternative() 84 void testTextAlternative()
68 { 85 {
69 Parser parser(readMailFromFile("alternative.mbox")); 86 Parser parser(readMailFromFile("alternative.mbox"));
87 printTree(parser.d->mTree,QString());
70 auto contentPartList = parser.collectContentParts(); 88 auto contentPartList = parser.collectContentParts();
71 QCOMPARE(contentPartList.size(), 1); 89 QCOMPARE(contentPartList.size(), 1);
72 auto contentPart = contentPartList[0]; 90 auto contentPart = contentPartList[0];
@@ -90,6 +108,7 @@ private slots:
90 void testTextHtml() 108 void testTextHtml()
91 { 109 {
92 Parser parser(readMailFromFile("html.mbox")); 110 Parser parser(readMailFromFile("html.mbox"));
111 printTree(parser.d->mTree,QString());
93 auto contentPartList = parser.collectContentParts(); 112 auto contentPartList = parser.collectContentParts();
94 QCOMPARE(contentPartList.size(), 1); 113 QCOMPARE(contentPartList.size(), 1);
95 auto contentPart = contentPartList[0]; 114 auto contentPart = contentPartList[0];
diff --git a/framework/domain/mimetreeparser/tests/kdepim_add_gpg_crypto_test.cmake b/framework/domain/mimetreeparser/tests/kdepim_add_gpg_crypto_test.cmake
new file mode 100644
index 00000000..17078202
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/kdepim_add_gpg_crypto_test.cmake
@@ -0,0 +1,60 @@
1# Copyright (c) 2013 Sandro Knauß <mail@sandroknauss.de>
2#
3# Redistribution and use is allowed according to the terms of the BSD license.
4# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
5
6set( GNUPGHOME ${CMAKE_BINARY_DIR}/framework/domain/mimetreeparser/tests/gnupg_home )
7add_definitions( -DGNUPGHOME="\\"${GNUPGHOME}\\"" )
8
9macro (ADD_GPG_CRYPTO_TEST _target _testname)
10 if (UNIX)
11 if (APPLE)
12 set(_library_path_variable "DYLD_LIBRARY_PATH")
13 elseif (CYGWIN)
14 set(_library_path_variable "PATH")
15 else (APPLE)
16 set(_library_path_variable "LD_LIBRARY_PATH")
17 endif (APPLE)
18
19 if (APPLE)
20 # DYLD_LIBRARY_PATH does not work like LD_LIBRARY_PATH
21 # OSX already has the RPATH in libraries and executables, putting runtime directories in
22 # DYLD_LIBRARY_PATH actually breaks things
23 set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/")
24 else (APPLE)
25 set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/:${LIB_INSTALL_DIR}:${QT_LIBRARY_DIR}")
26 endif (APPLE)
27 set(_executable "$<TARGET_FILE:${_target}>")
28
29 # use add_custom_target() to have the sh-wrapper generated during build time instead of cmake time
30 add_custom_command(TARGET ${_target} POST_BUILD
31 COMMAND ${CMAKE_COMMAND}
32 -D_filename=${_executable}.shell -D_library_path_variable=${_library_path_variable}
33 -D_ld_library_path="${_ld_library_path}" -D_executable=$<TARGET_FILE:${_target}>
34 -D_gnupghome="${GNUPGHOME}"
35 -P ${CMAKE_SOURCE_DIR}/framework/domain/mimetreeparser/tests/kdepim_generate_crypto_test_wrapper.cmake
36 )
37
38 set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_executable}.shell" )
39 add_test(NAME ${_testname} COMMAND ${_executable}.shell)
40
41 else (UNIX)
42 # under windows, set the property WRAPPER_SCRIPT just to the name of the executable
43 # maybe later this will change to a generated batch file (for setting the PATH so that the Qt libs are found)
44 set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}\;${LIB_INSTALL_DIR}\;${QT_LIBRARY_DIR}")
45 set(_executable "$<TARGET_FILE:${_target}>")
46
47 # use add_custom_target() to have the batch-file-wrapper generated during build time instead of cmake time
48 add_custom_command(TARGET ${_target} POST_BUILD
49 COMMAND ${CMAKE_COMMAND}
50 -D_filename="${_executable}.bat"
51 -D_ld_library_path="${_ld_library_path}" -D_executable="${_executable}"
52 -D_gnupghome="${GNUPGHOME}"
53 -P ${CMAKE_SOURCE_DIR}/framework/domain/mimetreeparser/tests/kdepim_generate_crypto_test_wrapper.cmake
54 )
55
56 add_test(NAME ${_testname} COMMAND ${_executable}.bat)
57
58 endif (UNIX)
59endmacro (ADD_GPG_CRYPTO_TEST)
60
diff --git a/framework/domain/mimetreeparser/tests/kdepim_generate_crypto_test_wrapper.cmake b/framework/domain/mimetreeparser/tests/kdepim_generate_crypto_test_wrapper.cmake
new file mode 100644
index 00000000..e1412f37
--- /dev/null
+++ b/framework/domain/mimetreeparser/tests/kdepim_generate_crypto_test_wrapper.cmake
@@ -0,0 +1,45 @@
1# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
2# Copyright (c) 2013, Sandro Knauß <mail@sandroknauss.de>
3#
4# Redistribution and use is allowed according to the terms of the BSD license.
5# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
6
7
8if (UNIX)
9
10file(WRITE "${_filename}"
11"#!/bin/sh
12# created by cmake, don't edit, changes will be lost
13
14# don't mess with a gpg-agent already running on the system
15unset GPG_AGENT_INFO
16
17${_library_path_variable}=${_ld_library_path}\${${_library_path_variable}:+:\$${_library_path_variable}} GNUPGHOME=${_gnupghome} gpg-agent --daemon \"${_executable}\" \"$@\"
18_result=$?
19_pid=`echo GETINFO pid | GNUPGHOME=${_gnupghome} gpg-connect-agent | grep 'D' | cut -d' ' -f2`
20if [ ! -z \"\$_pid\" ]; then
21 echo \"Waiting for gpg-agent to terminate (PID: $_pid)...\"
22 while kill -0 \"\$_pid\"; do
23 sleep 1
24 done
25fi
26exit \$_result
27")
28
29# make it executable
30# since this is only executed on UNIX, it is safe to call chmod
31exec_program(chmod ARGS ug+x \"${_filename}\" OUTPUT_VARIABLE _dummy )
32
33else (UNIX)
34
35file(TO_NATIVE_PATH "${_ld_library_path}" win_path)
36file(TO_NATIVE_PATH "${_gnupghome}" win_gnupghome)
37
38file(WRITE "${_filename}"
39"
40set PATH=${win_path};$ENV{PATH}
41set GNUPGHOME=${win_gnupghome};$ENV{GNUPGHOME}
42gpg-agent --daemon \"${_executable}\" %*
43")
44
45endif (UNIX)