add rudimentary support for Config PutEvaluations with TestMode for now
This commit is contained in:
parent
4c2667648a
commit
28b4305759
4 changed files with 104 additions and 0 deletions
|
|
@ -1802,3 +1802,68 @@ def test_batch_get_aggregate_resource_config():
|
|||
len(result["UnprocessedResourceIdentifiers"]) == 1
|
||||
and result["UnprocessedResourceIdentifiers"][0]["SourceRegion"] == "eu-west-1"
|
||||
)
|
||||
|
||||
|
||||
@mock_config
|
||||
def test_put_evaluations():
|
||||
client = boto3.client("config", region_name="us-west-2")
|
||||
|
||||
# Try without Evaluations supplied:
|
||||
with assert_raises(ClientError) as ce:
|
||||
client.put_evaluations(Evaluations=[], ResultToken="test", TestMode=True)
|
||||
assert ce.exception.response["Error"]["Code"] == "InvalidParameterValueException"
|
||||
assert (
|
||||
"The Evaluations object in your request cannot be null"
|
||||
in ce.exception.response["Error"]["Message"]
|
||||
)
|
||||
|
||||
# Try without a ResultToken supplied:
|
||||
with assert_raises(ClientError) as ce:
|
||||
client.put_evaluations(
|
||||
Evaluations=[
|
||||
{
|
||||
"ComplianceResourceType": "AWS::ApiGateway::RestApi",
|
||||
"ComplianceResourceId": "test-api",
|
||||
"ComplianceType": "INSUFFICIENT_DATA",
|
||||
"OrderingTimestamp": datetime(2015, 1, 1),
|
||||
}
|
||||
],
|
||||
ResultToken="",
|
||||
TestMode=True,
|
||||
)
|
||||
assert ce.exception.response["Error"]["Code"] == "InvalidResultTokenException"
|
||||
|
||||
# Try without TestMode supplied:
|
||||
with assert_raises(NotImplementedError) as ce:
|
||||
client.put_evaluations(
|
||||
Evaluations=[
|
||||
{
|
||||
"ComplianceResourceType": "AWS::ApiGateway::RestApi",
|
||||
"ComplianceResourceId": "test-api",
|
||||
"ComplianceType": "INSUFFICIENT_DATA",
|
||||
"OrderingTimestamp": datetime(2015, 1, 1),
|
||||
}
|
||||
],
|
||||
ResultToken="test",
|
||||
)
|
||||
|
||||
# Now with proper params:
|
||||
response = client.put_evaluations(
|
||||
Evaluations=[
|
||||
{
|
||||
"ComplianceResourceType": "AWS::ApiGateway::RestApi",
|
||||
"ComplianceResourceId": "test-api",
|
||||
"ComplianceType": "INSUFFICIENT_DATA",
|
||||
"OrderingTimestamp": datetime(2015, 1, 1),
|
||||
}
|
||||
],
|
||||
TestMode=True,
|
||||
ResultToken="test",
|
||||
)
|
||||
|
||||
# this is hard to match against, so remove it
|
||||
response["ResponseMetadata"].pop("HTTPHeaders", None)
|
||||
response["ResponseMetadata"].pop("RetryAttempts", None)
|
||||
response.should.equal(
|
||||
{"FailedEvaluations": [], "ResponseMetadata": {"HTTPStatusCode": 200,},}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue