From 1b674ca391e784c360b61c369491ff05bff4cd80 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Sun, 3 Dec 2023 05:52:40 +0000 Subject: [PATCH] feat(bt): Add tests to for unauth overwrite. * Two tests to ensure unauth overwrite does the right thing when hosts try to pair again without the profile cleared on the ZMK side. --- .../centrals.txt | 1 + .../events.patterns | 1 + .../nrf52_bsim.conf | 2 ++ .../nrf52_bsim.keymap | 25 +++++++++++++ .../snapshot.log | 36 +++++++++++++++++++ .../centrals.txt | 1 + .../events.patterns | 1 + .../nrf52_bsim.conf | 1 + .../nrf52_bsim.keymap | 25 +++++++++++++ .../snapshot.log | 36 +++++++++++++++++++ 10 files changed, 129 insertions(+) create mode 100644 app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt create mode 100644 app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/events.patterns create mode 100644 app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf create mode 100644 app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log create mode 100644 app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt create mode 100644 app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/events.patterns create mode 100644 app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf create mode 100644 app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap create mode 100644 app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log diff --git a/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt new file mode 100644 index 000000000000..53d70e32353e --- /dev/null +++ b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt @@ -0,0 +1 @@ +./ble_test_central.exe -d=2 -disconnect_and_reconnect -clear_bond_on_disconnect diff --git a/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/events.patterns b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/events.patterns new file mode 100644 index 000000000000..cca5a2d4ed3f --- /dev/null +++ b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/events.patterns @@ -0,0 +1 @@ +s/^d_02: @[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9] .{19}//p diff --git a/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf new file mode 100644 index 000000000000..5b2732d23301 --- /dev/null +++ b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf @@ -0,0 +1,2 @@ +CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y +CONFIG_ZMK_BLE_PASSKEY_ENTRY=y \ No newline at end of file diff --git a/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap new file mode 100644 index 000000000000..789cec44337c --- /dev/null +++ b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_SEL 1>; + }; + }; +}; diff --git a/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log new file mode 100644 index 000000000000..da2a0c772d7f --- /dev/null +++ b/app/tests/ble/profiles/overwrite-and-passkey-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log @@ -0,0 +1,36 @@ + bt_id: No static addresses stored in controller + ble_central: _posix_zephyr_main: [Bluetooth initialized] + ble_central: start_scan: [Scanning successfully started] + ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 + ble_central: eir_found: [AD]: 9 data_len 0 + ble_central: eir_found: [AD]: 25 data_len 2 + ble_central: eir_found: [AD]: 1 data_len 1 + ble_central: eir_found: [AD]: 2 data_len 4 + ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random) + ble_central: connected: [Setting the security for the connection] + ble_central: pairing_complete: Pairing complete + ble_central: disconnected: [Disconnected]: ED:3B:20:15:18:12 (random) (reason 0x16) + ble_central: start_scan: [Scanning successfully started] + ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 + ble_central: eir_found: [AD]: 9 data_len 0 + ble_central: eir_found: [AD]: 25 data_len 2 + ble_central: eir_found: [AD]: 1 data_len 1 + ble_central: eir_found: [AD]: 2 data_len 4 + ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random) + ble_central: connected: [Setting the security for the connection] + ble_central: pairing_complete: Pairing complete + ble_central: discover_conn: [Discovery started for conn] + ble_central: discover_func: [ATTRIBUTE] handle 23 + ble_central: discover_func: [ATTRIBUTE] handle 28 + ble_central: discover_func: [ATTRIBUTE] handle 30 + ble_central: discover_func: [SUBSCRIBED] + ble_central: notify_func: payload + 00 00 04 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 00 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 05 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 00 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 00 00 00 00 00 00 |........ diff --git a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt new file mode 100644 index 000000000000..53d70e32353e --- /dev/null +++ b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/centrals.txt @@ -0,0 +1 @@ +./ble_test_central.exe -d=2 -disconnect_and_reconnect -clear_bond_on_disconnect diff --git a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/events.patterns b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/events.patterns new file mode 100644 index 000000000000..cca5a2d4ed3f --- /dev/null +++ b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/events.patterns @@ -0,0 +1 @@ +s/^d_02: @[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9] .{19}//p diff --git a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf new file mode 100644 index 000000000000..e1bee6a7ed3d --- /dev/null +++ b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.conf @@ -0,0 +1 @@ +CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y \ No newline at end of file diff --git a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap new file mode 100644 index 000000000000..789cec44337c --- /dev/null +++ b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/nrf52_bsim.keymap @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +&kscan { + events = + ; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &bt BT_SEL 0 &bt BT_SEL 1>; + }; + }; +}; diff --git a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log new file mode 100644 index 000000000000..da2a0c772d7f --- /dev/null +++ b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log @@ -0,0 +1,36 @@ + bt_id: No static addresses stored in controller + ble_central: _posix_zephyr_main: [Bluetooth initialized] + ble_central: start_scan: [Scanning successfully started] + ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 + ble_central: eir_found: [AD]: 9 data_len 0 + ble_central: eir_found: [AD]: 25 data_len 2 + ble_central: eir_found: [AD]: 1 data_len 1 + ble_central: eir_found: [AD]: 2 data_len 4 + ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random) + ble_central: connected: [Setting the security for the connection] + ble_central: pairing_complete: Pairing complete + ble_central: disconnected: [Disconnected]: ED:3B:20:15:18:12 (random) (reason 0x16) + ble_central: start_scan: [Scanning successfully started] + ble_central: device_found: [DEVICE]: ED:3B:20:15:18:12 (random), AD evt type 0, AD data len 15, RSSI -59 + ble_central: eir_found: [AD]: 9 data_len 0 + ble_central: eir_found: [AD]: 25 data_len 2 + ble_central: eir_found: [AD]: 1 data_len 1 + ble_central: eir_found: [AD]: 2 data_len 4 + ble_central: connected: [Connected]: ED:3B:20:15:18:12 (random) + ble_central: connected: [Setting the security for the connection] + ble_central: pairing_complete: Pairing complete + ble_central: discover_conn: [Discovery started for conn] + ble_central: discover_func: [ATTRIBUTE] handle 23 + ble_central: discover_func: [ATTRIBUTE] handle 28 + ble_central: discover_func: [ATTRIBUTE] handle 30 + ble_central: discover_func: [SUBSCRIBED] + ble_central: notify_func: payload + 00 00 04 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 00 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 05 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 00 00 00 00 00 00 |........ + ble_central: notify_func: payload + 00 00 00 00 00 00 00 00 |........