File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -519,3 +519,25 @@ fn extract_account_uri(credentials_json: &str) -> Option<String> {
519519 . filter ( |c| !c. account_id . is_empty ( ) )
520520 . map ( |c| c. account_id )
521521}
522+
523+ #[ cfg( test) ]
524+ mod credential_tests {
525+ use super :: acme_url_matches;
526+
527+ #[ test]
528+ fn corrupt_acme_credentials_fail_closed ( ) {
529+ assert ! ( acme_url_matches( "not-json" , "https://acme.test/directory" ) . is_err( ) ) ;
530+ assert ! ( acme_url_matches( "{}" , "https://acme.test/directory" ) . is_err( ) ) ;
531+ }
532+
533+ #[ test]
534+ fn valid_acme_credentials_distinguish_directory ( ) {
535+ let credentials = r#"{"acme_url":"https://acme.test/directory"}"# ;
536+ assert ! ( acme_url_matches( credentials, "https://acme.test/directory" )
537+ . expect( "valid credentials rejected" ) ) ;
538+ assert ! (
539+ !acme_url_matches( credentials, "https://other.test/directory" )
540+ . expect( "valid credentials rejected" )
541+ ) ;
542+ }
543+ }
You can’t perform that action at this time.
0 commit comments