-
-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy path0008-TLSSocketWrapper-Add-unit-test-for-set_root_ca_cert_.patch
61 lines (54 loc) · 2.79 KB
/
0008-TLSSocketWrapper-Add-unit-test-for-set_root_ca_cert_.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 2ea47a9ca4cc1b6f92eacafe54cdb02df1cad6b5 Mon Sep 17 00:00:00 2001
From: Martino Facchin <m.facchin@arduino.cc>
Date: Mon, 9 Nov 2020 13:34:18 +0100
Subject: [PATCH 008/204] TLSSocketWrapper: Add unit test for
set_root_ca_cert_path
---
.../test/coap-service/unittest/stub/mbedtls_stub.c | 6 ++++++
.../netsocket/TLSSocketWrapper/test_TLSSocketWrapper.cpp | 6 ++++++
.../UNITTESTS/netsocket/TLSSocketWrapper/tls_test_config.h | 2 +-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/connectivity/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c b/connectivity/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c
index b63eb0269d..32026c4fe6 100644
--- a/connectivity/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c
+++ b/connectivity/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c
@@ -303,6 +303,12 @@ int mbedtls_x509_crt_parse(mbedtls_x509_crt *a, const unsigned char *b, size_t c
return mbedtls_stub.expected_int;
}
+int mbedtls_x509_crt_parse_path(mbedtls_x509_crt *a, const char *b)
+{
+ // means 5 valid certificates found
+ return 5;
+}
+
int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix,
const mbedtls_x509_crt *crt)
{
diff --git a/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/test_TLSSocketWrapper.cpp b/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/test_TLSSocketWrapper.cpp
index b0e473a401..6ba2421817 100644
--- a/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/test_TLSSocketWrapper.cpp
+++ b/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/test_TLSSocketWrapper.cpp
@@ -399,6 +399,12 @@ TEST_F(TestTLSSocketWrapper, set_root_ca_cert_invalid)
EXPECT_EQ(wrapper->set_root_ca_cert(cert, strlen(cert)), NSAPI_ERROR_PARAMETER);
}
+TEST_F(TestTLSSocketWrapper, set_root_ca_cert_path)
+{
+ EXPECT_EQ(transport->open(&stack), NSAPI_ERROR_OK);
+ EXPECT_EQ(wrapper->set_root_ca_cert_path("/"), NSAPI_ERROR_OK);
+}
+
TEST_F(TestTLSSocketWrapper, set_client_cert_key)
{
EXPECT_EQ(wrapper->get_own_cert(), static_cast<mbedtls_x509_crt *>(NULL));
diff --git a/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/tls_test_config.h b/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/tls_test_config.h
index 4f9ce6b96c..ad2d3d8d44 100644
--- a/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/tls_test_config.h
+++ b/connectivity/netsocket/tests/UNITTESTS/netsocket/TLSSocketWrapper/tls_test_config.h
@@ -19,6 +19,6 @@
#define UNITTESTS_FEATURES_NETSOCKET_TLSSOCKET_TLS_TEST_CONFIG_H_
#define MBEDTLS_SSL_CLI_C
-
+#define MBEDTLS_FS_IO
#endif /* UNITTESTS_FEATURES_NETSOCKET_TLSSOCKET_TLS_TEST_CONFIG_H_ */
--
2.39.1