Skip to content

Commit dd1adbd

Browse files
committed
TLSSocketWrapper: Add unit test for set_root_ca_cert_path
1 parent 36383ca commit dd1adbd

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

connectivity/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c

+6
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ int mbedtls_x509_crt_parse(mbedtls_x509_crt *a, const unsigned char *b, size_t c
299299
return mbedtls_stub.expected_int;
300300
}
301301

302+
int mbedtls_x509_crt_parse_path(mbedtls_x509_crt *a, const char *b)
303+
{
304+
// means 5 valid certificates found
305+
return 5;
306+
}
307+
302308
int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix,
303309
const mbedtls_x509_crt *crt)
304310
{

connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/test_TLSSocketWrapper.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ TEST_F(TestTLSSocketWrapper, set_root_ca_cert_invalid)
399399
EXPECT_EQ(wrapper->set_root_ca_cert(cert, strlen(cert)), NSAPI_ERROR_PARAMETER);
400400
}
401401

402+
TEST_F(TestTLSSocketWrapper, set_root_ca_cert_path)
403+
{
404+
EXPECT_EQ(transport->open(&stack), NSAPI_ERROR_OK);
405+
EXPECT_EQ(wrapper->set_root_ca_cert_path("/"), NSAPI_ERROR_OK);
406+
}
407+
402408
TEST_F(TestTLSSocketWrapper, set_client_cert_key)
403409
{
404410
EXPECT_EQ(wrapper->get_own_cert(), static_cast<mbedtls_x509_crt *>(NULL));

connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/tls_test_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
#define UNITTESTS_FEATURES_NETSOCKET_TLSSOCKET_TLS_TEST_CONFIG_H_
2020

2121
#define MBEDTLS_SSL_CLI_C
22-
22+
#define MBEDTLS_FS_IO
2323

2424
#endif /* UNITTESTS_FEATURES_NETSOCKET_TLSSOCKET_TLS_TEST_CONFIG_H_ */

0 commit comments

Comments
 (0)