diff --git a/man/en/acmed.toml.5 b/man/en/acmed.toml.5 index 33747ee..12fe1b9 100644 --- a/man/en/acmed.toml.5 +++ b/man/en/acmed.toml.5 @@ -18,7 +18,7 @@ are written in the format. The allowed elements are described below. .Bl -tag .It Ic account -Array of table representing an account on one or several endpoint. +Table of table representing an account on one or several endpoint. .Bl -tag .It Ic contacts Ar array Array of tables describing describing the account holder's contact information. Each table must have one and only one key-value pair. Possible keys and their associated values are: @@ -78,8 +78,6 @@ rsa2048 .It rsa4096 .El -.It Ic name Ar string -The name the account is registered under. Must be unique. .It Cm signature_algorithm Ar string Name of the signature algorithm used to sign the messages sent to the endpoint as defined in .Em RFC 7518 . diff --git a/src/config.rs b/src/config.rs index 5538bfc..0a3f45d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -36,7 +36,7 @@ pub struct AcmedConfig { #[serde(default)] pub(in crate::config) group: Vec, #[serde(default)] - pub(in crate::config) account: Vec, + pub(in crate::config) account: HashMap, #[serde(default)] pub(in crate::config) certificate: Vec, } @@ -119,13 +119,12 @@ mod tests { assert!(cfg.hook.is_empty()); assert!(cfg.group.is_empty()); assert_eq!(cfg.account.len(), 1); - let account = cfg.account.first().unwrap(); + let account = cfg.account.get("example").unwrap(); assert_eq!(account.contacts.len(), 1); assert!(account.env.is_empty()); assert!(account.external_account.is_none()); assert!(account.hooks.is_empty()); assert_eq!(account.key_type, AccountKeyType::EcDsaP256); - assert_eq!(account.name, "example"); assert_eq!( account.signature_algorithm, Some(AccountSignatureAlgorithm::Hs384) @@ -162,13 +161,12 @@ mod tests { assert!(cfg.hook.is_empty()); assert!(cfg.group.is_empty()); assert_eq!(cfg.account.len(), 1); - let account = cfg.account.first().unwrap(); + let account = cfg.account.get("example").unwrap(); assert_eq!(account.contacts.len(), 1); assert!(account.env.is_empty()); assert!(account.external_account.is_none()); assert!(account.hooks.is_empty()); assert_eq!(account.key_type, AccountKeyType::EcDsaP256); - assert_eq!(account.name, "example"); assert!(account.signature_algorithm.is_none()); assert!(cfg.certificate.is_empty()); } diff --git a/src/config/account.rs b/src/config/account.rs index 269147d..96a3fbd 100644 --- a/src/config/account.rs +++ b/src/config/account.rs @@ -14,7 +14,6 @@ pub struct Account { pub(in crate::config) hooks: Vec, #[serde(default)] pub(in crate::config) key_type: AccountKeyType, - pub(in crate::config) name: String, #[serde(default)] pub(in crate::config) signature_algorithm: Option, } @@ -89,7 +88,6 @@ mod tests { #[test] fn account_minimal() { let cfg = r#" -name = "test" contacts = [ { mailto = "acme@example.org" } ] @@ -106,14 +104,12 @@ contacts = [ assert!(a.external_account.is_none()); assert!(a.hooks.is_empty()); assert_eq!(a.key_type, AccountKeyType::EcDsaP256); - assert_eq!(a.name, "test"); assert!(a.signature_algorithm.is_none()); } #[test] fn account_full() { let cfg = r#" -name = "test" contacts = [ { mailto = "acme@example.org" } ] @@ -142,37 +138,15 @@ signature_algorithm = "HS512" assert_eq!(a.external_account, Some(ea)); assert_eq!(a.hooks, vec!["hook name".to_string()]); assert_eq!(a.key_type, AccountKeyType::Rsa2048); - assert_eq!(a.name, "test"); assert_eq!( a.signature_algorithm, Some(AccountSignatureAlgorithm::Hs512) ); } - #[test] - fn account_missing_name() { - let cfg = r#" -contacts = [ - { mailto = "acme@example.org" } -] -"#; - let res = load_str::(cfg); - assert!(res.is_err()); - } - - #[test] - fn account_missing_contact() { - let cfg = r#"name = "test""#; - let res = load_str::(cfg); - assert!(res.is_err()); - } - #[test] fn account_empty_contact() { - let cfg = r#" -name = "test" -contacts = [] -"#; + let cfg = r#"contacts = []"#; let res = load_str::(cfg); assert!(res.is_err()); } diff --git a/tests/config/override/00_initial.toml b/tests/config/override/00_initial.toml index f6e130c..33eea64 100644 --- a/tests/config/override/00_initial.toml +++ b/tests/config/override/00_initial.toml @@ -9,8 +9,7 @@ tos_agreed = false [endpoint."test AC 2"] url = "https://acme-v02.ac2.example.org/directory" -[[account]] -name = "example" +[account."example"] contacts = [ { mailto = "acme@example.org" }, ] diff --git a/tests/config/simple/simple.toml b/tests/config/simple/simple.toml index 12a26ce..2e89999 100644 --- a/tests/config/simple/simple.toml +++ b/tests/config/simple/simple.toml @@ -2,8 +2,7 @@ accounts_directory = "/tmp/example/account/dir" certificates_directory = "/tmp/example/cert/dir/" -[[account]] -name = "example" +[account."example"] contacts = [ { mailto = "acme@example.org" }, ]