@@ -12,26 +12,26 @@ use std::{
12
12
13
13
/// A single entry in the allowed signers file.
14
14
#[ derive( Debug ) ]
15
- pub struct AllowedSigner {
15
+ pub struct AllowedSignersEntry {
16
16
pub principal : String ,
17
17
pub valid_after : Option < DateTime < Local > > ,
18
18
pub valid_before : Option < DateTime < Local > > ,
19
19
pub key : SshPublicKey ,
20
20
}
21
21
22
- impl AllowedSigner {
22
+ impl AllowedSignersEntry {
23
23
/// The format string for timestamps.
24
24
const TIMESTAMP_FMT : & ' static str = "%Y%m%d%H%M%S" ;
25
25
}
26
26
27
- impl fmt:: Display for AllowedSigner {
27
+ impl fmt:: Display for AllowedSignersEntry {
28
28
/// Display the allowed signer in the format expected by the `allowed_signers` file.
29
29
///
30
30
/// # Examples
31
31
/// ```
32
- /// # use hanko::AllowedSigner ;
32
+ /// # use hanko::AllowedSignersEntry ;
33
33
/// # use chrono::{TimeZone, Local};
34
- /// let signer = AllowedSigner {
34
+ /// let signer = AllowedSignersEntry {
35
35
/// principal: "cwoods@universal.exports".to_string(),
36
36
/// valid_after: None,
37
37
/// valid_before: Some(Local.with_ymd_and_hms(2030, 1, 1, 0, 0, 0).unwrap()),
@@ -67,11 +67,11 @@ impl fmt::Display for AllowedSigner {
67
67
#[ derive( Debug ) ]
68
68
pub struct AllowedSignersFile {
69
69
pub file : File ,
70
- pub signers : Vec < AllowedSigner > ,
70
+ pub signers : Vec < AllowedSignersEntry > ,
71
71
}
72
72
73
73
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 > {
75
75
let file = File :: create ( path) ?;
76
76
Ok ( Self { file, signers } )
77
77
}
@@ -95,8 +95,8 @@ mod tests {
95
95
use std:: fs;
96
96
97
97
#[ fixture]
98
- fn signer_jsnow ( ) -> AllowedSigner {
99
- AllowedSigner {
98
+ fn signer_jsnow ( ) -> AllowedSignersEntry {
99
+ AllowedSignersEntry {
100
100
principal : "j.snow@wall.com" . to_string ( ) ,
101
101
valid_after : None ,
102
102
valid_before : None ,
@@ -107,8 +107,8 @@ mod tests {
107
107
}
108
108
109
109
#[ fixture]
110
- fn signer_imalcom ( ) -> AllowedSigner {
111
- AllowedSigner {
110
+ fn signer_imalcom ( ) -> AllowedSignersEntry {
111
+ AllowedSignersEntry {
112
112
principal : "ian.malcom@acme.corp" . to_string ( ) ,
113
113
valid_after : Some ( Local . with_ymd_and_hms ( 2024 , 4 , 11 , 22 , 00 , 00 ) . unwrap ( ) ) ,
114
114
valid_before : None ,
@@ -119,8 +119,8 @@ mod tests {
119
119
}
120
120
121
121
#[ fixture]
122
- fn signer_cwoods ( ) -> AllowedSigner {
123
- AllowedSigner {
122
+ fn signer_cwoods ( ) -> AllowedSignersEntry {
123
+ AllowedSignersEntry {
124
124
principal : "cwoods@universal.exports" . to_string ( ) ,
125
125
valid_after : None ,
126
126
valid_before : Some ( Local . with_ymd_and_hms ( 2030 , 1 , 1 , 0 , 0 , 0 ) . unwrap ( ) ) ,
@@ -131,7 +131,7 @@ mod tests {
131
131
}
132
132
133
133
#[ fixture]
134
- fn example_signers ( ) -> Vec < AllowedSigner > {
134
+ fn example_signers ( ) -> Vec < AllowedSignersEntry > {
135
135
vec ! [ signer_jsnow( ) , signer_imalcom( ) , signer_cwoods( ) ]
136
136
}
137
137
@@ -148,12 +148,12 @@ mod tests {
148
148
signer_cwoods( ) ,
149
149
"cwoods@universal.exports valid-before=20300101000000 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHDGMF+tZQL3dcr1arPst+YP8v33Is0kAJVvyTKrxMw"
150
150
) ]
151
- fn display_allowed_signer ( #[ case] signer : AllowedSigner , #[ case] expected_display : & str ) {
151
+ fn display_allowed_signer ( #[ case] signer : AllowedSignersEntry , #[ case] expected_display : & str ) {
152
152
assert_eq ! ( signer. to_string( ) , expected_display) ;
153
153
}
154
154
155
155
#[ rstest]
156
- fn write_allowed_signers_file ( example_signers : Vec < AllowedSigner > ) {
156
+ fn write_allowed_signers_file ( example_signers : Vec < AllowedSignersEntry > ) {
157
157
let path = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) . into_temp_path ( ) ;
158
158
let mut expected_content = String :: new ( ) ;
159
159
for signer in & example_signers {
@@ -171,7 +171,7 @@ mod tests {
171
171
}
172
172
173
173
#[ rstest]
174
- fn writing_overrides_existing_content ( example_signers : Vec < AllowedSigner > ) {
174
+ fn writing_overrides_existing_content ( example_signers : Vec < AllowedSignersEntry > ) {
175
175
let existing_content = "gathered dust" ;
176
176
let mut existing_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
177
177
writeln ! ( existing_file, "{existing_content}" ) . unwrap ( ) ;
0 commit comments