//! `/api/ssh/ca` — the public key of the SSH CA that signs the agents' //! certificates. use serde::{Deserialize, Serialize}; /// The CA's public key, one `authorized_keys`-style line. A public value: a /// machine puts it in its sshd config to trust the certificates the swarm /// signs. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "schema", derive(utoipa::ToSchema))] pub struct SshCa { /// For example `ssh-ed25519 AAAA…`, with no trailing newline. pub public_key: String, } #[cfg(test)] mod tests { use super::SshCa; #[test] fn the_ca_round_trips() { let wire = r#"{"public_key":"ssh-ed25519 AAAA"}"#; let value = SshCa { public_key: "ssh-ed25519 AAAA".to_owned(), }; assert_eq!(serde_json::to_string(&value).unwrap(), wire); assert_eq!(serde_json::from_str::(wire).unwrap(), value); } }