Fix:Add list connection API's (#3976)

* Initial commit create connection

* Added connection API's

* Add destination API's

* fixed tests

* fix tests

* Fixed tests
This commit is contained in:
usmangani1 2021-06-07 15:05:28 +05:30 committed by GitHub
commit d325593e46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 253 additions and 1 deletions

View file

@ -2138,3 +2138,78 @@ def test_start_replay_send_to_log_group():
event_replay["resources"].should.be.empty
event_replay["detail"].should.equal({"key": "value"})
event_replay["replay-name"].should.equal("test-replay")
@mock_events
def test_create_and_list_connections():
client = boto3.client("events", "eu-central-1")
response = client.list_connections()
assert len(response.get("Connections")) == 0
response = client.create_connection(
Name="test",
Description="test description",
AuthorizationType="API_KEY",
AuthParameters={
"ApiKeyAuthParameters": {"ApiKeyName": "test", "ApiKeyValue": "test"}
},
)
assert response.get(
"ConnectionArn"
) == "arn:aws:events:eu-central-1:{0}:connection/test".format(ACCOUNT_ID)
response = client.list_connections()
assert response.get("Connections")[0].get(
"ConnectionArn"
) == "arn:aws:events:eu-central-1:{0}:connection/test".format(ACCOUNT_ID)
@mock_events
def test_create_and_list_api_destinations():
client = boto3.client("events", "eu-central-1")
response = client.create_connection(
Name="test",
Description="test description",
AuthorizationType="API_KEY",
AuthParameters={
"ApiKeyAuthParameters": {"ApiKeyName": "test", "ApiKeyValue": "test"}
},
)
destination_response = client.create_api_destination(
Name="test",
Description="test-description",
ConnectionArn=response.get("ConnectionArn"),
InvocationEndpoint="www.google.com",
HttpMethod="GET",
)
assert destination_response.get(
"ApiDestinationArn"
) == "arn:aws:events:eu-central-1:{0}:destination/test".format(ACCOUNT_ID)
assert destination_response.get("ApiDestinationState") == "ACTIVE"
destination_response = client.describe_api_destination(Name="test")
assert destination_response.get(
"ApiDestinationArn"
) == "arn:aws:events:eu-central-1:{0}:destination/test".format(ACCOUNT_ID)
assert destination_response.get("Name") == "test"
assert destination_response.get("ApiDestinationState") == "ACTIVE"
destination_response = client.list_api_destinations()
assert destination_response.get("ApiDestinations")[0].get(
"ApiDestinationArn"
) == "arn:aws:events:eu-central-1:{0}:destination/test".format(ACCOUNT_ID)
assert destination_response.get("ApiDestinations")[0].get("Name") == "test"
assert (
destination_response.get("ApiDestinations")[0].get("ApiDestinationState")
== "ACTIVE"
)