summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs22
-rw-r--r--src/tests/pro.rs44
2 files changed, 52 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 53b0c6c..235c81b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -616,7 +616,7 @@ pub trait Device {
/// Changes the administrator PIN.
///
/// # Errors
- ///
+ ///
/// - [`InvalidString`][] if one of the provided passwords contains a null byte
/// - [`WrongPassword`][] if the current admin password is wrong
///
@@ -646,13 +646,18 @@ pub trait Device {
}
let current_string = current_string.unwrap();
let new_string = new_string.unwrap();
- unsafe { CommandStatus::from(nitrokey_sys::NK_change_admin_PIN(current_string.as_ptr(), new_string.as_ptr())) }
+ unsafe {
+ CommandStatus::from(nitrokey_sys::NK_change_admin_PIN(
+ current_string.as_ptr(),
+ new_string.as_ptr(),
+ ))
+ }
}
/// Changes the user PIN.
///
/// # Errors
- ///
+ ///
/// - [`InvalidString`][] if one of the provided passwords contains a null byte
/// - [`WrongPassword`][] if the current user password is wrong
///
@@ -682,7 +687,12 @@ pub trait Device {
}
let current_string = current_string.unwrap();
let new_string = new_string.unwrap();
- unsafe { CommandStatus::from(nitrokey_sys::NK_change_user_PIN(current_string.as_ptr(), new_string.as_ptr())) }
+ unsafe {
+ CommandStatus::from(nitrokey_sys::NK_change_user_PIN(
+ current_string.as_ptr(),
+ new_string.as_ptr(),
+ ))
+ }
}
}
@@ -1088,7 +1098,9 @@ impl UnauthenticatedDevice {
impl Drop for UnauthenticatedDevice {
fn drop(&mut self) {
- unsafe { nitrokey_sys::NK_logout(); }
+ unsafe {
+ nitrokey_sys::NK_logout();
+ }
}
}
diff --git a/src/tests/pro.rs b/src/tests/pro.rs
index 9cdc586..e39c95a 100644
--- a/src/tests/pro.rs
+++ b/src/tests/pro.rs
@@ -32,7 +32,9 @@ fn get_test_device() -> UnauthenticatedDevice {
}
fn get_admin_test_device() -> AdminAuthenticatedDevice {
- get_test_device().authenticate_admin(ADMIN_PASSWORD).expect("Could not login as admin.")
+ get_test_device()
+ .authenticate_admin(ADMIN_PASSWORD)
+ .expect("Could not login as admin.")
}
#[test]
@@ -59,9 +61,15 @@ fn disconnect() {
set_debug(false);
::connect().unwrap();
assert_empty_serial_number();
- ::connect().unwrap().authenticate_admin(ADMIN_PASSWORD).unwrap();
+ ::connect()
+ .unwrap()
+ .authenticate_admin(ADMIN_PASSWORD)
+ .unwrap();
assert_empty_serial_number();
- ::connect().unwrap().authenticate_user(USER_PASSWORD).unwrap();
+ ::connect()
+ .unwrap()
+ .authenticate_user(USER_PASSWORD)
+ .unwrap();
assert_empty_serial_number();
}
@@ -138,9 +146,15 @@ fn hotp_slot_name() {
fn hotp_error() {
let admin = get_admin_test_device();
let slot_data = OtpSlotData::new(1, "", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(CommandStatus::Error(CommandError::NoName), admin.write_hotp_slot(slot_data, 0));
+ assert_eq!(
+ CommandStatus::Error(CommandError::NoName),
+ admin.write_hotp_slot(slot_data, 0)
+ );
let slot_data = OtpSlotData::new(4, "test", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(CommandStatus::Error(CommandError::InvalidSlot), admin.write_hotp_slot(slot_data, 0));
+ assert_eq!(
+ CommandStatus::Error(CommandError::InvalidSlot),
+ admin.write_hotp_slot(slot_data, 0)
+ );
let code = admin.get_hotp_code(4);
assert_eq!(CommandError::InvalidSlot, code.unwrap_err());
}
@@ -239,9 +253,15 @@ fn totp_slot_name() {
fn totp_error() {
let admin = get_admin_test_device();
let slot_data = OtpSlotData::new(1, "", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(CommandStatus::Error(CommandError::NoName), admin.write_hotp_slot(slot_data, 0));
+ assert_eq!(
+ CommandStatus::Error(CommandError::NoName),
+ admin.write_hotp_slot(slot_data, 0)
+ );
let slot_data = OtpSlotData::new(4, "test", HOTP_SECRET, OtpMode::SixDigits);
- assert_eq!(CommandStatus::Error(CommandError::InvalidSlot), admin.write_hotp_slot(slot_data, 0));
+ assert_eq!(
+ CommandStatus::Error(CommandError::InvalidSlot),
+ admin.write_hotp_slot(slot_data, 0)
+ );
let code = admin.get_hotp_code(4);
assert_eq!(CommandError::InvalidSlot, code.unwrap_err());
}
@@ -350,7 +370,10 @@ fn change_user_pin() {
assert_eq!(CommandStatus::Success, result);
let device = device.authenticate_user(USER_PASSWORD).unwrap_err().0;
- let device = device.authenticate_user(USER_NEW_PASSWORD).unwrap().device();
+ let device = device
+ .authenticate_user(USER_NEW_PASSWORD)
+ .unwrap()
+ .device();
let result = device.change_user_pin(USER_PASSWORD, USER_PASSWORD);
assert_eq!(CommandStatus::Error(CommandError::WrongPassword), result);
@@ -373,7 +396,10 @@ fn change_admin_pin() {
assert_eq!(CommandStatus::Success, result);
let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap_err().0;
- let device = device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap().device();
+ let device = device
+ .authenticate_admin(ADMIN_NEW_PASSWORD)
+ .unwrap()
+ .device();
let result = device.change_admin_pin(ADMIN_PASSWORD, ADMIN_PASSWORD);
assert_eq!(CommandStatus::Error(CommandError::WrongPassword), result);