2 * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include <openssl/ssl.h>
22 static const version_test version_testdata
[] = {
23 /* min max ok expected min expected max */
25 {TLS1_VERSION
, TLS1_2_VERSION
, 1, 1, TLS1_VERSION
, TLS1_2_VERSION
},
26 {TLS1_2_VERSION
, TLS1_2_VERSION
, 1, 1, TLS1_2_VERSION
, TLS1_2_VERSION
},
27 {TLS1_2_VERSION
, TLS1_1_VERSION
, 1, 1, TLS1_2_VERSION
, TLS1_1_VERSION
},
31 static int test_set_min_max_version(int idx_tst
)
36 version_test t
= version_testdata
[idx_tst
];
38 ctx
= SSL_CTX_new(TLS_server_method());
46 if (!TEST_int_eq(SSL_CTX_set_min_proto_version(ctx
, t
.min_version
), t
.min_ok
))
48 if (!TEST_int_eq(SSL_CTX_set_max_proto_version(ctx
, t
.max_version
), t
.max_ok
))
50 if (!TEST_int_eq(SSL_CTX_get_min_proto_version(ctx
), t
.expected_min
))
52 if (!TEST_int_eq(SSL_CTX_get_max_proto_version(ctx
), t
.expected_max
))
55 if (!TEST_int_eq(SSL_set_min_proto_version(ssl
, t
.min_version
), t
.min_ok
))
57 if (!TEST_int_eq(SSL_set_max_proto_version(ssl
, t
.max_version
), t
.max_ok
))
59 if (!TEST_int_eq(SSL_get_min_proto_version(ssl
), t
.expected_min
))
61 if (!TEST_int_eq(SSL_get_max_proto_version(ssl
), t
.expected_max
))
74 ADD_ALL_TESTS(test_set_min_max_version
, sizeof(version_testdata
) / sizeof(version_test
));