]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls_ocsp_status_request_is_checked: added tests in client side
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 19 Sep 2019 19:26:25 +0000 (21:26 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 20 Sep 2019 20:13:51 +0000 (22:13 +0200)
This ensures that this function has functional tests.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
tests/mini-x509-2.c
tests/set_x509_key_file_ocsp.c
tests/set_x509_ocsp_multi_pem.c

index e20d45b7ff41f4a683b4d70181669ec21a3c1927..e336af83678a2406f987d25a2279ce31c7ac2669 100644 (file)
@@ -415,6 +415,24 @@ void start(const char *prio)
                        fprintf(stderr, "could not verify certificate: %.4x\n", status);
                        exit(1);
                }
+
+               status = gnutls_ocsp_status_request_is_checked(client, 0);
+               if (status != 0) {
+                       fprintf(stderr, "gnutls_ocsp_status_request_is_checked: unexpected value (%u)\n", status);
+                       exit(1);
+               }
+
+               status = gnutls_ocsp_status_request_is_checked(client, GNUTLS_OCSP_SR_IS_AVAIL);
+               if (status != 0) {
+                       fprintf(stderr, "gnutls_ocsp_status_request_is_checked: unexpected value (%u)\n", status);
+                       exit(1);
+               }
+
+               status = gnutls_ocsp_status_request_is_checked(server, 0);
+               if (status != 0) {
+                       fprintf(stderr, "gnutls_ocsp_status_request_is_checked: unexpected value (%u)\n", status);
+                       exit(1);
+               }
        }
 
        gnutls_bye(client, GNUTLS_SHUT_RDWR);
index d6685509327df1bdadc4054fcffb3f8f689cdc3d..9cb4001393125716497061a19d373c956c375590 100644 (file)
@@ -274,6 +274,17 @@ static void check_response(gnutls_session_t session, void *priv)
        if (resp.size != exp_resp->size || memcmp(resp.data, exp_resp->data, resp.size) != 0) {
                fail("did not receive the expected response\n");
        }
+
+       /* we provide a response, but an invalid one */
+       ret = gnutls_ocsp_status_request_is_checked(session, 0);
+       if (ret != 0) {
+               fail("did not receive the expected value (%d)\n", ret);
+       }
+
+       ret = gnutls_ocsp_status_request_is_checked(session, GNUTLS_OCSP_SR_IS_AVAIL);
+       if (ret == 0) {
+               fail("did not receive the expected value (%d)\n", ret);
+       }
 }
 
 void doit(void)
index c5c22dd6182d4da0c0a6e9ea46fd30dc911f53b6..834ee468e023d6086b84b7b428364eb8b0823480 100644 (file)
@@ -79,6 +79,16 @@ static void check_response(gnutls_session_t session, void *priv)
                        fail("did not receive the expected intermediate response\n");
                }
        }
+
+       ret = gnutls_ocsp_status_request_is_checked(session, 0);
+       if (ret == 0) {
+               fail("did not receive the expected value (%d)\n", ret);
+       }
+
+       ret = gnutls_ocsp_status_request_is_checked(session, GNUTLS_OCSP_SR_IS_AVAIL);
+       if (ret == 0) {
+               fail("did not receive the expected value (%d)\n", ret);
+       }
 }
 
 static void tls_log_func(int level, const char *str)