Skip to content

Commit 3fa01af

Browse files
committed
remove commented code
1 parent ae0a0bc commit 3fa01af

File tree

1 file changed

+25
-89
lines changed

1 file changed

+25
-89
lines changed

tests/tls_handler_test.c

+25-89
Original file line numberDiff line numberDiff line change
@@ -1199,44 +1199,27 @@ static int s_verify_good_host_mqtt_connect(
11991199

12001200
ASSERT_SUCCESS(s_tls_common_tester_init(allocator, &c_tester));
12011201

1202-
/* ****** NEW ********/
12031202
uint8_t outgoing_received_message[128] = {0};
12041203

1205-
// const uint8_t mqtt_connect_message[] = {
1206-
1207-
// 0x10, /* connect */
1208-
// 0x10,/*packet length */
1209-
// 0x00, 0x04,/* protocol name length */
1210-
// 0x4d, 0x51, 0x54, 0x54,/* MQTT */
1211-
// 0x04,/* protocol version 4 (3.11) */
1212-
// 0x02,/* connect flags */
1213-
// 0x00, 0x3c,/* keep alive */
1214-
// 0x00, 0x04, 't', 'e', 's', 't' /* client id(size (2) + data(4) */
1215-
//};
1216-
1217-
const uint8_t mqtt_connect_message[] = {
1218-
0x10, 0x51, 0x00, 0x04, 0x4D, 0x51, 0x54, 0x54, 0x04, 0x80, 0x03, 0xE8, 0x00, 0x29, 0x74, 0x65, 0x73,
1219-
0x74, 0x2D, 0x30, 0x62, 0x34, 0x37, 0x36, 0x30, 0x64, 0x35, 0x2D, 0x62, 0x61, 0x39, 0x63, 0x2D, 0x38,
1220-
0x65, 0x66, 0x64, 0x2D, 0x33, 0x32, 0x65, 0x37, 0x2D, 0x34, 0x38, 0x64, 0x30, 0x35, 0x62, 0x62, 0x32,
1221-
0x30, 0x30, 0x65, 0x61, 0x00, 0x1A, 0x3F, 0x53, 0x44, 0x4B, 0x3D, 0x43, 0x50, 0x50, 0x76, 0x32, 0x26,
1222-
0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x76, 0x31, 0x2E, 0x33, 0x32, 0x2E, 0x36
1223-
};
1224-
1225-
/*
12261204
const uint8_t mqtt_connect_message[] = {
1227-
0x10, 0x51, 0x00, 0x04, 0x4D, 0x51, 0x54, 0x54, 0x04, 0x80,
1228-
0x03, 0xE8, 0x00, 0x29, 0x74, 0x65, 0x73, 0x74, 0x2D, 0x35,
1229-
0x62, 0x39, 0x39, 0x36, 0x61, 0x62, 0x63, 0x2D, 0x63, 0x30,
1230-
0x38, 0x31, 0x2D, 0x37, 0x36, 0x31, 0x37, 0x2D, 0x64, 0x31,
1231-
0x34, 0x33, 0x2D, 0x64, 0x33, 0x35, 0x66, 0x37, 0x32, 0x65,
1232-
0x37, 0x36, 0x39, 0x64, 0x62, 0x00, 0x1A, 0x3F, 0x53, 0x44,
1233-
0x4B, 0x3D, 0x43, 0x50, 0x50, 0x76, 0x32, 0x26, 0x56, 0x65,
1234-
0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x76, 0x31, 0x2E, 0x33,
1235-
0x32, 0x2E, 0x36, 0x00
1205+
0x10, /* connect packet */
1206+
0x51, /* packet length */
1207+
0x00, 0x04, /* protocol name length */
1208+
0x4D, 0x51, 0x54, 0x54, /* M Q T T */
1209+
0x04, /* protocol version 3.11 = 4 */
1210+
0x82, /* connect flags user name + clean session */
1211+
0x03, 0xE8, // keep alive
1212+
0x00, 0x29, /* client id size */
1213+
0x74, 0x65, 0x73, 0x74, 0x2D, 0x30, 0x62, 0x34, 0x37, 0x36,
1214+
0x30, 0x64, 0x35, 0x2D, 0x62, 0x61, 0x39, 0x63, 0x2D, 0x38,
1215+
0x65, 0x66, 0x64, 0x2D, 0x33, 0x32, 0x65, 0x37, 0x2D, 0x34,
1216+
0x38, 0x64, 0x30, 0x35, 0x62, 0x62, 0x32, 0x30, 0x30, 0x65,
1217+
0x61, /* client id */
1218+
0x00, 0x1A, /* user name length */
1219+
0x3F, 0x53, 0x44, 0x4B, 0x3D, 0x43, 0x50, 0x50, 0x76, 0x32,
1220+
0x26, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x76,
1221+
0x31, 0x2E, 0x33, 0x32, 0x2E, 0x36 /* user name */
12361222
};
1237-
*/
1238-
1239-
// const uint8_t mqtt_connect_message[] = {'a', 'l', 'f', 'r', 'e', 'd', 0x00, 0x02, 0x01};
12401223

