[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-39-g487288b

by Andre Heinecke cvs at cvs.gnupg.org
Thu Sep 15 14:46:34 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, nomapi has been updated
       via  487288bf5fe607949913a90d582bc9407d25a0f1 (commit)
       via  4e54e266a582cddbcfd3b88c65822913cbc9d0ce (commit)
       via  a4a113aed3dda2525181796ef4bc5765db0a5391 (commit)
       via  e4ea280498f406a24973d16917a94dea1ff18d06 (commit)
       via  baa0515e7fb4b4ec2ee000afd69096156bc86d9f (commit)
      from  28116b887c2ae7a3f3e12b6dd372fdd5ba341646 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 487288bf5fe607949913a90d582bc9407d25a0f1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 14:45:22 2016 +0200

    Add first real unit test for pgp/inline/encrypted
    
    * tests/Makefile.am: Update GNUPGHOME and data handling.
    * tests/data/inlinepgpencrypted.mbox: New.
    * tests/data/inlinepgpencrypted.plain: New.
    * tests/run-parser.cpp (main): Fix output of bodies.
    * tests/t-parser.cpp (main): Prepare generic tests.
    
    --
    Let's start with a simple one :-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index dfb5222..8df8d27 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,15 +20,14 @@
 
 GPG = gpg
 
-TESTS_ENVIRONMENT = GNUPGHOME=$(abs_srcdir)/tests/gnupg_home
-
-TESTS = initial.test t-parser
+TESTS = t-parser
 
 AM_LDFLAGS = @GPGME_LIBS@ -lgpgmepp
 
 AM_CFLAGS = -I$(top_srcdir)/src $(GPGME_CFLAGS) $(LIBASSUAN_CFLAGS)
 AM_CXXFLAGS = -I$(top_srcdir)/src $(GPGME_CFLAGS) $(GPGME_CFLAGS)/gpgme++ \
-			  $(LIBASSUAN_CFLAGS) -std=c++11
+			  $(LIBASSUAN_CFLAGS) -std=c++11 -DDATADIR=\"$(abs_srcdir)/data\" \
+			  -DGPGHOMEDIR=\"$(abs_srcdir)/gnupg_home\"
 
 parser_SRC= ../src/parsecontroller.cpp \
 			../src/parsecontroller.h \
@@ -43,5 +42,3 @@ t_parser_SOURCES = t-parser.cpp $(parser_SRC)
 run_parser_SOURCES = run-parser.cpp $(parser_SRC)
 
 noinst_PROGRAMS = t-parser run-parser
-
-export GNUPGHOME := $(abs_srcdir)/tests/gnupg_home
diff --git a/tests/data/inlinepgpencrypted.mbox b/tests/data/inlinepgpencrypted.mbox
new file mode 100644
index 0000000..f8347d3
--- /dev/null
+++ b/tests/data/inlinepgpencrypted.mbox
@@ -0,0 +1,28 @@
+From test at kolab.org Wed, 25 May 2011 23:49:40 +0100
+From: OpenPGP Test <test at kolab.org>
+To: test at kolab.org
+Subject: inlinepgpencrypted
+Date: Wed, 25 May 2011 23:49:40 +0100
+Message-ID: <1786696.yKXrOjjflF at herrwackelpudding.localhost>
+X-KMail-Transport: GMX
+X-KMail-Fcc: 28
+X-KMail-Drafts: 7
+X-KMail-Templates: 9
+User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19)
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7Bit
+Content-Type: text/plain; charset="us-ascii"
+
+-----BEGIN PGP MESSAGE-----
+Version: GnuPG v2.0.15 (GNU/Linux)
+
+hQEMAwzOQ1qnzNo7AQf/a3aNTLpQBfcUr+4AKsZQLj4h6z7e7a5AaCW8AG0wrbxN
+kBYB7E5jdZh45DX/99gvoZslthWryUCX2kKZ3LtIllxKVjqNuK5hSt+SAuKkwiMR
+Xcbf1KFKENKupgGSO9B2NJRbjoExdJ+fC3mGXnO3dT7xJJAo3oLE8Nivu+Bj1peY
+E1wCf+vcTwVHFrA7SV8eMRb9Z9wBXmU8Q8e9ekJ7ZsRX3tMeBs6jvscVvfMf6DYY
+N14snZBZuGNKT9a3DPny7IC1S0lHcaam34ogWwMi3FxPGJt/Lg52kARlkF5TDhcP
+N6H0EB/iqDRjOOUoEVm8um5XOSR1FpEiAdD0DON3y9JPATnrYq7sgYZz3BVImYY+
+N/jV8fEiN0a34pcOq8NQedMuOsJHNBS5MtbQH/kJLq0MXBpXekGlHo4MKw0trISc
+Rw3pW6/BFfhPJLni29g9tw==
+=fRFW
+-----END PGP MESSAGE-----
diff --git a/tests/data/inlinepgpencrypted.plain b/tests/data/inlinepgpencrypted.plain
new file mode 100644
index 0000000..7a9ecd0
--- /dev/null
+++ b/tests/data/inlinepgpencrypted.plain
@@ -0,0 +1 @@
+some random text
\ No newline at end of file
diff --git a/tests/run-parser.cpp b/tests/run-parser.cpp
index 5ded8c4..3144d4a 100644
--- a/tests/run-parser.cpp
+++ b/tests/run-parser.cpp
@@ -45,6 +45,7 @@ int main(int argc, char **argv)
   msgtype_t msgtype = MSGTYPE_UNKNOWN;
   FILE *fp_in = NULL;
 
