Skip to content

Commit bee19e2

Browse files
Roytakmichalvasko
authored andcommitted
test tls UPDATE add no ca/ee tests
1 parent 2fba92c commit bee19e2

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/test_tls.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,54 @@ test_nc_tls(void **state)
7474
}
7575
}
7676

77+
static void
78+
test_nc_tls_ca_cert_only(void **state)
79+
{
80+
int ret, i;
81+
pthread_t tids[2];
82+
struct ln2_test_ctx *test_ctx = *state;
83+
84+
/* delete a client certificate so that only CA certs are used */
85+
assert_int_equal(nc_server_config_del_tls_client_cert("endpt",
86+
"client_cert", (struct lyd_node **)&test_ctx->test_data), 0);
87+
88+
/* apply the configuration */
89+
assert_int_equal(nc_server_config_setup_data(test_ctx->test_data), 0);
90+
91+
ret = pthread_create(&tids[0], NULL, client_thread, *state);
92+
assert_int_equal(ret, 0);
93+
ret = pthread_create(&tids[1], NULL, ln2_glob_test_server_thread, *state);
94+
assert_int_equal(ret, 0);
95+
96+
for (i = 0; i < 2; i++) {
97+
pthread_join(tids[i], NULL);
98+
}
99+
}
100+
101+
static void
102+
test_nc_tls_ee_cert_only(void **state)
103+
{
104+
int ret, i;
105+
pthread_t tids[2];
106+
struct ln2_test_ctx *test_ctx = *state;
107+
108+
/* delete a CA certificate so that only end entity client cert is used */
109+
assert_int_equal(nc_server_config_del_tls_ca_cert("endpt",
110+
"client_ca", (struct lyd_node **)&test_ctx->test_data), 0);
111+
112+
/* apply the configuration */
113+
assert_int_equal(nc_server_config_setup_data(test_ctx->test_data), 0);
114+
115+
ret = pthread_create(&tids[0], NULL, client_thread, *state);
116+
assert_int_equal(ret, 0);
117+
ret = pthread_create(&tids[1], NULL, ln2_glob_test_server_thread, *state);
118+
assert_int_equal(ret, 0);
119+
120+
for (i = 0; i < 2; i++) {
121+
pthread_join(tids[i], NULL);
122+
}
123+
}
124+
77125
static void
78126
test_nc_tls_ec_key(void **state)
79127
{
@@ -223,6 +271,8 @@ main(void)
223271
{
224272
const struct CMUnitTest tests[] = {
225273
cmocka_unit_test_setup_teardown(test_nc_tls, setup_f, ln2_glob_test_teardown),
274+
cmocka_unit_test_setup_teardown(test_nc_tls_ca_cert_only, setup_f, ln2_glob_test_teardown),
275+
cmocka_unit_test_setup_teardown(test_nc_tls_ee_cert_only, setup_f, ln2_glob_test_teardown),
226276
cmocka_unit_test_setup_teardown(test_nc_tls_ec_key, setup_f, ln2_glob_test_teardown),
227277
cmocka_unit_test_setup_teardown(test_nc_tls_keylog, keylog_setup_f, ln2_glob_test_teardown)
228278
};

0 commit comments

Comments
 (0)