From 024a7f75d4b8e017b92a13552b23e7fb1d22a5ce Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Wed, 5 Jun 2019 17:23:59 +0200 Subject: [PATCH] tests: Implement import in run-threaded * tests/run-threaded.c (import): New. (do_data_op): Call it. --- tests/run-threaded.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/run-threaded.c b/tests/run-threaded.c index 8a1c666e..fef24cb0 100644 --- a/tests/run-threaded.c +++ b/tests/run-threaded.c @@ -453,6 +453,32 @@ decrypt (const char *fname, gpgme_protocol_t proto) random_data_close (data); } +void +import (const char *fname, gpgme_protocol_t proto) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + data_t data = random_data_new (fname); + + log ("Starting import on: %s", fname); + + err = gpgme_new (&ctx); + fail_if_err (err); + + err = gpgme_set_protocol (ctx, proto); + fail_if_err (err); + + gpgme_set_offline (ctx, 1); + + err = gpgme_op_import (ctx, data->dh); + fail_if_err (err); + + gpgme_release (ctx); + + log ("Import completed."); + + random_data_close (data); +} static THREAD_RET do_data_op (void *file_name) @@ -502,6 +528,16 @@ do_data_op (void *file_name) decrypt (fname, GPGME_PROTOCOL_CMS); break; } + case GPGME_DATA_TYPE_PGP_KEY: + { + import (fname, GPGME_PROTOCOL_OpenPGP); + break; + } + case GPGME_DATA_TYPE_X509_CERT: + { + import (fname, GPGME_PROTOCOL_CMS); + break; + } default: { out ("Unhandled data type 0x%x for '%s'\n", type, fname);