+  putenv ((char*) "GNUPGHOME=" GPGHOMEDIR);
   gpgme_check_version (NULL);
 
   if (argc)
@@ -104,8 +105,8 @@ int main(int argc, char **argv)
   fp_in = fopen (argv[0], "rb");
 
   ParseController parser(fp_in, msgtype);
-  std::cout << "Parse result: " << parser.parse()
-            << "\nDecrypt result:\n" << parser.decrypt_result()
+  std::cout << "Parse result: " << parser.parse();
+  std::cout << "\nDecrypt result:\n" << parser.decrypt_result()
             << "\nVerify result:\n" << parser.verify_result()
             << "\nBEGIN BODY\n" << parser.get_body() << "\nEND BODY"
             << "\nBEGIN HTML\n" << parser.get_html_body() << "\nEND HTML";
diff --git a/tests/t-parser.cpp b/tests/t-parser.cpp
index 6c1d99a..fdef25a 100644
--- a/tests/t-parser.cpp
+++ b/tests/t-parser.cpp
@@ -17,7 +17,118 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <stdio.h>
+#include "parsecontroller.h"
+#include <iostream>
+#include "attachment.h"
+#include <gpgme.h>
+
+struct
+{
+  const char *input_file;
+  msgtype_t type;
+  const char *expected_body_file;
+  const char *expected_html_body_file;
+  const char *expected_return;
+  int attachment_cnt;
+} test_data[] = {
+  { DATADIR "/inlinepgpencrypted.mbox",
+    MSGTYPE_GPGOL_PGP_MESSAGE,
+    DATADIR "/inlinepgpencrypted.plain",
+    NULL,
+    NULL,
+    0 },
+  { NULL, MSGTYPE_UNKNOWN, NULL, NULL, 0 }
+};
+
+
 int main()
 {
-  return 0;
+  int i = 0;
+  putenv ((char*) "GNUPGHOME=" GPGHOMEDIR);
+  gpgme_check_version (NULL);
+
+  while (test_data[i].input_file)
+    {
+      auto input = fopen (test_data[i].input_file, "rb");
+      if (!input)
+        {
+          fprintf (stderr, "Failed to open input file: %s\n",
+                   test_data[i].input_file);
+          exit(1);
+        }
+      ParseController parser (input, test_data[i].type);
+
+      auto result = parser.parse();
+
+      auto decResult = parser.decrypt_result();
+      auto verifyResult = parser.verify_result();
+
+      if (decResult.error() || verifyResult.error())
+        {
+          std::cerr << "Decrypt or verify error:\n"
+                    << decResult
+                    << verifyResult;
+          exit(1);
+        }
+
+      if (test_data[i].expected_return)
+        {
+          if (result != test_data[i].expected_return)
+            {
+              fprintf (stderr, "Failed to get expected return. Return was: %s\n",
+                       result.c_str());
+              exit(1);
+            }
+        }
+      if (test_data[i].expected_body_file)
+        {
+          auto expected_body = fopen (test_data[i].expected_body_file, "rb");
+          if (!expected_body)
+            {
+              fprintf (stderr, "Failed to open input file: %s\n",
+                       test_data[i].expected_body_file);
+              exit(1);
+            }
+          char bodybuf[16000];
+          fread (bodybuf, 1, 16000, expected_body);
+          if (parser.get_body() != bodybuf)
+            {
+              fprintf (stderr, "Body was: \n\"%s\"\nExpected:\n\"%s\"\n",
+                       parser.get_body().c_str(), bodybuf);
+              exit(1);
+            }
+        }
+      if (test_data[i].expected_html_body_file)
+        {
+          auto expected_html_body = fopen (test_data[i].expected_html_body_file, "rb");
+          if (!expected_html_body)
+            {
+              fprintf (stderr, "Failed to open input file: %s\n",
+                       test_data[i].expected_html_body_file);
+              exit(1);
+            }
+          char bodybuf[16000];
+          fread (bodybuf, 1, 16000, expected_html_body);
+          if (parser.get_html_body() != bodybuf)
+            {
+              fprintf (stderr, "HTML was: \n\"%s\"\nExpected:\n\"%s\"\n",
+                       parser.get_html_body().c_str(), bodybuf);
+              exit(1);
+            }
+        }
+      if (test_data[i].attachment_cnt)
+        {
+          int actual = (int)parser.get_attachments().size();
+          if (actual != test_data[i].attachment_cnt)
+            {
+              fprintf (stderr, "Attachment count mismatch. Actual: %i Expected: %i\n",
+                       actual, test_data[i].attachment_cnt);
+              exit(1);
+            }
+        }
+      fprintf (stderr, "Pass: %s\n", test_data[i].input_file);
+      i++;
+    }
+  exit(0);
 }

