summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nitrocli/src/commands.rs4
-rw-r--r--nitrocli/src/tests/mod.rs13
-rw-r--r--nitrocli/src/tests/pin.rs8
-rw-r--r--nitrocli/src/tests/reset.rs4
4 files changed, 12 insertions, 17 deletions
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs
index 1d3ba65..37698f7 100644
--- a/nitrocli/src/commands.rs
+++ b/nitrocli/src/commands.rs
@@ -36,8 +36,6 @@ use crate::error::Error;
use crate::pinentry;
use crate::Result;
-const NITROKEY_DEFAULT_ADMIN_PIN: &str = "12345678";
-
/// Create an `error::Error` with an error message of the format `msg: err`.
fn get_error(msg: &'static str, err: nitrokey::Error) -> Error {
Error::NitrokeyError(Some(msg), err)
@@ -387,7 +385,7 @@ pub fn reset(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
// build_aes_key after a factory reset on Pro devices.
// https://github.com/Nitrokey/nitrokey-pro-firmware/issues/57
let _ = device.get_user_retry_count();
- device.build_aes_key(NITROKEY_DEFAULT_ADMIN_PIN)
+ device.build_aes_key(nitrokey::DEFAULT_ADMIN_PIN)
})
})
}
diff --git a/nitrocli/src/tests/mod.rs b/nitrocli/src/tests/mod.rs
index 382ad3b..b79f96f 100644
--- a/nitrocli/src/tests/mod.rs
+++ b/nitrocli/src/tests/mod.rs
@@ -22,11 +22,6 @@ use std::fmt;
use nitrokey_test::test as test_device;
-// TODO: Those defines should potentially be taken from the `nitrokey`
-// crate, once exported.
-const NITROKEY_DEFAULT_ADMIN_PIN: &str = "12345678";
-const NITROKEY_DEFAULT_USER_PIN: &str = "123456";
-
mod config;
mod encrypted;
mod hidden;
@@ -94,8 +89,8 @@ impl Nitrocli {
pub fn new() -> Self {
Self {
model: None,
- admin_pin: Some(NITROKEY_DEFAULT_ADMIN_PIN.into()),
- user_pin: Some(NITROKEY_DEFAULT_USER_PIN.into()),
+ admin_pin: Some(nitrokey::DEFAULT_ADMIN_PIN.into()),
+ user_pin: Some(nitrokey::DEFAULT_USER_PIN.into()),
new_admin_pin: None,
new_user_pin: None,
password: None,
@@ -108,8 +103,8 @@ impl Nitrocli {
{
let result = Self {
model: Some(device.get_model()),
- admin_pin: Some(NITROKEY_DEFAULT_ADMIN_PIN.into()),
- user_pin: Some(NITROKEY_DEFAULT_USER_PIN.into()),
+ admin_pin: Some(nitrokey::DEFAULT_ADMIN_PIN.into()),
+ user_pin: Some(nitrokey::DEFAULT_USER_PIN.into()),
new_admin_pin: None,
new_user_pin: None,
password: Some("1234567".into()),
diff --git a/nitrocli/src/tests/pin.rs b/nitrocli/src/tests/pin.rs
index 69e0ff9..051129c 100644
--- a/nitrocli/src/tests/pin.rs
+++ b/nitrocli/src/tests/pin.rs
@@ -49,7 +49,7 @@ fn set_user(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
let device = nitrokey::connect_model(ncli.model().unwrap())?;
let (device, err) = device
- .authenticate_user(NITROKEY_DEFAULT_USER_PIN)
+ .authenticate_user(nitrokey::DEFAULT_USER_PIN)
.unwrap_err();
match err {
@@ -60,12 +60,14 @@ fn set_user(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
// Revert to the default user PIN.
ncli.user_pin("new-pin");
- ncli.new_user_pin(NITROKEY_DEFAULT_USER_PIN);
+ ncli.new_user_pin(nitrokey::DEFAULT_USER_PIN);
let out = ncli.handle(&["pin", "set", "user"])?;
assert!(out.is_empty());
let device = nitrokey::connect_model(ncli.model().unwrap())?;
- let _ = device.authenticate_user(NITROKEY_DEFAULT_USER_PIN).unwrap();
+ let _ = device
+ .authenticate_user(nitrokey::DEFAULT_USER_PIN)
+ .unwrap();
Ok(())
}
diff --git a/nitrocli/src/tests/reset.rs b/nitrocli/src/tests/reset.rs
index 2e567fa..12d7023 100644
--- a/nitrocli/src/tests/reset.rs
+++ b/nitrocli/src/tests/reset.rs
@@ -43,12 +43,12 @@ fn reset(device: nitrokey::DeviceWrapper) -> crate::Result<()> {
// Check that the admin PIN has been reset.
let device = nitrokey::connect_model(ncli.model().unwrap())?;
let device = device
- .authenticate_admin(NITROKEY_DEFAULT_ADMIN_PIN)
+ .authenticate_admin(nitrokey::DEFAULT_ADMIN_PIN)
.unwrap();
// Check that the password store works, i.e., the AES key has been
// built.
- let _ = device.get_password_safe(NITROKEY_DEFAULT_USER_PIN)?;
+ let _ = device.get_password_safe(nitrokey::DEFAULT_USER_PIN)?;
Ok(())
}