12411224
struct aws_byte_buf write_tag = aws_byte_buf_from_array((const char*)mqtt_connect_message, 83);
12421225

@@ -1251,8 +1234,6 @@ static int s_verify_good_host_mqtt_connect(
12511234
true, write_tag.len, &outgoing_rw_args);
12521235
ASSERT_NOT_NULL(outgoing_rw_handler);
12531236

1254-
/* end new */
1255-
12561237
struct tls_test_args outgoing_args = {
12571238
.mutex = &c_tester.mutex,
12581239
.allocator = allocator,
@@ -1283,18 +1264,14 @@ static int s_verify_good_host_mqtt_connect(
12831264
aws_tls_connection_options_set_callbacks(
12841265
&tls_client_conn_options, s_tls_on_negotiated, NULL, NULL, &outgoing_args);
12851266

1286-
/* ***** new ****** */
12871267
struct aws_byte_buf cert_buf = {0};
12881268
struct aws_byte_buf key_buf = {0};
12891269
struct aws_byte_buf ca_buf = {0};
12901270
struct aws_tls_ctx_options tls_options = {0};
1291-
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&cert_buf, allocator, "ed384_server.pem"));
1292-
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&key_buf, allocator, "ed384_key.pem"));
1293-
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&ca_buf, allocator, "AmazonRootCA1.pem"));
12941271

1295-
// ASSERT_SUCCESS(aws_byte_buf_init_from_file(&cert_buf, allocator, "server_EC384.pem"));
1296-
// ASSERT_SUCCESS(aws_byte_buf_init_from_file(&key_buf, allocator, "server_EC384.key"));
1297-
//ASSERT_SUCCESS(aws_byte_buf_init_from_file(&ca_buf, allocator, "ca.pem"));
1272+
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&cert_buf, allocator, "ed384_server.pem"));
1273+
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&key_buf, allocator, "ed384_key.pem"));
1274+
ASSERT_SUCCESS(aws_byte_buf_init_from_file(&ca_buf, allocator, "AmazonRootCA1.pem"));
12981275

