summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-05-21 23:22:18 +0000
committerRobin Krahl <robin.krahl@ireas.org>2018-05-22 01:23:15 +0200
commitb035b1392469a91556715071cc9751dc23a53994 (patch)
treed9740960f0b4e7c5eb8b2c295ec45f2294ac427f /src/tests
parentaac8f14edf4986c4881267a5b76a58d6800945bb (diff)
downloadnitrokey-rs-b035b1392469a91556715071cc9751dc23a53994.tar.gz
nitrokey-rs-b035b1392469a91556715071cc9751dc23a53994.tar.bz2
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.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/pro.rs18
1 files 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());
@@ -59,6 +55,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() {
let device = get_test_device();
let result = device.get_serial_number();