From: Nikos Mavrogiannopoulos Date: Wed, 29 Nov 2017 15:19:56 +0000 (+0100) Subject: tests: added unit test for gnutls_ocsp_resp_list_import2 X-Git-Tag: gnutls_3_6_3~252 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e448ad7e22599a10e472b336f65357fa42f35d64;p=thirdparty%2Fgnutls.git tests: added unit test for gnutls_ocsp_resp_list_import2 Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 26bb86075d..4e9bd1dc0f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -143,7 +143,7 @@ ctests += mini-record-2 simple gnutls_hmac_fast set_pkcs12_cred cert certuniquei tls-ext-register tls-supplemental mini-dtls0-9 duplicate-extensions \ mini-record-retvals mini-server-name tls-etm x509-cert-callback \ client-sign-md5-rep tls12-invalid-key-exchanges session-rdn-read \ - tls13-cert-key-exchange x509-cert-callback-ocsp \ + tls13-cert-key-exchange x509-cert-callback-ocsp gnutls_ocsp_resp_list_import2 \ server-sign-md5-rep privkey-keygen mini-tls-nonblock no-signal pkcs7-gen dtls-etm \ x509sign-verify-rsa x509sign-verify-ecdsa mini-alignment oids atfork prf psk-file \ status-request status-request-ok status-request-missing sign-verify-ext \ diff --git a/tests/gnutls_ocsp_resp_list_import2.c b/tests/gnutls_ocsp_resp_list_import2.c new file mode 100644 index 0000000000..03d1db8c56 --- /dev/null +++ b/tests/gnutls_ocsp_resp_list_import2.c @@ -0,0 +1,261 @@ +/* + * Copyright (C) 2017 Nikos Mavrogiannopoulos + * + * Author: Nikos Mavrogiannopoulos + * + * This file is part of GnuTLS. + * + * GnuTLS is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GnuTLS is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see + */ + +/* This tests key import for gnutls_ocsp_resp_t APIs */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include "ocsp-common.h" +#include "utils.h" + +#define testfail(fmt, ...) \ + fail("%s: "fmt, name, ##__VA_ARGS__) + +static void load_list(const char *name, const gnutls_datum_t *txt, + unsigned int nocsps, + int format, + unsigned flags, int exp_err) +{ + gnutls_ocsp_resp_t *ocsps; + unsigned int i, size; + int ret; + + ret = gnutls_ocsp_resp_list_import2(&ocsps, &size, txt, format, flags); + if (ret < 0) { + if (exp_err == ret) + return; + testfail("gnutls_x509_crt_list_import: %s\n", gnutls_strerror(ret)); + } + + for (i=0;i