From b035b1392469a91556715071cc9751dc23a53994 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 21 May 2018 23:22:18 +0000 Subject: Extend test case for drop() with authenticated devices As Drop is only implemented for UnauthenticatedDevice, it is relevant to test whether it also works if we work on authenticated devices. --- src/tests/pro.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tests/pro.rs b/src/tests/pro.rs index feadcbc..9cdc586 100644 --- a/src/tests/pro.rs +++ b/src/tests/pro.rs @@ -44,11 +44,7 @@ fn connect() { assert!(::connect_model(Model::Storage).is_err()); } -#[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] -fn disconnect() { - set_debug(false); - ::connect().unwrap(); +fn assert_empty_serial_number() { unsafe { let ptr = ::nitrokey_sys::NK_device_serial_number(); assert!(!ptr.is_null()); @@ -57,6 +53,18 @@ fn disconnect() { } } +#[test] +#[cfg_attr(not(feature = "test-pro"), ignore)] +fn disconnect() { + set_debug(false); + ::connect().unwrap(); + assert_empty_serial_number(); + ::connect().unwrap().authenticate_admin(ADMIN_PASSWORD).unwrap(); + assert_empty_serial_number(); + ::connect().unwrap().authenticate_user(USER_PASSWORD).unwrap(); + assert_empty_serial_number(); +} + #[test] #[cfg_attr(not(feature = "test-pro"), ignore)] fn get_serial_number() { -- cgit v1.2.1