Skip to content

Commit 38d84e6

Browse files
committed
fixup! tests: Allow more configuration for test token
1 parent cd347d7 commit 38d84e6

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

cryptoki/tests/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ fn get_attribute_info_test() -> TestResult {
12001200
session.generate_key_pair(&mechanism, &pub_key_template, &priv_key_template)?;
12011201

12021202
let pub_attribs = vec![AttributeType::PublicExponent, AttributeType::Modulus];
1203-
let mut priv_attribs = [
1203+
let priv_attribs = [
12041204
AttributeType::PublicExponent,
12051205
AttributeType::Modulus,
12061206
AttributeType::PrivateExponent,

cryptoki/tests/common.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2021 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use cryptoki::context::{CInitializeArgs, Function, Pkcs11};
4-
use cryptoki::error::{Error, RvError};
3+
use cryptoki::context::{CInitializeArgs, Pkcs11};
54
use cryptoki::session::UserType;
65
use cryptoki::slot::Slot;
76
use cryptoki::types::AuthPin;
@@ -13,10 +12,7 @@ pub static USER_PIN: &str = "fedcba";
1312
pub static SO_PIN: &str = "abcdef";
1413

1514
fn get_token_label() -> Option<String> {
16-
match env::var("TEST_TOKEN_LABEL") {
17-
Ok(s) => Some(s),
18-
Err(_) => None,
19-
}
15+
env::var("TEST_TOKEN_LABEL").ok()
2016
}
2117

2218
fn skip_token_init() -> bool {
@@ -43,7 +39,7 @@ fn get_slot(pkcs11: &Pkcs11) -> Slot {
4339
// find a slot, get the first one or one with name specified in the environment variable
4440
let mut slots = pkcs11.get_slots_with_token().unwrap();
4541
match get_token_label() {
46-
None => return slots.remove(0),
42+
None => slots.remove(0),
4743
Some(label) => {
4844
for s in slots {
4945
let ti = pkcs11.get_token_info(s).unwrap();
@@ -53,7 +49,7 @@ fn get_slot(pkcs11: &Pkcs11) -> Slot {
5349
}
5450
panic!("No token with Token Label `{label}` found");
5551
}
56-
};
52+
}
5753
}
5854

5955
pub fn init_pins() -> (Pkcs11, Slot) {
@@ -66,7 +62,7 @@ pub fn init_pins() -> (Pkcs11, Slot) {
6662

6763
if !skip_token_init() {
6864
let so_pin = AuthPin::new(SO_PIN.into());
69-
let res = pkcs11.init_token(slot, &so_pin, "Test Token");
65+
let _ = pkcs11.init_token(slot, &so_pin, "Test Token");
7066
{
7167
// open a session
7268
let session = pkcs11.open_rw_session(slot).unwrap();

0 commit comments

Comments
 (0)