aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpg/t-sig-notation.c
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-09-12 12:53:08 +0000
committerJustus Winter <[email protected]>2016-09-12 12:56:07 +0000
commita0263ad282d350b548cbbc27e96f196d9217d040 (patch)
tree086c0bd6234ff613bc5f6cbe239171a5b2169538 /tests/gpg/t-sig-notation.c
parentqt: Fix some includes (diff)
downloadgpgme-a0263ad282d350b548cbbc27e96f196d9217d040.tar.gz
gpgme-a0263ad282d350b548cbbc27e96f196d9217d040.zip
tests: Make signature notation test compatible with older GnuPGs.
* lang/python/tests/t-sig-notation.py: Only check the critical flag when GnuPG >= 2.1.13 is used. * tests/gpg/t-sig-notation.c: Likewise. Fixes-commit: c88c9ef3 Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'tests/gpg/t-sig-notation.c')
-rw-r--r--tests/gpg/t-sig-notation.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/gpg/t-sig-notation.c b/tests/gpg/t-sig-notation.c
index 843606a5..798ad24f 100644
--- a/tests/gpg/t-sig-notation.c
+++ b/tests/gpg/t-sig-notation.c
@@ -24,6 +24,7 @@
#include <config.h>
#endif
+#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -33,6 +34,11 @@
#include "t-support.h"
+
+/* GnuPG prior to 2.1.13 did not report the critical flag
+ correctly. */
+int have_correct_sig_data;
+
static struct {
const char *name;
const char *value;
@@ -83,11 +89,17 @@ check_result (gpgme_verify_result_t result)
&& r->value
&& !strcmp (r->value, expected_notations[i].value)
&& r->value_len == strlen (expected_notations[i].value)
- && r->flags == expected_notations[i].flags
+ && r->flags
+ == (have_correct_sig_data
+ ? expected_notations[i].flags
+ : expected_notations[i].flags
+ & ~GPGME_SIG_NOTATION_CRITICAL)
&& r->human_readable
== !!(r->flags & GPGME_SIG_NOTATION_HUMAN_READABLE)
&& r->critical
- == !!(r->flags & GPGME_SIG_NOTATION_CRITICAL))
+ == (have_correct_sig_data
+ ? !!(r->flags & GPGME_SIG_NOTATION_CRITICAL)
+ : 0))
{
expected_notations[i].seen++;
any++;
@@ -121,9 +133,25 @@ main (int argc, char *argv[])
gpgme_verify_result_t result;
char *agent_info;
int i;
+ gpgme_engine_info_t engine_info;
init_gpgme (GPGME_PROTOCOL_OpenPGP);
+ err = gpgme_get_engine_info (&engine_info);
+ fail_if_err (err);
+ for (; engine_info; engine_info = engine_info->next)
+ if (engine_info->protocol == GPGME_PROTOCOL_OpenPGP)
+ break;
+ assert (engine_info);
+
+ /* GnuPG prior to 2.1.13 did not report the critical flag
+ correctly. */
+ have_correct_sig_data =
+ ! (strncmp ("1.", engine_info->version, 2)
+ || (strncmp ("2.1.1", engine_info->version, 5)
+ && (engine_info->version[5] == 0
+ || engine_info->version[5] < '3')));
+
err = gpgme_new (&ctx);
fail_if_err (err);