New SSL test framework
[openssl.git] / test / ssl_test_ctx.h
1 /*
2  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL licenses, (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * https://www.openssl.org/source/license.html
8  * or in the file LICENSE in the source distribution.
9  */
10
11 #ifndef HEADER_SSL_TEST_CTX_H
12 #define HEADER_SSL_TEST_CTX_H
13
14 #include <openssl/conf.h>
15 #include <openssl/ssl.h>
16
17 typedef enum {
18     SSL_TEST_SUCCESS,  /* Default */
19     SSL_TEST_SERVER_FAIL,
20     SSL_TEST_CLIENT_FAIL,
21     SSL_TEST_INTERNAL_ERROR
22 } ssl_test_result_t;
23
24 typedef struct ssl_test_ctx {
25     /* Test expectations. */
26     /* Defaults to SUCCESS. */
27     ssl_test_result_t expected_result;
28     /* Alerts. 0 if no expectation. */
29     /* See ssl.h for alert codes. */
30     /* Alert sent by the client / received by the server. */
31     int client_alert;
32     /* Alert sent by the server / received by the client. */
33     int server_alert;
34     /* Negotiated protocol version. 0 if no expectation. */
35     /* See ssl.h for protocol versions. */
36     int protocol;
37 } SSL_TEST_CTX;
38
39 const char *ssl_test_result_t_name(ssl_test_result_t result);
40 const char *ssl_alert_name(int alert);
41 const char *ssl_protocol_name(int protocol);
42
43 /*
44  * Load the test case context from |conf|.
45  * See test/README.ssl_test for details on the conf file format.
46  */
47 SSL_TEST_CTX *SSL_TEST_CTX_create(const CONF *conf, const char *test_section);
48
49 SSL_TEST_CTX *SSL_TEST_CTX_new(void);
50
51 void SSL_TEST_CTX_free(SSL_TEST_CTX *ctx);
52
53 #endif  /* HEADER_SSL_TEST_CTX_H */