commit 4e54e266a582cddbcfd3b88c65822913cbc9d0ce
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 14:42:30 2016 +0200

    Use body to decrypt / verify inline msgs
    
    * src/parsecontroller.cpp (parse): Use body for inline msgs.

diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 3d4c405..e9c61a5 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -111,7 +111,20 @@ ParseController::parse()
   ctx->setArmor(true);
 
   Data output(m_outputprovider);
-  Data input(m_inputprovider);
+
+  Data input;
+  if (m_type == MSGTYPE_GPGOL_CLEAR_SIGNED ||
+      m_type == MSGTYPE_GPGOL_PGP_MESSAGE)
+    {
+      /* For clearsigned and PGP Message take the body.
+         This does not copy the data. */
+      input = Data (m_inputprovider->get_body().c_str(),
+                    m_inputprovider->get_body().size(), false);
+    }
+  else
+    {
+      input = Data (m_inputprovider);
+    }
   log_debug ("%s:%s: decrypt: %i verify: %i with protocol: %s",
              SRCNAME, __func__,
              decrypt, verify,

commit a4a113aed3dda2525181796ef4bc5765db0a5391
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 14:40:51 2016 +0200

    Fix FILE read and enable write for mimedataprovider
    
    * src/mimedataprovider.cpp (isSupported): Add write.
    (collect_data(FILE*)): Fix fread call.
    (get_body, get_html_body): Fix truncated output when a mail
    body did not end with a newline.
    * src/mimedataprovider.h: Update accordingly.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index 3f525a9..d75bd51 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -515,6 +515,7 @@ MimeDataProvider::isSupported(GpgME::DataProvider::Operation op) const
 {
   return op == GpgME::DataProvider::Read ||
          op == GpgME::DataProvider::Seek ||
+         op == GpgME::DataProvider::Write ||
          op == GpgME::DataProvider::Release;
 }
 
@@ -738,7 +739,7 @@ MimeDataProvider::collect_data(FILE *stream)
     }
   char buf[BUFSIZE];
   size_t bRead;
-  while ((bRead = fread (buf, BUFSIZE, 1, stream)) > 0)
+  while ((bRead = fread (buf, 1, BUFSIZE, stream)) > 0)
     {
       log_mime_parser ("%s:%s: Read " SIZE_T_FORMAT " bytes.",
                        SRCNAME, __func__, bRead);
@@ -769,7 +770,7 @@ ssize_t MimeDataProvider::write(const void *buffer, size_t bufSize)
     if (not_taken == m_rawbuf.size())
       {
         log_error ("%s:%s: Write failed to consume anything.\n"
-                   "Buffer too small?",
+                   "Buffer too small? or no newlines in text?",
                    SRCNAME, __func__);
         return bufSize;
       }
@@ -820,3 +821,31 @@ MimeDataProvider::create_attachment()
   return attach;
   /* TODO handle encoding */
 }
+
+const std::string &MimeDataProvider::get_body()
+{
+  if (m_rawbuf.size())
+    {
+      /* If there was some data left in the rawbuf this could
+         mean that some plaintext was not finished with a linefeed.
+         In that case we append it to the bodies. */
+      m_body += m_rawbuf;
+      m_html_body += m_rawbuf;
+      m_rawbuf.clear();
+    }
+  return m_body;
+}
+
+const std::string &MimeDataProvider::get_html_body()
+{
+  if (m_rawbuf.size())
+    {
+      /* If there was some data left in the rawbuf this could
+         mean that some plaintext was not finished with a linefeed.
+         In that case we append it to the bodies. */
+      m_body += m_rawbuf;
+      m_html_body += m_rawbuf;
+      m_rawbuf.clear();
+    }
+  return m_html_body;
+}
diff --git a/src/mimedataprovider.h b/src/mimedataprovider.h
index 9f52a88..2311881 100644
--- a/src/mimedataprovider.h
+++ b/src/mimedataprovider.h
@@ -101,8 +101,8 @@ public:
 
   mime_context_t mime_context() {return m_mime_ctx;}
 
-  const std::string get_body() const {return m_body;}
-  const std::string get_html_body() const {return m_html_body;}
+  const std::string &get_body();
+  const std::string &get_html_body();
   const std::vector <std::shared_ptr<Attachment> > get_attachments() const
     {return m_attachments;}
 private:

commit e4ea280498f406a24973d16917a94dea1ff18d06
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 14:38:54 2016 +0200

    Add test gnupg_home from messagelib
    
    * tests/gnupg_home: New.
    --
    Reusing Messagelibs test keys will allow us to reuse
    the same test data as KMail's messagelib uses.

