aws-cloudformation / aws-cloudformation/cloudformation-cli
Defaults returned by resource fails response_contains_resource_model_equal_current_model
- Dominant language
- Python
- Stars
- 336
- Forks
- 172
- Avg merge
- 3d 5m
- Merged PRs (30d)
- 3
Description
Summary:
Sub-properties of properties are not always required. When you use one of the sub-properties the contract tests fails because it expects ALL of the sub-properties to be there.
The short version is that this should pass an "equals" assert
```
expected = { "top": { "inner1": "1" } }
actual = { "top": { "inner1": "1", "inner2": "2" } }
```
Details:
My Resource has a property `NetworkInterfaces` which is an array of objects with definition:
```
"NetworkInterface": {
"type": "object",
"additionalProperties": false,
"properties": {
"Description": {
"type": "string"
},
"PrivateIpAddress": {
"type": "string"
},
"PrivateIpAddresses": {
"type": "array",
"uniqueItems": false,
"items": {
"$ref": "#/definitions/PrivateIpAddressSpecification"
}
},
"SecondaryPrivateIpAddressCount": {
"type": "integer"
},
"DeviceIndex": {
"type": "string"
},
"GroupSet": {
"type": "array",
"uniqueItems": false,
"items": {
"type": "string"
}
},
"Ipv6Addresses": {
"type": "array",
"uniqueItems": false,
"items": {
"$ref": "#/definitions/InstanceIpv6Address"
}
},
"SubnetId": {
"type": "string"
},
"AssociatePublicIpAddress": {
"type": "boolean"
},
"NetworkInterfaceId": {
"type": "string"
},
"Ipv6AddressCount": {
"type": "integer"
},
"DeleteOnTermination": {
"type": "boolean"
}
},
"required": [
"DeviceIndex"
]
}
```
Note that only DeviceIndex is required.
The ReadHandler will construct this object and fill in the fields. I use the ReadHandler at the end of my CreateHandler.
When I have an input that only specifies some of these fields, such as
```
{ ...
"NetworkInteraces" :[
{
"DeviceIndex": 0,
"DeleteOnTermination": false
}
]
...
}
```
Then the test fails, saying that my input does not match the output.
Although it is true that the desiredResource and does not match the output from the Handle, SubnetID is not a required property. It should not matter that SubnetId is not in the desiredResource.
Contributor guide
Assessment
This issue has not been assessed yet.