mirror of
https://github.com/rustfs/rustfs.git
synced 2026-03-17 14:24:08 +00:00
fix: allow missing admin policy fields
This commit is contained in:
@@ -153,6 +153,7 @@ pub struct AddServiceAccountReq {
|
||||
#[serde(
|
||||
rename = "policy",
|
||||
skip_serializing_if = "Option::is_none",
|
||||
default,
|
||||
deserialize_with = "deserialize_optional_policy_value"
|
||||
)]
|
||||
pub policy: Option<Value>,
|
||||
@@ -287,6 +288,7 @@ pub struct UpdateServiceAccountReq {
|
||||
#[serde(
|
||||
rename = "newPolicy",
|
||||
skip_serializing_if = "Option::is_none",
|
||||
default,
|
||||
deserialize_with = "deserialize_optional_policy_value"
|
||||
)]
|
||||
pub new_policy: Option<Value>,
|
||||
@@ -901,6 +903,19 @@ mod tests {
|
||||
assert_eq!(req.policy, Some(serde_json::json!({"Version":"2012-10-17","Statement":[]})));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_service_account_req_allows_missing_policy_field() {
|
||||
let req: AddServiceAccountReq = serde_json::from_str(
|
||||
r#"{
|
||||
"accessKey":"AKIAIOSFODNN7EXAMPLE",
|
||||
"secretKey":"secret"
|
||||
}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(req.policy, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_service_account_req_validate_invalid_name() {
|
||||
let req = AddServiceAccountReq {
|
||||
@@ -1031,6 +1046,13 @@ mod tests {
|
||||
assert_eq!(req.new_policy, Some(serde_json::json!({"Version":"2012-10-17","Statement":[]})));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_update_service_account_req_allows_missing_policy_field() {
|
||||
let req: UpdateServiceAccountReq = serde_json::from_str(r#"{}"#).unwrap();
|
||||
|
||||
assert_eq!(req.new_policy, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_account_info_creation() {
|
||||
use crate::BackendInfo;
|
||||
|
||||
Reference in New Issue
Block a user