12991276
struct aws_byte_cursor cert_cur = aws_byte_cursor_from_buf(&cert_buf);
13001277
struct aws_byte_cursor key_cur = aws_byte_cursor_from_buf(&key_buf);
@@ -1307,10 +1284,7 @@ static int s_verify_good_host_mqtt_connect(
13071284

13081285
struct aws_tls_ctx *tls_context = aws_tls_client_ctx_new(allocator, &tls_options);
13091286
ASSERT_NOT_NULL(tls_context);
1310-
/* new */
13111287
tls_client_conn_options.ctx = tls_context;
1312-
/* new */
1313-
/* ***** new ****** */
13141288

13151289
struct aws_byte_cursor host_name_cur = aws_byte_cursor_from_string(host_name);
13161290
aws_tls_connection_options_set_server_name(&tls_client_conn_options, allocator, &host_name_cur);
@@ -1354,8 +1328,6 @@ static int s_verify_good_host_mqtt_connect(
13541328
ASSERT_FALSE(outgoing_args.error_invoked);
13551329
struct aws_byte_buf expected_protocol = aws_byte_buf_from_c_str("x-amzn-mqtt-ca");
13561330
/* check ALPN and SNI was properly negotiated */
1357-
1358-
13591331
if (aws_tls_is_alpn_available() && client_ctx_options.verify_peer) {
13601332
ASSERT_BIN_ARRAYS_EQUALS(
13611333
expected_protocol.buffer,
@@ -1364,19 +1336,12 @@ static int s_verify_good_host_mqtt_connect(
13641336
outgoing_args.negotiated_protocol.len);
13651337
}
13661338

1339+
ASSERT_BIN_ARRAYS_EQUALS(
1340+
host_name->bytes, host_name->len, outgoing_args.server_name.buffer, outgoing_args.server_name.len);
13671341

1368-
// ASSERT_BIN_ARRAYS_EQUALS(
1369-
// host_name->bytes, host_name->len, outgoing_args.server_name.buffer, outgoing_args.server_name.len);
1370-
1371-
1372-
/* XXX: ---- new ----*/
13731342
/* Do the IO operations */
1374-
printf(" ============================================= doing the io operaion \n");
13751343
outgoing_rw_args.invocation_happened = false;
13761344
rw_handler_write(outgoing_args.rw_handler, outgoing_args.rw_slot, &write_tag);
1377-
1378-
1379-
printf(" ============================================= waiting to read data \n");
13801345
ASSERT_SUCCESS(aws_mutex_lock(&c_tester.mutex));
13811346

13821347
ASSERT_SUCCESS(aws_condition_variable_wait_pred(
@@ -1386,36 +1351,13 @@ static int s_verify_good_host_mqtt_connect(
13861351
ASSERT_SUCCESS(aws_mutex_unlock(&c_tester.mutex));
13871352

13881353
aws_mutex_lock(outgoing_rw_args.mutex);
1389-
printf("=====================================printing message received message buffer\n");
1390-
for (size_t i = 0; i < outgoing_rw_args.received_message.len; i++) {
1391-
printf(" %.2X ", outgoing_rw_args.received_message.buffer[i]);
1392-
}
1393-
printf("\n");
1394-
//printf("conn ack is %d\n", outgoing_rw_args.received_message.buffer[3]);
13951354

13961355
ASSERT_INT_EQUALS(0x20, outgoing_rw_args.received_message.buffer[0]); /* conn ack */
1397-
ASSERT_INT_EQUALS(0x02, outgoing_rw_args.received_message.buffer[1]); /* conn ack */
1398-
ASSERT_INT_EQUALS(0x01, outgoing_rw_args.received_message.buffer[2]); /* conn ack */
1399-
ASSERT_INT_EQUALS(0x00, outgoing_rw_args.received_message.buffer[3]); /* conn ack */
1356+
ASSERT_INT_EQUALS(0x02, outgoing_rw_args.received_message.buffer[1]);
1357+
ASSERT_INT_EQUALS(0x00, outgoing_rw_args.received_message.buffer[2]); /* clean session */
1358+
ASSERT_INT_EQUALS(0x00, outgoing_rw_args.received_message.buffer[3]);
14001359
aws_mutex_unlock(outgoing_rw_args.mutex);
14011360

1402-
//ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[0]); /* conn ack */
1403-
//ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[1]); /* conn ack */
1404-
//ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[2]); /* conn ack */
1405-
printf(" ============================================= data read\n");
1406-
1407-
//outgoing_rw_args.invocation_happened = false;
1408-
//ASSERT_INT_EQUALS(1, outgoing_rw_args.read_invocations);
1409-
1410-
/*
1411-
struct aws_byte_cursor cert_cur = aws_byte_cursor_from_buf(&cert_buf);
1412-
struct aws_byte_cursor key_cur = aws_byte_cursor_from_buf(&key_buf);
1413-
struct aws_byte_cursor ca_cur = aws_byte_cursor_from_buf(&ca_buf);
1414-
*/
1415-
/* ---- */
1416-
1417-
printf(" ======================================================= freeing memory\n");
1418-
14191361
ASSERT_SUCCESS(aws_mutex_lock(&c_tester.mutex));
14201362
aws_channel_shutdown(outgoing_args.channel, AWS_OP_SUCCESS);
14211363
ASSERT_SUCCESS(aws_condition_variable_wait_pred(
@@ -1428,7 +1370,6 @@ static int s_verify_good_host_mqtt_connect(
14281370
aws_tls_ctx_release(client_ctx);
14291371
aws_tls_ctx_release(client_ctx);
14301372
aws_tls_ctx_release(tls_context->impl);
1431-
//aws_tls_ctx_release(tls_context->impl);
14321373

14331374
aws_tls_ctx_options_clean_up(&tls_options);
14341375

@@ -1465,15 +1406,10 @@ static int s_tls_client_channel_negotiation_success_ecc384_fn(struct aws_allocat
14651406
}
14661407

14671408
AWS_TEST_CASE(tls_client_channel_negotiation_success_ecc384, s_tls_client_channel_negotiation_success_ecc384_fn)
1468-
1469-
//AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "a2w1wmp9234lcw-ats.iot.us-west-2.amazonaws.com");
1470-
//AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "192.168.1.152"); /* mosuquitto/openssl local server */
14711409
AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "a2yvr5l8sc9814-ats.iot.us-east-2.amazonaws.com");
1472-
//AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "172.17.48.219"); /* s2n windows wsl */
14731410

14741411
static int s_tls_client_channel_negotiation_success_ecc384_tls1_3_fn(struct aws_allocator *allocator, void *ctx) {
14751412
(void)ctx;
1476-
//return s_verify_good_host_mqtt_connect(allocator, s_aws_ecc384_host_name, 8883, NULL);
14771413
return s_verify_good_host_mqtt_connect(allocator, s_aws_ecc384_host_name, 443, NULL);
14781414
}
14791415

0 commit comments

Comments
 (0)