Skip to content

Commit fedf1f9

Browse files
SNOW-1866382 ensure OCSP mode is by default set to FAIL_OPEN (#827)
1 parent ab172ef commit fedf1f9

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

tests/test_ocsp_fail_open.c

+15-20
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#include "utils/test_setup.h"
66

7-
#define FAIL_OPEN_DEFAULT SF_BOOLEAN_TRUE
8-
97
void setCacheFile(char *cache_file)
108
{
119
#ifdef __linux__
@@ -40,7 +38,18 @@ void setCacheFile(char *cache_file)
4038
#endif
4139
}
4240

41+
void test_fail_open_is_default_mode(void **unused) {
42+
SF_UNUSED(unused);
43+
SF_CONNECT *sf = snowflake_init();
44+
sf_bool *ocsp_fail_open = NULL;
45+
SF_STATUS ret = snowflake_get_attribute(sf, SF_CON_OCSP_FAIL_OPEN, (void**)&ocsp_fail_open);
46+
assert_int_equal(ret, SF_STATUS_SUCCESS);
47+
assert_int_equal(*ocsp_fail_open, SF_BOOLEAN_TRUE);
48+
snowflake_term(sf);
49+
}
50+
4351
void test_fail_open_revoked(void **unused) {
52+
SF_UNUSED(unused);
4453
char cache_file[4096];
4554
setCacheFile(cache_file);
4655
remove(cache_file);
@@ -49,13 +58,6 @@ void test_fail_open_revoked(void **unused) {
4958
sf_setenv("SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED", "false");
5059

5160
SF_CONNECT *sf = setup_snowflake_connection();
52-
53-
sf_bool value = SF_BOOLEAN_TRUE;
54-
if (value != FAIL_OPEN_DEFAULT)
55-
{
56-
snowflake_set_attribute(sf, SF_CON_OCSP_FAIL_OPEN, &value);
57-
}
58-
5961
SF_STATUS ret = snowflake_connect(sf);
6062
assert_int_not_equal(ret, SF_STATUS_SUCCESS); // must fail
6163
SF_ERROR_STRUCT *sferr = snowflake_error(sf);
@@ -67,6 +69,7 @@ void test_fail_open_revoked(void **unused) {
6769
}
6870

6971
void test_fail_close_timeout(void** unused) {
72+
SF_UNUSED(unused);
7073
char cache_file[4096];
7174
setCacheFile(cache_file);
7275
remove(cache_file);
@@ -76,11 +79,7 @@ void test_fail_close_timeout(void** unused) {
7679
sf_setenv("SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED", "false");
7780

7881
SF_CONNECT* sf = setup_snowflake_connection();
79-
sf_bool value = SF_BOOLEAN_FALSE;
80-
if (value != FAIL_OPEN_DEFAULT)
81-
{
82-
snowflake_set_attribute(sf, SF_CON_OCSP_FAIL_OPEN, &value);
83-
}
82+
snowflake_set_attribute(sf, SF_CON_OCSP_FAIL_OPEN, &SF_BOOLEAN_FALSE);
8483

8584
SF_STATUS ret = snowflake_connect(sf);
8685
assert_int_not_equal(ret, SF_STATUS_SUCCESS); // must fail
@@ -93,6 +92,7 @@ void test_fail_close_timeout(void** unused) {
9392
}
9493

9594
void test_fail_open_timeout(void** unused) {
95+
SF_UNUSED(unused);
9696
char cache_file[4096];
9797
setCacheFile(cache_file);
9898
remove(cache_file);
@@ -102,12 +102,6 @@ void test_fail_open_timeout(void** unused) {
102102
sf_setenv("SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED", "false");
103103

104104
SF_CONNECT* sf = setup_snowflake_connection();
105-
sf_bool value = SF_BOOLEAN_TRUE;
106-
if (value != FAIL_OPEN_DEFAULT)
107-
{
108-
snowflake_set_attribute(sf, SF_CON_OCSP_FAIL_OPEN, &value);
109-
}
110-
111105
SF_STATUS ret = snowflake_connect(sf);
112106
if (ret != SF_STATUS_SUCCESS) {
113107
dump_error(&(sf->error));
@@ -119,6 +113,7 @@ void test_fail_open_timeout(void** unused) {
119113
int main(void) {
120114
initialize_test(SF_BOOLEAN_FALSE);
121115
const struct CMUnitTest tests[] = {
116+
cmocka_unit_test(test_fail_open_is_default_mode),
122117
cmocka_unit_test(test_fail_open_revoked),
123118
cmocka_unit_test(test_fail_close_timeout),
124119
cmocka_unit_test(test_fail_open_timeout),

0 commit comments

Comments
 (0)