diff --git a/tests/gnupg_home/.gpg-v21-migrated b/tests/gnupg_home/.gpg-v21-migrated
new file mode 100644
index 0000000..e69de29
diff --git a/tests/gnupg_home/dirmngr-cache.d/DIR.txt b/tests/gnupg_home/dirmngr-cache.d/DIR.txt
new file mode 100644
index 0000000..1a45a6b
--- /dev/null
+++ b/tests/gnupg_home/dirmngr-cache.d/DIR.txt
@@ -0,0 +1,3 @@
+v:1:
+c: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::::
+c: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/tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db b/tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db
new file mode 100644
index 0000000..0b7e2dd
Binary files /dev/null and b/tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db differ
diff --git a/tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db b/tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db
new file mode 100644
index 0000000..47474a2
Binary files /dev/null and b/tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db differ
diff --git a/tests/gnupg_home/dirmngr.conf b/tests/gnupg_home/dirmngr.conf
new file mode 100644
index 0000000..a17a035
--- /dev/null
+++ b/tests/gnupg_home/dirmngr.conf
@@ -0,0 +1,8 @@
+
+###+++--- GPGConf ---+++###
+debug-level basic
+log-file socket:///home/leo/kde/src/kdepim/messagecomposer/tests/gnupg_home/log-socket
+###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
+# GPGConf edited this configuration file.
+# It will disable options before this marked block, but it will
+# never change anything below these lines.
diff --git a/tests/gnupg_home/gpg-agent.conf b/tests/gnupg_home/gpg-agent.conf
new file mode 100644
index 0000000..ded0954
--- /dev/null
+++ b/tests/gnupg_home/gpg-agent.conf
@@ -0,0 +1,3 @@
+allow-mark-trusted
+debug-level basic
+faked-system-time 20130110T154812
diff --git a/tests/gnupg_home/gpg.conf b/tests/gnupg_home/gpg.conf
new file mode 100644
index 0000000..ec839d4
--- /dev/null
+++ b/tests/gnupg_home/gpg.conf
@@ -0,0 +1,244 @@
+# Options for GnuPG
+# Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Unless you specify which option file to use (with the command line
+# option "--options filename"), GnuPG uses the file ~/.gnupg/gpg.conf
+# by default.
+#
+# An options file can contain any long options which are available in
+# GnuPG. If the first non white space character of a line is a '#',
+# this line is ignored.  Empty lines are also ignored.
+#
+# See the man page for a list of options.
+
+# Uncomment the following option to get rid of the copyright notice
+
+#no-greeting
+
+# If you have more than 1 secret key in your keyring, you may want to
+# uncomment the following option and set your preferred keyid.
+
+#default-key 621CC013
+
+# If you do not pass a recipient to gpg, it will ask for one.  Using
+# this option you can encrypt to a default key.  Key validation will
+# not be done in this case.  The second form uses the default key as
+# default recipient.
+
+#default-recipient some-user-id
+#default-recipient-self
+
+# Use --encrypt-to to add the specified key as a recipient to all
+# messages.  This is useful, for example, when sending mail through a
+# mail client that does not automatically encrypt mail to your key.
+# In the example, this option allows you to read your local copy of
+# encrypted mail that you've sent to others.
+
+#encrypt-to some-key-id
+
+# By default GnuPG creates version 3 signatures for data files.  This
+# is not strictly OpenPGP compliant but PGP 6 and most versions of PGP
+# 7 require them.  To disable this behavior, you may use this option
+# or --openpgp.
+
+#no-force-v3-sigs
+
+# Because some mailers change lines starting with "From " to ">From "
+# it is good to handle such lines in a special way when creating
+# cleartext signatures; all other PGP versions do it this way too.
+
+#no-escape-from-lines
+
+# If you do not use the Latin-1 (ISO-8859-1) charset, you should tell
+# GnuPG which is the native character set.  Please check the man page
+# for supported character sets.  This character set is only used for
+# metadata and not for the actual message which does not undergo any
+# translation.  Note that future version of GnuPG will change to UTF-8
+# as default character set.  In most cases this option is not required
+# as GnuPG is able to figure out the correct charset at runtime.
+
+#charset utf-8
+
+# Group names may be defined like this:
+#   group mynames = paige 0x12345678 joe patti
+#
+# Any time "mynames" is a recipient (-r or --recipient), it will be
+# expanded to the names "paige", "joe", and "patti", and the key ID
+# "0x12345678".  Note there is only one level of expansion - you
+# cannot make an group that points to another group.  Note also that
+# if there are spaces in the recipient name, this will appear as two
+# recipients.  In these cases it is better to use the key ID.
+
+#group mynames = paige 0x12345678 joe patti
+
+# Lock the file only once for the lifetime of a process.  If you do
+# not define this, the lock will be obtained and released every time
+# it is needed, which is usually preferable.
+
+#lock-once
+
+# GnuPG can send and receive keys to and from a keyserver.  These
+# servers can be HKP, email, or LDAP (if GnuPG is built with LDAP
+# support).
+#
+# Example HKP keyserver:
+#      hkp://keys.gnupg.net
+#      hkp://subkeys.pgp.net
+#
+# Example email keyserver:
+#      mailto:pgp-public-keys at keys.pgp.net
+#
+# Example LDAP keyservers:
+#      ldap://keyserver.pgp.com
+#
+# Regular URL syntax applies, and you can set an alternate port
+# through the usual method:
+#      hkp://keyserver.example.net:22742
+#
+# Most users just set the name and type of their preferred keyserver.
+# Note that most servers (with the notable exception of
+# ldap://keyserver.pgp.com) synchronize changes with each other.  Note
+# also that a single server name may actually point to multiple
+# servers via DNS round-robin.  hkp://keys.gnupg.net is an example of
+# such a "server", which spreads the load over a number of physical
+# servers.  To see the IP address of the server actually used, you may use
+# the "--keyserver-options debug".
+
+keyserver hkp://keys.gnupg.net
+#keyserver mailto:pgp-public-keys at keys.nl.pgp.net
+#keyserver ldap://keyserver.pgp.com
+
+# Common options for keyserver functions:
+#
+# include-disabled : when searching, include keys marked as "disabled"
+#                    on the keyserver (not all keyservers support this).
+#
+# no-include-revoked : when searching, do not include keys marked as
+#                      "revoked" on the keyserver.
+#
+# verbose : show more information as the keys are fetched.
+#           Can be used more than once to increase the amount
+#           of information shown.
+#
+# use-temp-files : use temporary files instead of a pipe to talk to the
+#                  keyserver.  Some platforms (Win32 for one) always
+#                  have this on.
+#
+# keep-temp-files : do not delete temporary files after using them
+#                   (really only useful for debugging)
+#
+# http-proxy="proxy" : set the proxy to use for HTTP and HKP keyservers.
+#                      This overrides the "http_proxy" environment variable,
+#                      if any.
+#
+# auto-key-retrieve : automatically fetch keys as needed from the keyserver
+#                     when verifying signatures or when importing keys that
+#                     have been revoked by a revocation key that is not
+#                     present on the keyring.
+#
+# no-include-attributes : do not include attribute IDs (aka "photo IDs")
+#                         when sending keys to the keyserver.
+
+#keyserver-options auto-key-retrieve
+
+# Display photo user IDs in key listings
+
+# list-options show-photos
+
+# Display photo user IDs when a signature from a key with a photo is
+# verified
+
+# verify-options show-photos
+
+# Use this program to display photo user IDs
+#
+# %i is expanded to a temporary file that contains the photo.
+# %I is the same as %i, but the file isn't deleted afterwards by GnuPG.
+# %k is expanded to the key ID of the key.
+# %K is expanded to the long OpenPGP key ID of the key.
+# %t is expanded to the extension of the image (e.g. "jpg").
+# %T is expanded to the MIME type of the image (e.g. "image/jpeg").
+# %f is expanded to the fingerprint of the key.
+# %% is %, of course.
+#
+# If %i or %I are not present, then the photo is supplied to the
+# viewer on standard input.  If your platform supports it, standard
+# input is the best way to do this as it avoids the time and effort in
+# generating and then cleaning up a secure temp file.
+#
+# If no photo-viewer is provided, GnuPG will look for xloadimage, eog,
+# or display (ImageMagick).  On Mac OS X and Windows, the default is
+# to use your regular JPEG image viewer.
+#
+# Some other viewers:
+# photo-viewer "qiv %i"
+# photo-viewer "ee %i"
+#
+# This one saves a copy of the photo ID in your home directory:
+# photo-viewer "cat > ~/photoid-for-key-%k.%t"
+#
+# Use your MIME handler to view photos:
+# photo-viewer "metamail -q -d -b -c %T -s 'KeyID 0x%k' -f GnuPG"
+
+# Passphrase agent
+#
+# We support the old experimental passphrase agent protocol as well as
+# the new Assuan based one (currently available in the "newpg" package
+# at ftp.gnupg.org/gcrypt/alpha/aegypten/).  To make use of the agent,
+# you have to run an agent as daemon and use the option
+#
+# use-agent
+#
+# which tries to use the agent but will fallback to the regular mode
+# if there is a problem connecting to the agent.  The normal way to
+# locate the agent is by looking at the environment variable
+# GPG_AGENT_INFO which should have been set during gpg-agent startup.
+# In certain situations the use of this variable is not possible, thus
+# the option
+#
+# --gpg-agent-info=<path>:<pid>:1
+#
+# may be used to override it.
+
+# Automatic key location
+#
+# GnuPG can automatically locate and retrieve keys as needed using the
+# auto-key-locate option.  This happens when encrypting to an email
+# address (in the "user at example.com" form), and there are no
+# user at example.com keys on the local keyring.  This option takes the
+# following arguments, in the order they are to be tried:
+#
+# cert = locate a key using DNS CERT, as specified in RFC-4398.
+#        GnuPG can handle both the PGP (key) and IPGP (URL + fingerprint)
+#        CERT methods.
+#
+# pka = locate a key using DNS PKA.
+#
+# ldap = locate a key using the PGP Universal method of checking
+#        "ldap://keys.(thedomain)".  For example, encrypting to
+#        user at example.com will check ldap://keys.example.com.
+#
+# keyserver = locate a key using whatever keyserver is defined using
+#             the keyserver option.
+#
+# You may also list arbitrary keyservers here by URL.
+#
+# Try CERT, then PKA, then LDAP, then hkp://subkeys.net:
+#auto-key-locate cert pka ldap hkp://subkeys.pgp.net
+
+###+++--- GPGConf ---+++###
+utf8-strings
+#debug-level basic
+#log-file socket:///home/leo/kde/src/kdepim/messagecomposer/tests/gnupg_home/log-socket
+###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
+# GPGConf edited this configuration file.
+# It will disable options before this marked block, but it will
+# never change anything below these lines.
diff --git a/tests/gnupg_home/gpgsm.conf b/tests/gnupg_home/gpgsm.conf
new file mode 100644
index 0000000..3783f53
--- /dev/null
+++ b/tests/gnupg_home/gpgsm.conf
@@ -0,0 +1,3 @@
+disable-crl-checks
+debug-level basic
+faked-system-time 20130110T154812
diff --git a/tests/gnupg_home/pinentry-fake.sh b/tests/gnupg_home/pinentry-fake.sh
new file mode 100755
index 0000000..7135a94
--- /dev/null
+++ b/tests/gnupg_home/pinentry-fake.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+echo "OK Your orders please"
+while :
+do
+	read cmd
+	echo "OK"
+	[ "$cmd" = "BYE" ] && break
+done
diff --git a/tests/gnupg_home/private-keys-v1.d/01A7EA42DB00E28D85BB27378D7A47829B63FDB6.key b/tests/gnupg_home/private-keys-v1.d/01A7EA42DB00E28D85BB27378D7A47829B63FDB6.key
new file mode 100644
index 0000000..87619f0
Binary files /dev/null and b/tests/gnupg_home/private-keys-v1.d/01A7EA42DB00E28D85BB27378D7A47829B63FDB6.key differ
diff --git a/tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key b/tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key
new file mode 100644
index 0000000..39ac307
Binary files /dev/null and b/tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key differ
diff --git a/tests/gnupg_home/private-keys-v1.d/3BD9080DE9C88A88A67965B8E49F677004D6F6B7.key b/tests/gnupg_home/private-keys-v1.d/3BD9080DE9C88A88A67965B8E49F677004D6F6B7.key
new file mode 100644
index 0000000..d197aad
Binary files /dev/null and b/tests/gnupg_home/private-keys-v1.d/3BD9080DE9C88A88A67965B8E49F677004D6F6B7.key differ
diff --git a/tests/gnupg_home/private-keys-v1.d/53F70182AE3A9CFDDA3DA5B3A1742B875F43524B.key b/tests/gnupg_home/private-keys-v1.d/53F70182AE3A9CFDDA3DA5B3A1742B875F43524B.key
new file mode 100644
index 0000000..af872d9
Binary files /dev/null and b/tests/gnupg_home/private-keys-v1.d/53F70182AE3A9CFDDA3DA5B3A1742B875F43524B.key differ
diff --git a/tests/gnupg_home/private-keys-v1.d/61A7BB3E7F89151CFB8B18AC27668585CE77A7A7.key b/tests/gnupg_home/private-keys-v1.d/61A7BB3E7F89151CFB8B18AC27668585CE77A7A7.key
new file mode 100644
index 0000000..55b5e89
Binary files /dev/null and b/tests/gnupg_home/private-keys-v1.d/61A7BB3E7F89151CFB8B18AC27668585CE77A7A7.key differ
diff --git a/tests/gnupg_home/private-keys-v1.d/B8E914E1B03F0238FF0A999E69DE8C8D1FDFFFCD.key b/tests/gnupg_home/private-keys-v1.d/B8E914E1B03F0238FF0A999E69DE8C8D1FDFFFCD.key
new file mode 100644
index 0000000..a828627
Binary files /dev/null and b/tests/gnupg_home/private-keys-v1.d/B8E914E1B03F0238FF0A999E69DE8C8D1FDFFFCD.key differ
diff --git a/tests/gnupg_home/private-keys-v1.d/EC06D8C339EF73304D5B2CCF5363B437E0C915F2.key b/tests/gnupg_home/private-keys-v1.d/EC06D8C339EF73304D5B2CCF5363B437E0C915F2.key
new file mode 100644
index 0000000..bb0a4f6
Binary files /dev/null and b/tests/gnupg_home/private-keys-v1.d/EC06D8C339EF73304D5B2CCF5363B437E0C915F2.key differ
diff --git a/tests/gnupg_home/pubring.gpg b/tests/gnupg_home/pubring.gpg
new file mode 100644
index 0000000..2e00fa2
Binary files /dev/null and b/tests/gnupg_home/pubring.gpg differ
diff --git a/tests/gnupg_home/pubring.kbx b/tests/gnupg_home/pubring.kbx
new file mode 100644
index 0000000..0230f31
Binary files /dev/null and b/tests/gnupg_home/pubring.kbx differ
diff --git a/tests/gnupg_home/scdaemon.conf b/tests/gnupg_home/scdaemon.conf
new file mode 100644
index 0000000..a17a035
--- /dev/null
+++ b/tests/gnupg_home/scdaemon.conf
@@ -0,0 +1,8 @@
+
+###+++--- GPGConf ---+++###
+debug-level basic
+log-file socket:///home/leo/kde/src/kdepim/messagecomposer/tests/gnupg_home/log-socket
+###+++--- GPGConf ---+++### Tue 29 Jun 2010 10:23:13 AM EDT
+# GPGConf edited this configuration file.
+# It will disable options before this marked block, but it will
+# never change anything below these lines.
diff --git a/tests/gnupg_home/secring.gpg b/tests/gnupg_home/secring.gpg
new file mode 100644
index 0000000..cfd3387
Binary files /dev/null and b/tests/gnupg_home/secring.gpg differ
diff --git a/tests/gnupg_home/trustdb.gpg b/tests/gnupg_home/trustdb.gpg
new file mode 100644
index 0000000..70089c1
Binary files /dev/null and b/tests/gnupg_home/trustdb.gpg differ
diff --git a/tests/gnupg_home/trustlist.txt b/tests/gnupg_home/trustlist.txt
new file mode 100644
index 0000000..76d47bd
--- /dev/null
+++ b/tests/gnupg_home/trustlist.txt
@@ -0,0 +1,9 @@
+5E:7C:B2:F4:9F:70:05:43:42:32:5D:75:74:70:00:09:B9:D8:08:61 S
+
+
+
+# CN=unittest cert
+# O=KDAB
+# C=US
+# EMail=test at example.com
+24:D2:FC:A2:2E:B3:B8:0A:1E:37:71:D1:4C:C6:58:E3:21:2B:49:DC S

