From 2e13802a38469d5cb9a7fbbca8c029a9ce9e9f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Battrel?= Date: Fri, 22 Sep 2023 13:16:37 +0200 Subject: [PATCH] Bluetooth: Test: Update `security/ccc_update` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous commit reverted the `link_encrypted` filed of CCC config. Update the test to match the new expected behavior. Signed-off-by: Théo Battrel --- .../host/security/ccc_update/src/central.c | 9 ++---- .../host/security/ccc_update/src/peripheral.c | 28 ++++++++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/bsim/bluetooth/host/security/ccc_update/src/central.c b/tests/bsim/bluetooth/host/security/ccc_update/src/central.c index fbdf7ee0108..8f2d2c17dd4 100644 --- a/tests/bsim/bluetooth/host/security/ccc_update/src/central.c +++ b/tests/bsim/bluetooth/host/security/ccc_update/src/central.c @@ -248,7 +248,7 @@ static void connect_unsubscribe(void) backchannel_sync_wait(SERVER_CLIENT_CHAN, SERVER_ID); } -static void connect_restore_sec_unsubscribe(void) +static void connect_restore_sec(void) { int err; @@ -270,10 +270,7 @@ static void connect_restore_sec_unsubscribe(void) /* wait for server to check that the subscribtion has been restored */ backchannel_sync_wait(SERVER_CLIENT_CHAN, SERVER_ID); - /* send unsubscribtion request */ - ccc_unsubscribe(); - - /* wait for server to check that the unsubscribtion has been well registered */ + /* wait for server to check that the subscription no longer exist */ backchannel_sync_send(SERVER_CLIENT_CHAN, SERVER_ID); } @@ -347,7 +344,7 @@ void run_central(void) backchannel_sync_send(CLIENT_CLIENT_CHAN, BAD_CLIENT_ID); backchannel_sync_wait(CLIENT_CLIENT_CHAN, BAD_CLIENT_ID); - connect_restore_sec_unsubscribe(); + connect_restore_sec(); disconnect(); PASS("Central test passed\n"); diff --git a/tests/bsim/bluetooth/host/security/ccc_update/src/peripheral.c b/tests/bsim/bluetooth/host/security/ccc_update/src/peripheral.c index b9070361577..ac6307dae6a 100644 --- a/tests/bsim/bluetooth/host/security/ccc_update/src/peripheral.c +++ b/tests/bsim/bluetooth/host/security/ccc_update/src/peripheral.c @@ -194,9 +194,9 @@ static void connect_wait_unsubscribtion(struct bt_le_ext_adv *adv) stop_adv(adv); - /* check that subscribtion is not restored for bad client */ - if (is_peer_subscribed(default_conn)) { - FAIL("Subscribtion has been restored for bad client\n"); + /* check that subscribtion is restored for bad client */ + if (!is_peer_subscribed(default_conn)) { + FAIL("Subscribtion has not been restored for bad client\n"); } /* confirm to bad client that the subscribtion had not been restored */ @@ -204,12 +204,12 @@ static void connect_wait_unsubscribtion(struct bt_le_ext_adv *adv) /* wait for confirmation that bad client requested unsubscribtion */ backchannel_sync_wait(BAD_CLIENT_CHAN, BAD_CLIENT_ID); - /* check that unsubscribtion request failed */ - if (GET_FLAG(ccc_cfg_changed_flag)) { - FAIL("Bad client updated CCC config\n"); + /* check that unsubscribtion request didn't fail */ + if (!GET_FLAG(ccc_cfg_changed_flag)) { + FAIL("Bad client didn't manage to update CCC config\n"); } - /* confirm to bad client that unsubscribtion request has been ignored */ + /* confirm to bad client that unsubscribtion request has been well registered */ backchannel_sync_send(BAD_CLIENT_CHAN, BAD_CLIENT_ID); } @@ -225,9 +225,9 @@ static void connect_restore_sec_check_subscribtion(struct bt_le_ext_adv *adv) /* wait for good client end of security update */ backchannel_sync_wait(GOOD_CLIENT_CHAN, GOOD_CLIENT_ID); - /* check that subscribtion has been restored */ - if (!is_peer_subscribed(default_conn)) { - FAIL("Good client is not subscribed\n"); + /* check that subscribtion hasn't been restored */ + if (is_peer_subscribed(default_conn)) { + FAIL("Good client is subscribed\n"); } /* confirm to good client that the subscribtion has been well restored */ @@ -285,6 +285,14 @@ static void check_ccc_handle(void) void run_peripheral(void) { + /* + * test goal: demonstrate the expected behavior of the GATT server when + * a non-bonded peer try to unsubscribe from a previously subscription + * done in a bonded context + * + * test pass if the bad client manage to unsubscribe + */ + int err; struct bt_le_ext_adv *adv = NULL;