tests: Implement import in run-threaded

* tests/run-threaded.c (import): New.
(do_data_op): Call it.
This commit is contained in:
Andre Heinecke 2019-06-05 17:23:59 +02:00
parent 0f68c9f16b
commit 024a7f75d4
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -453,6 +453,32 @@ decrypt (const char *fname, gpgme_protocol_t proto)
random_data_close (data); 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 static THREAD_RET
do_data_op (void *file_name) do_data_op (void *file_name)
@ -502,6 +528,16 @@ do_data_op (void *file_name)
decrypt (fname, GPGME_PROTOCOL_CMS); decrypt (fname, GPGME_PROTOCOL_CMS);
break; 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: default:
{ {
out ("Unhandled data type 0x%x for '%s'\n", type, fname); out ("Unhandled data type 0x%x for '%s'\n", type, fname);