4
4
5
5
#include "utils/test_setup.h"
6
6
7
- #define FAIL_OPEN_DEFAULT SF_BOOLEAN_TRUE
8
-
9
7
void setCacheFile (char * cache_file )
10
8
{
11
9
#ifdef __linux__
@@ -40,7 +38,18 @@ void setCacheFile(char *cache_file)
40
38
#endif
41
39
}
42
40
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
+
43
51
void test_fail_open_revoked (void * * unused ) {
52
+ SF_UNUSED (unused );
44
53
char cache_file [4096 ];
45
54
setCacheFile (cache_file );
46
55
remove (cache_file );
@@ -49,13 +58,6 @@ void test_fail_open_revoked(void **unused) {
49
58
sf_setenv ("SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED" , "false" );
50
59
51
60
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
-
59
61
SF_STATUS ret = snowflake_connect (sf );
60
62
assert_int_not_equal (ret , SF_STATUS_SUCCESS ); // must fail
61
63
SF_ERROR_STRUCT * sferr = snowflake_error (sf );
@@ -67,6 +69,7 @@ void test_fail_open_revoked(void **unused) {
67
69
}
68
70
69
71
void test_fail_close_timeout (void * * unused ) {
72
+ SF_UNUSED (unused );
70
73
char cache_file [4096 ];
71
74
setCacheFile (cache_file );
72
75
remove (cache_file );
@@ -76,11 +79,7 @@ void test_fail_close_timeout(void** unused) {
76
79
sf_setenv ("SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED" , "false" );
77
80
78
81
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 );
84
83
85
84
SF_STATUS ret = snowflake_connect (sf );
86
85
assert_int_not_equal (ret , SF_STATUS_SUCCESS ); // must fail
@@ -93,6 +92,7 @@ void test_fail_close_timeout(void** unused) {
93
92
}
94
93
95
94
void test_fail_open_timeout (void * * unused ) {
95
+ SF_UNUSED (unused );
96
96
char cache_file [4096 ];
97
97
setCacheFile (cache_file );
98
98
remove (cache_file );
@@ -102,12 +102,6 @@ void test_fail_open_timeout(void** unused) {
102
102
sf_setenv ("SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED" , "false" );
103
103
104
104
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
-
111
105
SF_STATUS ret = snowflake_connect (sf );
112
106
if (ret != SF_STATUS_SUCCESS ) {
113
107
dump_error (& (sf -> error ));
@@ -119,6 +113,7 @@ void test_fail_open_timeout(void** unused) {
119
113
int main (void ) {
120
114
initialize_test (SF_BOOLEAN_FALSE );
121
115
const struct CMUnitTest tests [] = {
116
+ cmocka_unit_test (test_fail_open_is_default_mode ),
122
117
cmocka_unit_test (test_fail_open_revoked ),
123
118
cmocka_unit_test (test_fail_close_timeout ),
124
119
cmocka_unit_test (test_fail_open_timeout ),
0 commit comments