commit baa0515e7fb4b4ec2ee000afd69096156bc86d9f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 15 11:46:52 2016 +0200

    tests: Add messagetypes as command line args
    
    * tests/run-parser.cpp (main): Add cmd line args for msgtype.

diff --git a/tests/run-parser.cpp b/tests/run-parser.cpp
index c7a5b3a..5ded8c4 100644
--- a/tests/run-parser.cpp
+++ b/tests/run-parser.cpp
@@ -28,8 +28,13 @@ show_usage (int ex)
 {
   fputs ("usage: run-parser [options] FILE\n\n"
          "Options:\n"
-         "  --verbose        run in verbose mode\n"
-         "  --type           GPGOL_MESSAGETYPE\n"
+         "  --verbose             run in verbose mode\n"
+         "  --multipart-signed    multipart/signed\n"
+         "  --multipart-encrypted multipart/encrypted\n"
+         "  --opaque-signed       SMIME opaque signed\n"
+         "  --opaque-encrypted    SMIME opaque encrypted\n"
+         "  --clear-signed        clearsigned\n"
+         "  --pgp-message         inline pgp message\n"
          , stderr);
   exit (ex);
 }
@@ -37,7 +42,7 @@ show_usage (int ex)
 int main(int argc, char **argv)
 {
   int last_argc = -1;
-  int msgtype = 0;
+  msgtype_t msgtype = MSGTYPE_UNKNOWN;
   FILE *fp_in = NULL;
 
   gpgme_check_version (NULL);
@@ -58,13 +63,38 @@ int main(int argc, char **argv)
       else if (!strcmp (*argv, "--verbose"))
         {
           opt.enable_debug |= DBG_MIME_PARSER;
+          opt.enable_debug |= 1;
           set_log_file ("stderr");
           argc--; argv++;
         }
-      else if (!strcmp (*argv, "--type"))
+      else if (!strcmp (*argv, "--multipart-signed"))
         {
-          msgtype = atoi (*(argv + 1));
+          msgtype = MSGTYPE_GPGOL_MULTIPART_SIGNED;
           argc--; argv++;
+        }
+      else if (!strcmp (*argv, "--multipart-encrypted"))
+        {
+          msgtype = MSGTYPE_GPGOL_MULTIPART_ENCRYPTED;
+          argc--; argv++;
+        }
+      else if (!strcmp (*argv, "--opaque-signed"))
+        {
+          msgtype = MSGTYPE_GPGOL_OPAQUE_SIGNED;
+          argc--; argv++;
+        }
+      else if (!strcmp (*argv, "--opaque-encrypted"))
+        {
+          msgtype = MSGTYPE_GPGOL_OPAQUE_ENCRYPTED;
+          argc--; argv++;
+        }
+      else if (!strcmp (*argv, "--clear-signed"))
+        {
+          msgtype = MSGTYPE_GPGOL_CLEAR_SIGNED;
+          argc--; argv++;
+        }
+      else if (!strcmp (*argv, "--pgp-message"))
+        {
+          msgtype = MSGTYPE_GPGOL_PGP_MESSAGE;
           argc--; argv++;
         }
     }
