Skip to content

Commit b5db5cd

Browse files
committed
Rename AllowedSigner to AllowedSignersEntry
1 parent 979842b commit b5db5cd

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

benches/write_allowed_signers.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
use chrono::{Local, TimeZone};
22
use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion};
3-
use hanko::{AllowedSigner, AllowedSignersFile};
3+
use hanko::{AllowedSignersEntry, AllowedSignersFile};
44

55
pub fn criterion_benchmark(c: &mut Criterion) {
66
let mut file = AllowedSignersFile {
77
file: tempfile::tempfile().unwrap(),
88
signers: vec![
9-
AllowedSigner {
9+
AllowedSignersEntry {
1010
principal: "j.snow@wall.com".to_string(),
1111
valid_after: None,
1212
valid_before: None,
1313
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGtQUDZWhs8k/cZcykMkaoX7ZE7DXld8TP79HyddMVTS"
1414
.parse()
1515
.unwrap(),
1616
},
17-
AllowedSigner {
17+
AllowedSignersEntry {
1818
principal: "ian.malcom@acme.corp".to_string(),
1919
valid_after: Some(Local.with_ymd_and_hms(2024, 4, 11, 22, 00, 00).unwrap()),
2020
valid_before: None,
2121
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILWtK6WxXw7NVhbn6fTQ0dECF8y98fahSIsqKMh+sSo9"
2222
.parse()
2323
.unwrap(),
2424
},
25-
AllowedSigner {
25+
AllowedSignersEntry {
2626
principal: "cwoods@universal.exports".to_string(),
2727
valid_after: None,
2828
valid_before: Some(Local.with_ymd_and_hms(2030, 1, 1, 0, 0, 0).unwrap()),

src/cli/update.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! The update subcommand used to get the latest allowed signers and write them to the output file.
2-
use crate::{AllowedSigner, Config, Source, SshPublicKey};
2+
use crate::{AllowedSignersEntry, Config, Source, SshPublicKey};
33
use std::collections::{HashMap, HashSet};
44

55
pub(super) fn update(config: Config) {
66
let sources = config.get_sources();
77

8-
let mut allowed_signers: HashSet<AllowedSigner> = HashSet::new();
8+
let mut allowed_signers: HashSet<AllowedSignersEntry> = HashSet::new();
99
if let Some(users) = config.users {
1010
for user in users {
1111
let public_keys = get_public_keys((), &sources);

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#![warn(clippy::panic)]
33
#![forbid(unsafe_code)]
44

5-
pub use allowed_signers::{AllowedSigner, AllowedSignersFile};
65
pub use config::Config;
76
pub use core::*;
7+
pub use signer::{AllowedSignersEntry, AllowedSignersFile};
88
pub use source::Source;
99

10-
mod allowed_signers;
1110
pub mod cli;
1211
mod config;
1312
mod core;
13+
mod signer;
1414
mod source;

src/allowed_signers.rs src/signer.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ use std::{
1212

1313
/// A single entry in the allowed signers file.
1414
#[derive(Debug)]
15-
pub struct AllowedSigner {
15+
pub struct AllowedSignersEntry {
1616
pub principal: String,
1717
pub valid_after: Option<DateTime<Local>>,
1818
pub valid_before: Option<DateTime<Local>>,
1919
pub key: SshPublicKey,
2020
}
2121

22-
impl AllowedSigner {
22+
impl AllowedSignersEntry {
2323
/// The format string for timestamps.
2424
const TIMESTAMP_FMT: &'static str = "%Y%m%d%H%M%S";
2525
}
2626

27-
impl fmt::Display for AllowedSigner {
27+
impl fmt::Display for AllowedSignersEntry {
2828
/// Display the allowed signer in the format expected by the `allowed_signers` file.
2929
///
3030
/// # Examples
3131
/// ```
32-
/// # use hanko::AllowedSigner;
32+
/// # use hanko::AllowedSignersEntry;
3333
/// # use chrono::{TimeZone, Local};
34-
/// let signer = AllowedSigner {
34+
/// let signer = AllowedSignersEntry {
3535
/// principal: "cwoods@universal.exports".to_string(),
3636
/// valid_after: None,
3737
/// valid_before: Some(Local.with_ymd_and_hms(2030, 1, 1, 0, 0, 0).unwrap()),
@@ -67,11 +67,11 @@ impl fmt::Display for AllowedSigner {
6767
#[derive(Debug)]
6868
pub struct AllowedSignersFile {
6969
pub file: File,
70-
pub signers: Vec<AllowedSigner>,
70+
pub signers: Vec<AllowedSignersEntry>,
7171
}
7272

7373
impl AllowedSignersFile {
74-
pub fn new(path: &Path, signers: Vec<AllowedSigner>) -> io::Result<Self> {
74+
pub fn new(path: &Path, signers: Vec<AllowedSignersEntry>) -> io::Result<Self> {
7575
let file = File::create(path)?;
7676
Ok(Self { file, signers })
7777
}
@@ -95,8 +95,8 @@ mod tests {
9595
use std::fs;
9696

9797
#[fixture]
98-
fn signer_jsnow() -> AllowedSigner {
99-
AllowedSigner {
98+
fn signer_jsnow() -> AllowedSignersEntry {
99+
AllowedSignersEntry {
100100
principal: "j.snow@wall.com".to_string(),
101101
valid_after: None,
102102
valid_before: None,
@@ -107,8 +107,8 @@ mod tests {
107107
}
108108

109109
#[fixture]
110-
fn signer_imalcom() -> AllowedSigner {
111-
AllowedSigner {
110+
fn signer_imalcom() -> AllowedSignersEntry {
111+
AllowedSignersEntry {
112112
principal: "ian.malcom@acme.corp".to_string(),
113113
valid_after: Some(Local.with_ymd_and_hms(2024, 4, 11, 22, 00, 00).unwrap()),
114114
valid_before: None,
@@ -119,8 +119,8 @@ mod tests {
119119
}
120120

121121
#[fixture]
122-
fn signer_cwoods() -> AllowedSigner {
123-
AllowedSigner {
122+
fn signer_cwoods() -> AllowedSignersEntry {
123+
AllowedSignersEntry {
124124
principal: "cwoods@universal.exports".to_string(),
125125
valid_after: None,
126126
valid_before: Some(Local.with_ymd_and_hms(2030, 1, 1, 0, 0, 0).unwrap()),
@@ -131,7 +131,7 @@ mod tests {
131131
}
132132

133133
#[fixture]
134-
fn example_signers() -> Vec<AllowedSigner> {
134+
fn example_signers() -> Vec<AllowedSignersEntry> {
135135
vec![signer_jsnow(), signer_imalcom(), signer_cwoods()]
136136
}
137137

@@ -148,12 +148,12 @@ mod tests {
148148
signer_cwoods(),
149149
"cwoods@universal.exports valid-before=20300101000000 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHDGMF+tZQL3dcr1arPst+YP8v33Is0kAJVvyTKrxMw"
150150
)]
151-
fn display_allowed_signer(#[case] signer: AllowedSigner, #[case] expected_display: &str) {
151+
fn display_allowed_signer(#[case] signer: AllowedSignersEntry, #[case] expected_display: &str) {
152152
assert_eq!(signer.to_string(), expected_display);
153153
}
154154

155155
#[rstest]
156-
fn write_allowed_signers_file(example_signers: Vec<AllowedSigner>) {
156+
fn write_allowed_signers_file(example_signers: Vec<AllowedSignersEntry>) {
157157
let path = tempfile::NamedTempFile::new().unwrap().into_temp_path();
158158
let mut expected_content = String::new();
159159
for signer in &example_signers {
@@ -171,7 +171,7 @@ mod tests {
171171
}
172172

173173
#[rstest]
174-
fn writing_overrides_existing_content(example_signers: Vec<AllowedSigner>) {
174+
fn writing_overrides_existing_content(example_signers: Vec<AllowedSignersEntry>) {
175175
let existing_content = "gathered dust";
176176
let mut existing_file = tempfile::NamedTempFile::new().unwrap();
177177
writeln!(existing_file, "{existing_content}").unwrap();

0 commit comments

Comments
 (0)