File tree 1 file changed +21
-0
lines changed
lambda-events/src/event/iam
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ pub struct IamPolicyStatement {
25
25
#[ serde( deserialize_with = "deserialize_string_or_slice" ) ]
26
26
pub resource : Vec < String > ,
27
27
#[ serde( default , deserialize_with = "deserialize_policy_condition" ) ]
28
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
28
29
pub condition : Option < IamPolicyCondition > ,
29
30
}
30
31
@@ -169,4 +170,24 @@ mod tests {
169
170
170
171
assert_eq ! ( vec![ "janedoe/*" ] , condition[ "StringLike" ] [ "s3:prefix" ] ) ;
171
172
}
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
+ }
172
193
}
You can’t perform that action at this time.
0 commit comments