@@ -73,12 +103,12 @@ int main(int argc, char **argv)
 
   fp_in = fopen (argv[0], "rb");
 
-  ParseController parser(fp_in, (msgtype_t)msgtype);
-  parser.parse();
-  std::cout << "Decrypt result:\n" << parser.decrypt_result();
-  std::cout << "Verify result:\n" << parser.verify_result();
-  std::cout << "BEGIN BODY\n" << parser.get_body() << "\nEND BODY";
-  std::cout << "BEGIN HTML\n" << parser.get_html_body() << "\nEND HTML";
+  ParseController parser(fp_in, msgtype);
+  std::cout << "Parse result: " << parser.parse()
+            << "\nDecrypt result:\n" << parser.decrypt_result()
+            << "\nVerify result:\n" << parser.verify_result()
+            << "\nBEGIN BODY\n" << parser.get_body() << "\nEND BODY"
+            << "\nBEGIN HTML\n" << parser.get_html_body() << "\nEND HTML";
   for (auto attach: parser.get_attachments())
     {
       std::cout << "Attachment: " << attach->get_display_name();

-----------------------------------------------------------------------

Summary of changes:
 src/mimedataprovider.cpp                           |  33 ++-
 src/mimedataprovider.h                             |   4 +-
 src/parsecontroller.cpp                            |  15 +-
 tests/Makefile.am                                  |   9 +-
 tests/data/inlinepgpencrypted.mbox                 |  28 +++
 tests/data/inlinepgpencrypted.plain                |   1 +
 tests/gnupg_home/.gpg-v21-migrated                 |   0
 tests/gnupg_home/dirmngr-cache.d/DIR.txt           |   3 +
 ...crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db | Bin 0 -> 2130 bytes
 ...crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db | Bin 0 -> 2048 bytes
 tests/gnupg_home/dirmngr.conf                      |   8 +
 tests/gnupg_home/gpg-agent.conf                    |   3 +
 tests/gnupg_home/gpg.conf                          | 244 +++++++++++++++++++++
 tests/gnupg_home/gpgsm.conf                        |   3 +
 tests/gnupg_home/pinentry-fake.sh                  |   9 +
 .../01A7EA42DB00E28D85BB27378D7A47829B63FDB6.key   | Bin 0 -> 797 bytes
 .../1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key   | Bin 0 -> 528 bytes
 .../3BD9080DE9C88A88A67965B8E49F677004D6F6B7.key   | Bin 0 -> 797 bytes
 .../53F70182AE3A9CFDDA3DA5B3A1742B875F43524B.key   | Bin 0 -> 1377 bytes
 .../61A7BB3E7F89151CFB8B18AC27668585CE77A7A7.key   | Bin 0 -> 797 bytes
 .../B8E914E1B03F0238FF0A999E69DE8C8D1FDFFFCD.key   | Bin 0 -> 798 bytes
 .../EC06D8C339EF73304D5B2CCF5363B437E0C915F2.key   | Bin 0 -> 978 bytes
 tests/gnupg_home/pubring.gpg                       | Bin 0 -> 6757 bytes
 tests/gnupg_home/pubring.kbx                       | Bin 0 -> 2017 bytes
 tests/gnupg_home/scdaemon.conf                     |   8 +
 tests/gnupg_home/secring.gpg                       | Bin 0 -> 5163 bytes
 tests/gnupg_home/trustdb.gpg                       | Bin 0 -> 1440 bytes
 tests/gnupg_home/trustlist.txt                     |   9 +
 tests/run-parser.cpp                               |  53 ++++-
 tests/t-parser.cpp                                 | 113 +++++++++-
 30 files changed, 520 insertions(+), 23 deletions(-)
 create mode 100644 tests/data/inlinepgpencrypted.mbox
 create mode 100644 tests/data/inlinepgpencrypted.plain
 create mode 100644 tests/gnupg_home/.gpg-v21-migrated
 create mode 100644 tests/gnupg_home/dirmngr-cache.d/DIR.txt
 create mode 100644 tests/gnupg_home/dirmngr-cache.d/crl-4E31CEB57DDD4A7B9991AB05507B1ED4293FF952.db
 create mode 100644 tests/gnupg_home/dirmngr-cache.d/crl-7F2A402CBB016A9146D613568C89D3596A4111AA.db
 create mode 100644 tests/gnupg_home/dirmngr.conf
 create mode 100644 tests/gnupg_home/gpg-agent.conf
 create mode 100644 tests/gnupg_home/gpg.conf
 create mode 100644 tests/gnupg_home/gpgsm.conf
 create mode 100755 tests/gnupg_home/pinentry-fake.sh
 create mode 100644 tests/gnupg_home/private-keys-v1.d/01A7EA42DB00E28D85BB27378D7A47829B63FDB6.key
 create mode 100644 tests/gnupg_home/private-keys-v1.d/1AA8BA52430E51AE249AF0DA97D59F869E4101A8.key
 create mode 100644 tests/gnupg_home/private-keys-v1.d/3BD9080DE9C88A88A67965B8E49F677004D6F6B7.key
 create mode 100644 tests/gnupg_home/private-keys-v1.d/53F70182AE3A9CFDDA3DA5B3A1742B875F43524B.key
 create mode 100644 tests/gnupg_home/private-keys-v1.d/61A7BB3E7F89151CFB8B18AC27668585CE77A7A7.key
 create mode 100644 tests/gnupg_home/private-keys-v1.d/B8E914E1B03F0238FF0A999E69DE8C8D1FDFFFCD.key
 create mode 100644 tests/gnupg_home/private-keys-v1.d/EC06D8C339EF73304D5B2CCF5363B437E0C915F2.key
 create mode 100644 tests/gnupg_home/pubring.gpg
 create mode 100644 tests/gnupg_home/pubring.kbx
 create mode 100644 tests/gnupg_home/scdaemon.conf
 create mode 100644 tests/gnupg_home/secring.gpg
 create mode 100644 tests/gnupg_home/trustdb.gpg
 create mode 100644 tests/gnupg_home/trustlist.txt


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list