diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-09-21 07:47:15 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-09-21 07:47:15 +0300 |
commit | e3364a68f77a0af164be19b4b802033cc778911d (patch) | |
tree | a8c75f9fc4e0f5122b13d812abbf04ecc395a79f | |
parent | bb830960fedcc58a47141406ef7707f4892fb2db (diff) | |
download | sshca-e3364a68f77a0af164be19b4b802033cc778911d.tar.gz |
fix: add principals to host
Previously, adding replaced the whole set of principals, which was
wrong. Also, change the test scenario to catch the problem this fixes.
Sponsored-by: author
-rw-r--r-- | src/cmd/host.rs | 2 | ||||
-rw-r--r-- | sshca.md | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/host.rs b/src/cmd/host.rs index d3a85b4..830a5f4 100644 --- a/src/cmd/host.rs +++ b/src/cmd/host.rs @@ -466,7 +466,7 @@ pub struct AddPrincipals { impl Runnable for AddPrincipals { fn run(&mut self, _config: &Config, store: &mut KeyStore) -> Result<(), CAError> { if let Some(host) = store.get_host_mut(&self.hostname) { - host.set_principals(&self.principals); + host.add_principals(&self.principals); assert!(store.is_dirty()); Ok(()) } else { @@ -468,7 +468,12 @@ when I run sshca host principals list myhost then stdout doesn't contain "alfred.lan" then stdout doesn't contain "alfred.example.com" -when I run sshca host principals add --host myhost alfred.lan alfred.example.com +when I run sshca host principals add --host myhost alfred.lan +when I run sshca host principals list myhost +then stdout contains "alfred.lan" +then stdout doesn't contain "alfred.example.com" + +when I run sshca host principals add --host myhost alfred.example.com when I run sshca host principals list myhost then stdout contains "alfred.lan" then stdout contains "alfred.example.com" |