mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-10 06:40:23 +00:00
fix security manager test
This commit is contained in:
parent
4eb412ed88
commit
fe03d808ac
@ -9,6 +9,7 @@ SUBDIRS = \
|
||||
linked_list \
|
||||
remote_device_db \
|
||||
sdp_client \
|
||||
security_manager \
|
||||
|
||||
# security_manager \
|
||||
|
||||
|
@ -19,8 +19,14 @@ static uint16_t packet_buffer_len = 0;
|
||||
|
||||
static uint8_t aes128_cyphertext[16];
|
||||
|
||||
static hci_connection_t the_connection;
|
||||
static linked_list_t connections;
|
||||
|
||||
void mock_init(void){
|
||||
the_connection.item.next = NULL;
|
||||
connections = (linked_item*) &the_connection;
|
||||
}
|
||||
|
||||
uint8_t * mock_packet_buffer(void){
|
||||
return packet_buffer;
|
||||
}
|
||||
@ -119,17 +125,13 @@ int hci_can_send_packet_now_using_packet_buffer(uint8_t packet_type){
|
||||
return 1;
|
||||
}
|
||||
|
||||
// todo:
|
||||
hci_connection_t * hci_connection_for_bd_addr_and_type(bd_addr_t addr, bd_addr_type_t addr_type){
|
||||
printf("hci_connection_for_bd_addr_and_type not implemented in mock backend\n");
|
||||
return NULL;
|
||||
return &the_connection;
|
||||
}
|
||||
hci_connection_t * hci_connection_for_handle(hci_con_handle_t con_handle){
|
||||
printf("hci_connection_for_handle not implemented in mock backend\n");
|
||||
return NULL;
|
||||
return &the_connection;
|
||||
}
|
||||
void hci_connections_get_iterator(linked_list_iterator_t *it){
|
||||
// printf("hci_connections_get_iterator not implemented in mock backend\n");
|
||||
linked_list_iterator_init(it, &connections);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,10 @@ uint8_t test_command_packet_02[] = {
|
||||
0x17, 0x20, 0x20, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93,
|
||||
0x92, 0x91, 0x90, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, };
|
||||
uint8_t test_command_packet_02a[] = {
|
||||
0x17, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x68, 0xc9, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 };
|
||||
uint8_t test_acl_packet_03[] = {
|
||||
0x40, 0x00, 0x0b, 0x00, 0x07, 0x00, 0x06, 0x00, 0x02, 0x03, 0x00, 0x01, 0x10, 0x07, 0x07, };
|
||||
uint8_t test_command_packet_04[] = {
|
||||
@ -101,13 +105,14 @@ uint8_t test_acl_packet_22[] = {
|
||||
0x5b, 0x93, 0x93, 0xc1, 0x8b, 0x09, 0xd0, 0xb8, 0x80, };
|
||||
|
||||
bd_addr_t test_device_addr = {0x34, 0xb1, 0xf7, 0xd1, 0x77, 0x9b};
|
||||
|
||||
void mock_simulate_hci_state_working();
|
||||
|
||||
void mock_init(void);
|
||||
void mock_simulate_hci_state_working(void);
|
||||
void mock_simulate_hci_event(uint8_t * packet, uint16_t size);
|
||||
void aes128_report_result();
|
||||
void aes128_report_result(void);
|
||||
void mock_simulate_sm_data_packet(uint8_t * packet, uint16_t size);
|
||||
void mock_simulate_command_complete(const hci_cmd_t *cmd);
|
||||
void mock_simulate_connected();
|
||||
void mock_simulate_connected(void);
|
||||
uint8_t * mock_packet_buffer(void);
|
||||
uint16_t mock_packet_buffer_len(void);
|
||||
void mock_clear_packet_buffer(void);
|
||||
@ -141,10 +146,9 @@ TEST_GROUP(SecurityManager){
|
||||
|
||||
TEST(SecurityManager, MainTest){
|
||||
|
||||
mock_init();
|
||||
mock_simulate_hci_state_working();
|
||||
|
||||
printf("0\n");
|
||||
|
||||
// expect le encrypt commmand
|
||||
CHECK_HCI_COMMAND(test_command_packet_01);
|
||||
|
||||
@ -154,26 +158,31 @@ TEST(SecurityManager, MainTest){
|
||||
CHECK_HCI_COMMAND(test_command_packet_02);
|
||||
|
||||
aes128_report_result();
|
||||
|
||||
printf("1\n");
|
||||
mock_clear_packet_buffer();
|
||||
|
||||
mock_simulate_connected();
|
||||
|
||||
|
||||
CHECK_HCI_COMMAND(test_command_packet_02a);
|
||||
aes128_report_result();
|
||||
|
||||
CHECK_HCI_COMMAND(test_command_packet_02a);
|
||||
aes128_report_result();
|
||||
|
||||
CHECK_HCI_COMMAND(test_command_packet_02a);
|
||||
aes128_report_result();
|
||||
|
||||
CHECK_HCI_COMMAND(test_command_packet_02a);
|
||||
aes128_report_result();
|
||||
|
||||
uint8_t test_pairing_request_command[] = { 0x01, 0x04, 0x00, 0x01, 0x10, 0x07, 0x07 };
|
||||
mock_simulate_sm_data_packet(&test_pairing_request_command[0], sizeof(test_pairing_request_command));
|
||||
|
||||
printf("2\n");
|
||||
|
||||
// expect send pairing response command
|
||||
CHECK_ACL_PACKET(test_acl_packet_03);
|
||||
|
||||
printf("3\n");
|
||||
|
||||
uint8_t test_pairing_confirm_command[] = { 0x03, 0x84, 0x5a, 0x87, 0x9a, 0x0f, 0xa9, 0x42, 0xba, 0x48, 0xc5, 0x79, 0xa0, 0x70, 0x70, 0xa9, 0xc8 };
|
||||
mock_simulate_sm_data_packet(&test_pairing_confirm_command[0], sizeof(test_pairing_confirm_command));
|
||||
|
||||
printf("4\n");
|
||||
|
||||
// expect le random command
|
||||
CHECK_HCI_COMMAND(test_command_packet_04);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user