Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions crates/cli/src/commands/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,28 @@ mod tests {
assert_eq!(config.rules[0].allowed_methods, vec!["GET".to_string()]);
}

#[test]
fn test_parse_cors_configuration_xml_drops_blank_optional_headers() {
let config = parse_cors_configuration(
r#"
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>https://console.example.com</AllowedOrigin>
<AllowedMethod>get</AllowedMethod>
<AllowedHeader> </AllowedHeader>
<ExposeHeader></ExposeHeader>
</CORSRule>
</CORSConfiguration>
"#,
)
.expect("parse xml config with blank optional headers");

assert_eq!(config.rules.len(), 1);
assert_eq!(config.rules[0].allowed_headers, None);
assert_eq!(config.rules[0].expose_headers, None);
assert_eq!(config.rules[0].allowed_methods, vec!["GET".to_string()]);
}

#[test]
fn test_cors_input_source_prefers_positional_argument() {
let args = SetCorsArgs {
Expand Down
13 changes: 13 additions & 0 deletions crates/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,19 @@ mod tests {
}
}

#[test]
fn cli_accepts_top_level_cors_get_alias() {
let cli = Cli::try_parse_from(["rc", "cors", "get", "local/my-bucket"])
.expect("parse top-level cors get");

match cli.command {
Commands::Cors(cors::CorsCommands::List(arg)) => {
assert_eq!(arg.path, "local/my-bucket");
}
other => panic!("expected top-level cors get alias, got {:?}", other),
}
}

#[test]
fn cli_accepts_bucket_cors_get_alias() {
let cli = Cli::try_parse_from(["rc", "bucket", "cors", "get", "local/my-bucket"])
Expand Down