aboutsummaryrefslogtreecommitdiff
path: root/src/tests/pro.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/pro.rs')
-rw-r--r--src/tests/pro.rs27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/tests/pro.rs b/src/tests/pro.rs
index 8476451..915b45b 100644
--- a/src/tests/pro.rs
+++ b/src/tests/pro.rs
@@ -1,6 +1,6 @@
use std::ffi::CStr;
-use {AdminAuthenticatedDevice, Authenticate, CommandError, CommandStatus, Config, ConfigureOtp,
- Device, GenerateOtp, Model, OtpMode, OtpSlotData, UnauthenticatedDevice};
+use {Admin, Authenticate, CommandError, CommandStatus, Config, ConfigureOtp, Device, GenerateOtp,
+ OtpMode, OtpSlotData, Pro};
static ADMIN_PASSWORD: &str = "12345678";
static ADMIN_NEW_PASSWORD: &str = "1234567890";
@@ -25,11 +25,11 @@ static TOTP_CODES: &[(u64, &str)] = &[
(20000000000, "65353130"),
];
-fn get_test_device() -> UnauthenticatedDevice {
- ::connect_model(Model::Pro).expect("Could not connect to the Nitrokey Pro.")
+fn get_test_device() -> Pro {
+ Pro::connect().expect("Could not connect to the Nitrokey Pro.")
}
-fn get_admin_test_device() -> AdminAuthenticatedDevice {
+fn get_admin_test_device() -> Admin<Pro> {
get_test_device()
.authenticate_admin(ADMIN_PASSWORD)
.expect("Could not login as admin.")
@@ -39,8 +39,9 @@ fn get_admin_test_device() -> AdminAuthenticatedDevice {
#[cfg_attr(not(feature = "test-pro"), ignore)]
fn connect() {
assert!(::connect().is_ok());
- assert!(::connect_model(Model::Pro).is_ok());
- assert!(::connect_model(Model::Storage).is_err());
+ assert!(Pro::connect().is_ok());
+ // TODO: test storage
+ // assert!(::Storage::connect().is_err());
}
fn assert_empty_serial_number() {
@@ -55,14 +56,14 @@ fn assert_empty_serial_number() {
#[test]
#[cfg_attr(not(feature = "test-pro"), ignore)]
fn disconnect() {
- ::connect().unwrap();
+ Pro::connect().unwrap();
assert_empty_serial_number();
- ::connect()
+ Pro::connect()
.unwrap()
.authenticate_admin(ADMIN_PASSWORD)
.unwrap();
assert_empty_serial_number();
- ::connect()
+ Pro::connect()
.unwrap()
.authenticate_user(USER_PASSWORD)
.unwrap();
@@ -85,7 +86,7 @@ fn configure_hotp(admin: &ConfigureOtp) {
assert_eq!(CommandStatus::Success, admin.write_hotp_slot(slot_data, 0));
}
-fn check_hotp_codes<T: GenerateOtp>(device: &T) {
+fn check_hotp_codes(device: &GenerateOtp) {
for code in HOTP_CODES {
let result = device.get_hotp_code(1);
assert_eq!(code, &result.unwrap());
@@ -287,7 +288,7 @@ fn get_firmware_version() {
assert!(minor == 7 || minor == 8);
}
-fn admin_retry(device: UnauthenticatedDevice, suffix: &str, count: u8) -> UnauthenticatedDevice {
+fn admin_retry(device: Pro, suffix: &str, count: u8) -> Pro {
let result = device.authenticate_admin(&(ADMIN_PASSWORD.to_owned() + suffix));
let device = match result {
Ok(admin) => admin.device(),
@@ -297,7 +298,7 @@ fn admin_retry(device: UnauthenticatedDevice, suffix: &str, count: u8) -> Unauth
return device;
}
-fn user_retry(device: UnauthenticatedDevice, suffix: &str, count: u8) -> UnauthenticatedDevice {
+fn user_retry(device: Pro, suffix: &str, count: u8) -> Pro {
let result = device.authenticate_user(&(USER_PASSWORD.to_owned() + suffix));
let device = match result {
Ok(admin) => admin.device(),