summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-06 23:27:06 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-07 00:29:52 +0100
commit3fab663891d42cfe317125650394c9560639b60c (patch)
tree36d72acd96d49cc1d8da85b920a30a42acc721cb /tests
parentd44f8be7c038bc499b36aa502f4939f41ebebfbf (diff)
downloadnitrokey-rs-3fab663891d42cfe317125650394c9560639b60c.tar.gz
nitrokey-rs-3fab663891d42cfe317125650394c9560639b60c.tar.bz2
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/device.rs10
1 files changed, 10 insertions, 0 deletions
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() {