aws-cloudformation / aws-cloudformation/cloudformation-cli

Should contract_create_delete contract test ignore null input params?

Open
#739 5 comments 0 reactions 1 assignee Claimed by @anshikg View on GitHub
contract tests
Dominant language
Python
Stars
336
Forks
172
Avg merge
3d 5m
Merged PRs (30d)
3

Description

Hey, I'm trying to run the `handler_create.py::contract_create_delete` contract test, but it is failing because
>All properties specified in the request MUST be present in the model returned, and they MUST match exactly, with the exception of properties defined as writeOnlyProperties in the resource schema

Specifically, the test tries to create the resource with model:

{'Id': 'N', 'Authorization': None, 'Tags': [], 'EgressAccessLogs': {'LogGroupName': '/aws/MediaPackage/0'}}

Note the empty Tags list and null Authorization. The test gets back this as a response from our resource provider:

{'Id': 'N', 'EgressAccessLogs': {'LogGroupName': '/aws/MediaPackage/0'}}

### My question:
Should this test ignore null value inputs? Using the java rpdk, I'm not sure how to differentiate between null and nonexistant in responses.

How about empty lists? The API backing the resource provider returns Tags as an empty map/dict no matter whether the request was with an empty dict or null/nonexistant. Customers can craft CFN templates such that Tags is either an empty list or non existant/null. Is it valid to treat them the same (ie only return nonexistant or only return empty list), or do we need to handle both cases in our resource provider?

Code in question: https://github.com/aws-cloudformation/cloudformation-cli/blob/master/src/rpdk/core/contract/suite/handler_commons.py#L176

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.