File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
lambda-events/src/event/iam Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ pub struct IamPolicyStatement {
2525 #[ serde( deserialize_with = "deserialize_string_or_slice" ) ]
2626 pub resource : Vec < String > ,
2727 #[ serde( default , deserialize_with = "deserialize_policy_condition" ) ]
28+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
2829 pub condition : Option < IamPolicyCondition > ,
2930}
3031
@@ -169,4 +170,24 @@ mod tests {
169170
170171 assert_eq ! ( vec![ "janedoe/*" ] , condition[ "StringLike" ] [ "s3:prefix" ] ) ;
171172 }
173+
174+ #[ test]
175+ fn test_serialize_none_condition ( ) {
176+ let policy = IamPolicyStatement {
177+ action : vec ! [ "some:action" . into( ) ] ,
178+ effect : IamPolicyEffect :: Allow ,
179+ resource : vec ! [ "some:resource" . into( ) ] ,
180+ condition : None ,
181+ } ;
182+ let policy_ser = serde_json:: to_value ( policy) . unwrap ( ) ;
183+
184+ assert_eq ! (
185+ policy_ser,
186+ serde_json:: json!( {
187+ "Action" : [ "some:action" ] ,
188+ "Effect" : "Allow" ,
189+ "Resource" : [ "some:resource" ]
190+ } )
191+ ) ;
192+ }
172193}
You can’t perform that action at this time.
0 commit comments