From 3fab663891d42cfe317125650394c9560639b60c Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sun, 6 Jan 2019 23:27:06 +0000 Subject: Add the connect_model function This patch adds the global connect_model function that can be used to connect to a Nitrokey device of a given model. Contrary to Pro::connect and Storage::connect, the model does not have to be set at compile time. --- tests/device.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/device.rs') diff --git a/tests/device.rs b/tests/device.rs index f7d8df3..db8194c 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -31,6 +31,8 @@ fn count_nitrokey_block_devices() -> usize { #[test_device] fn connect_no_device() { assert!(nitrokey::connect().is_err()); + assert!(nitrokey::connect_model(nitrokey::Model::Pro).is_err()); + assert!(nitrokey::connect_model(nitrokey::Model::Storage).is_err()); assert!(nitrokey::Pro::connect().is_err()); assert!(nitrokey::Storage::connect().is_err()); } @@ -41,7 +43,11 @@ fn connect_pro(device: Pro) { drop(device); assert!(nitrokey::connect().is_ok()); + assert!(nitrokey::connect_model(nitrokey::Model::Pro).is_ok()); assert!(nitrokey::Pro::connect().is_ok()); + + assert!(nitrokey::connect_model(nitrokey::Model::Storage).is_err()); + assert!(nitrokey::Storage::connect().is_err()); } #[test_device] @@ -50,7 +56,11 @@ fn connect_storage(device: Storage) { drop(device); assert!(nitrokey::connect().is_ok()); + assert!(nitrokey::connect_model(nitrokey::Model::Storage).is_ok()); assert!(nitrokey::Storage::connect().is_ok()); + + assert!(nitrokey::connect_model(nitrokey::Model::Pro).is_err()); + assert!(nitrokey::Pro::connect().is_err()); } fn assert_empty_serial_number() { -- cgit v1.2.1