|
#[cfg(test)] |
|
mod tests { |
|
use super::*; |
|
|
|
#[test] |
|
fn order() { |
|
let _order: Order = serde_json::from_str( |
|
r#"{ |
|
"status": "valid", |
|
"expires": "2016-01-20T14:09:07.99Z", |
|
|
|
"identifiers": [ |
|
{ "type": "dns", "value": "www.example.org" }, |
|
{ "type": "dns", "value": "example.org" } |
|
], |
|
|
|
"notBefore": "2016-01-01T00:00:00Z", |
|
"notAfter": "2016-01-08T00:00:00Z", |
|
|
|
"authorizations": [ |
|
"https://example.com/acme/authz/PAniVnsZcis", |
|
"https://example.com/acme/authz/r4HqLzrSrpI" |
|
], |
|
|
|
"finalize": "https://example.com/acme/order/TOlocE8rfgo/finalize", |
|
|
|
"certificate": "https://example.com/acme/cert/mAt3xBGaobw" |
|
}"#, |
|
) |
|
.unwrap(); |
|
} |
|
|
|
#[test] |
|
fn authorization() { |
|
let auth: Authorization = serde_json::from_str( |
|
r#" |
|
{ |
|
"status": "pending", |
|
"identifier": { |
|
"type": "dns", |
|
"value": "www.example.org" |
|
}, |
|
"challenges": [ |
|
{ |
|
"type": "http-01", |
|
"url": "https://example.com/acme/chall/prV_B7yEyA4", |
|
"status": "pending", |
|
"token": "LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0" |
|
}, |
|
{ |
|
"type": "dns-01", |
|
"url": "https://example.com/acme/chall/Rg5dV14Gh1Q", |
|
"status": "pending", |
|
"token": "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA" |
|
}, |
|
{ |
|
"type": "tls-alpn-01", |
|
"url": "https://example.com/acme/chall/TJds3qqnMAf", |
|
"status": "pending", |
|
"token": "nRsTyUVQh1YAwovxwzAEVgtFLRV47f7HAcRfl6pED5Y=" |
|
} |
|
], |
|
|
|
"wildcard": false |
|
}"#, |
|
) |
|
.unwrap(); |
|
|
|
assert_eq!(auth.challenges.len(), 3); |
|
assert_eq!(auth.challenges[0].kind, ChallengeKind::Http01); |
|
assert_eq!(auth.challenges[1].kind, ChallengeKind::Dns01); |
|
assert_eq!(auth.challenges[2].kind, ChallengeKind::TlsAlpn01); |
|
} |
|
|
|
#[test] |
|
fn error_kind() { |
|
let err: Problem = serde_json::from_str( |
|
r#" |
|
{ |
|
"type": "urn:ietf:params:acme:error:badNonce", |
|
"detail": "The client sent an unacceptable anti-replay nonce" |
|
}"#, |
|
) |
|
.unwrap(); |
|
|
|
assert_eq!(err.kind, ErrorKind::BadNonce); |
|
|
|
let err: Problem = serde_json::from_str( |
|
r#" |
|
{ |
|
"type": "urn:ietf:params:acme:error:caa", |
|
"detail": "CAA records forbid the CA from issuing a certificate" |
|
}"#, |
|
) |
|
.unwrap(); |
|
|
|
assert_eq!(err.kind, ErrorKind::Caa); |
|
|
|
let err: Problem = serde_json::from_str( |
|
r#" |
|
{ |
|
"type": "unknown-error", |
|
"detail": "Some unknown error" |
|
}"#, |
|
) |
|
.unwrap(); |
|
|
|
assert_eq!(err.kind, ErrorKind::Other("unknown-error".to_string())); |
|
|
|
let err: Problem = serde_json::from_str( |
|
r#" |
|
{ |
|
"type": "urn:ietf:params:acme:error:malformed", |
|
"detail": "Some of the identifiers requested were rejected", |
|
"subproblems": [ |
|
{ |
|
"type": "urn:ietf:params:acme:error:malformed", |
|
"detail": "Invalid underscore in DNS name \"_example.org\"", |
|
"identifier": { |
|
"type": "dns", |
|
"value": "_example.org" |
|
} |
|
}, |
|
{ |
|
"type": "urn:ietf:params:acme:error:rejectedIdentifier", |
|
"detail": "This CA will not issue for \"example.net\"", |
|
"identifier": { |
|
"type": "dns", |
|
"value": "example.net" |
|
} |
|
} |
|
] |
|
}"#, |
|
) |
|
.unwrap(); |
|
|
|
assert_eq!(err.kind, ErrorKind::Malformed); |
|
assert_eq!(err.subproblems.len(), 2); |
|
assert_eq!( |
|
err.subproblems[0].identifier, |
|
Some(Identifier::Dns("_example.org".to_string())) |
|
) |
|
} |
|
} |
Feature Overview
At the moment the documentation in
README.mdonly references the pebble tests.However the
Makefilealso contains a section for runningunittestfor tests defined e.g. innginx-acme/src/acme/types.rs
Lines 384 to 527 in 1cb00ec
These tests should be Rust only, yet fail to run with either
make unittest, orcargo test:These tests seemingly are also not run during CI, nor are they part of the overall
make testormake full-test.It should be clarified if these tests are intended to be run and if so, what the correct procedure for it is.
Alternatives Considered
Additional Context
No response