Skip to content

Commit ae24752

Browse files
committed
Add tests
1 parent b56a781 commit ae24752

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

tests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ if(NOT BYO_CRYPTO)
295295
add_net_test_case(test_tls_negotiation_timeout)
296296
add_net_test_case(alpn_successfully_negotiates)
297297
add_net_test_case(alpn_no_protocol_message)
298-
add_net_test_case(test_ecc_cert_import)
298+
add_net_test_case(test_ecc_p256_cert_import)
299+
add_net_test_case(test_ecc_p384_cert_import)
299300

300301
add_test_case(test_tls_cipher_preference)
301302

tests/resources/ecc-cert-384.pem

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIICvTCCAkKgAwIBAgIUeP9ui00vOr6GvctifJ929rRIKB8wCgYIKoZIzj0EAwIw
3+
gZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdT
4+
ZWF0dGxlMQ8wDQYDVQQKDAZBbWF6b24xDTALBgNVBAsMBFNES3MxDDAKBgNVBAMM
5+
A0NSVDEwMC4GCSqGSIb3DQEJARYhYXdzLXNkay1jb21tb24tcnVudGltZUBhbWF6
6+
b24uY29tMB4XDTI1MTEwNjE3NTAzN1oXDTM1MDkxNTE3NTAzN1owgZQxCzAJBgNV
7+
BAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQHDAdTZWF0dGxlMQ8w
8+
DQYDVQQKDAZBbWF6b24xDTALBgNVBAsMBFNES3MxDDAKBgNVBAMMA0NSVDEwMC4G
9+
CSqGSIb3DQEJARYhYXdzLXNkay1jb21tb24tcnVudGltZUBhbWF6b24uY29tMHYw
10+
EAYHKoZIzj0CAQYFK4EEACIDYgAELW5XvrGkolo2Rqm3XbTZ83dZYMjfLQK59HTg
11+
9ExL2lVD2MHK0iFh2SB9PVCprghSHZW9uE8ymaiUyujt2WtVFRhTAlRt85vBM8Xw
12+
SJ4ybYhzJwaRD8F+koIlbgRRJu+So1MwUTAdBgNVHQ4EFgQU+LZ0DF0pMGTw4F8A
13+
jpaXUnQLT8cwHwYDVR0jBBgwFoAU+LZ0DF0pMGTw4F8AjpaXUnQLT8cwDwYDVR0T
14+
AQH/BAUwAwEB/zAKBggqhkjOPQQDAgNpADBmAjEA/7upMHjcbIkZjiuLcdQH2+Sd
15+
xGRQrAxd5pqcqQDKkV9VMdXHFkxH54GgbG7QrsPhAjEA3yLCiWbt7meDZZS4p0Ji
16+
Pl6pg6lwzylTVVnQA9028rREcTebdc9ZmZ3SOIWKyydO
17+
-----END CERTIFICATE-----

tests/resources/ecc-key-384.pem

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-----BEGIN EC PRIVATE KEY-----
2+
MIGkAgEBBDDeuS2ZwnCWqjeDJJThQ3TYukh9HxEo/VoOOf2vDS+p+Ml5sxF60H69
3+
jy6AmYwA1bKgBwYFK4EEACKhZANiAAQtble+saSiWjZGqbddtNnzd1lgyN8tArn0
4+
dOD0TEvaVUPYwcrSIWHZIH09UKmuCFIdlb24TzKZqJTK6O3Za1UVGFMCVG3zm8Ez
5+
xfBInjJtiHMnBpEPwX6SgiVuBFEm75I=
6+
-----END EC PRIVATE KEY-----

tests/tls_handler_test.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,17 +2642,12 @@ static int s_tls_destroy_null_context(struct aws_allocator *allocator, void *ctx
26422642
}
26432643
AWS_TEST_CASE(tls_destroy_null_context, s_tls_destroy_null_context);
26442644

2645-
static int s_test_ecc_cert_import(struct aws_allocator *allocator, void *ctx) {
2646-
(void)ctx;
2647-
(void)allocator;
2648-
2649-
aws_io_library_init(allocator);
2650-
2645+
static int s_test_ecc_import(struct aws_allocator *allocator, const char *key_path, const char *cert_path) {
26512646
struct aws_byte_buf cert_buf;
26522647
struct aws_byte_buf key_buf;
26532648

2654-
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&cert_buf, allocator, "ecc-cert.pem"));
2655-
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&key_buf, allocator, "ecc-key.pem"));
2649+
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&cert_buf, allocator, cert_path));
2650+
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&key_buf, allocator, key_path));
26562651

26572652
struct aws_byte_cursor cert_cur = aws_byte_cursor_from_buf(&cert_buf);
26582653
struct aws_byte_cursor key_cur = aws_byte_cursor_from_buf(&key_buf);
@@ -2676,7 +2671,19 @@ static int s_test_ecc_cert_import(struct aws_allocator *allocator, void *ctx) {
26762671
return AWS_OP_SUCCESS;
26772672
}
26782673

2679-
AWS_TEST_CASE(test_ecc_cert_import, s_test_ecc_cert_import)
2674+
static int s_test_ecc_p256_cert_import(struct aws_allocator *allocator, void *ctx) {
2675+
(void)ctx;
2676+
return s_test_ecc_import(allocator, "ecc-key.pem", "ecc-cert.pem");
2677+
}
2678+
2679+
AWS_TEST_CASE(test_ecc_p256_cert_import, s_test_ecc_p256_cert_import)
2680+
2681+
static int s_test_ecc_p384_cert_import(struct aws_allocator *allocator, void *ctx) {
2682+
(void)ctx;
2683+
return s_test_ecc_import(allocator, "ecc-key-384.pem", "ecc-cert-384.pem");
2684+
}
2685+
2686+
AWS_TEST_CASE(test_ecc_p384_cert_import, s_test_ecc_p384_cert_import)
26802687

26812688
static int s_test_pkcs12_import(struct aws_allocator *allocator, void *ctx) {
26822689
(void)ctx;

0 commit comments

Comments
 (0)