diff --git a/localstack-core/localstack/testing/snapshots/transformer_utility.py b/localstack-core/localstack/testing/snapshots/transformer_utility.py index 95bfc0b21cbc2..de8f96e8cd13f 100644 --- a/localstack-core/localstack/testing/snapshots/transformer_utility.py +++ b/localstack-core/localstack/testing/snapshots/transformer_utility.py @@ -744,36 +744,6 @@ def stepfunctions_api(): # def custom(fn: Callable[[dict], dict]) -> Transformer: # return GenericTransformer(fn) - @staticmethod - def eventbridge_api_destination(snapshot, connection_name: str): - """ - Add common transformers for EventBridge connection tests. - - Args: - snapshot: The snapshot instance to add transformers to - connection_name: The name of the connection to transform in the snapshot - """ - snapshot.add_transformer(snapshot.transform.regex(connection_name, "")) - snapshot.add_transformer( - snapshot.transform.key_value("ApiDestinationArn", reference_replacement=False) - ) - snapshot.add_transformer( - snapshot.transform.key_value("ConnectionArn", reference_replacement=False) - ) - return snapshot - - @staticmethod - def eventbridge_connection(snapshot, connection_name: str): - """ - Add common transformers for EventBridge connection tests. - Args: - snapshot: The snapshot instance to add transformers to - connection_name: The name of the connection to transform in the snapshot - """ - snapshot.add_transformer(snapshot.transform.regex(connection_name, "")) - snapshot.add_transformer(TransformerUtility.resource_name()) - return snapshot - def _sns_pem_file_token_transformer(key: str, val: str) -> str: if isinstance(val, str) and key.lower() == "SigningCertURL".lower(): diff --git a/tests/aws/services/events/conftest.py b/tests/aws/services/events/conftest.py index f098f925601bf..77b9d925e033c 100644 --- a/tests/aws/services/events/conftest.py +++ b/tests/aws/services/events/conftest.py @@ -4,6 +4,7 @@ import pytest +from localstack.testing.snapshots.transformer_utility import TransformerUtility from localstack.utils.aws.arns import get_partition from localstack.utils.strings import short_uid from localstack.utils.sync import retry @@ -445,3 +446,31 @@ def _create_api_destination(**kwargs): ) return _create_api_destination + + +############################# +# Common Transformer Fixtures +############################# + + +@pytest.fixture +def api_destination_snapshot(snapshot, destination_name): + snapshot.add_transformers_list( + [ + snapshot.transform.regex(destination_name, ""), + snapshot.transform.key_value("ApiDestinationArn", reference_replacement=False), + snapshot.transform.key_value("ConnectionArn", reference_replacement=False), + ] + ) + return snapshot + + +@pytest.fixture +def connection_snapshot(snapshot, connection_name): + snapshot.add_transformers_list( + [ + snapshot.transform.regex(connection_name, ""), + TransformerUtility.resource_name(), + ] + ) + return snapshot diff --git a/tests/aws/services/events/test_api_destinations_and_connection.py b/tests/aws/services/events/test_api_destinations_and_connection.py new file mode 100644 index 0000000000000..00e0aec57536c --- /dev/null +++ b/tests/aws/services/events/test_api_destinations_and_connection.py @@ -0,0 +1,384 @@ +import pytest +from botocore.exceptions import ClientError + +from localstack.testing.pytest import markers +from localstack.utils.sync import poll_condition +from tests.aws.services.events.helper_functions import is_old_provider + +API_DESTINATION_AUTHS = [ + { + "type": "BASIC", + "key": "BasicAuthParameters", + "parameters": {"Username": "user", "Password": "pass"}, + }, + { + "type": "API_KEY", + "key": "ApiKeyAuthParameters", + "parameters": {"ApiKeyName": "Api", "ApiKeyValue": "apikey_secret"}, + }, + { + "type": "OAUTH_CLIENT_CREDENTIALS", + "key": "OAuthParameters", + "parameters": { + "AuthorizationEndpoint": "replace_this", + "ClientParameters": {"ClientID": "id", "ClientSecret": "password"}, + "HttpMethod": "put", + "OAuthHttpParameters": { + "BodyParameters": [{"Key": "oauthbody", "Value": "value1"}], + "HeaderParameters": [{"Key": "oauthheader", "Value": "value2"}], + "QueryStringParameters": [{"Key": "oauthquery", "Value": "value3"}], + }, + }, + }, +] + +API_DESTINATION_AUTH_PARAMS = [ + { + "AuthorizationType": "BASIC", + "AuthParameters": { + "BasicAuthParameters": {"Username": "user", "Password": "pass"}, + }, + }, + { + "AuthorizationType": "API_KEY", + "AuthParameters": { + "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, + }, + }, + { + "AuthorizationType": "OAUTH_CLIENT_CREDENTIALS", + "AuthParameters": { + "OAuthParameters": { + "AuthorizationEndpoint": "https://example.com/oauth", + "ClientParameters": {"ClientID": "client_id", "ClientSecret": "client_secret"}, + "HttpMethod": "POST", + } + }, + }, +] + + +class TestEventBridgeApiDestinations: + @markers.aws.validated + @pytest.mark.parametrize("auth", API_DESTINATION_AUTHS) + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_api_destinations( + self, + aws_client, + create_connection, + create_api_destination, + destination_name, + auth, + api_destination_snapshot, + ): + connection_response = create_connection(auth) + connection_arn = connection_response["ConnectionArn"] + + response = create_api_destination( + ConnectionArn=connection_arn, + HttpMethod="POST", + InvocationEndpoint="https://example.com/api", + Description="Test API destination", + ) + api_destination_snapshot.match("create-api-destination", response) + + describe_response = aws_client.events.describe_api_destination(Name=destination_name) + api_destination_snapshot.match("describe-api-destination", describe_response) + + list_response = aws_client.events.list_api_destinations(NamePrefix=destination_name) + api_destination_snapshot.match("list-api-destinations", list_response) + + update_response = aws_client.events.update_api_destination( + Name=destination_name, + ConnectionArn=connection_arn, + HttpMethod="PUT", + InvocationEndpoint="https://example.com/api/v2", + Description="Updated API destination", + ) + api_destination_snapshot.match("update-api-destination", update_response) + + describe_updated_response = aws_client.events.describe_api_destination( + Name=destination_name + ) + api_destination_snapshot.match( + "describe-updated-api-destination", describe_updated_response + ) + + delete_response = aws_client.events.delete_api_destination(Name=destination_name) + api_destination_snapshot.match("delete-api-destination", delete_response) + + with pytest.raises(aws_client.events.exceptions.ResourceNotFoundException) as exc_info: + aws_client.events.describe_api_destination(Name=destination_name) + api_destination_snapshot.match( + "describe-api-destination-not-found-error", exc_info.value.response + ) + + @markers.aws.validated + @pytest.mark.skipif(is_old_provider(), reason="V1 provider does not support this feature") + def test_create_api_destination_invalid_parameters( + self, aws_client, api_destination_snapshot, destination_name + ): + with pytest.raises(ClientError) as e: + aws_client.events.create_api_destination( + Name=destination_name, + ConnectionArn="invalid-connection-arn", + HttpMethod="INVALID_METHOD", + InvocationEndpoint="invalid-endpoint", + ) + api_destination_snapshot.match( + "create-api-destination-invalid-parameters-error", e.value.response + ) + + @markers.aws.validated + @pytest.mark.skipif(is_old_provider(), reason="V1 provider does not support this feature") + def test_create_api_destination_name_validation( + self, aws_client, api_destination_snapshot, create_connection + ): + invalid_name = "Invalid Name With Spaces!" + + connection_response = create_connection(API_DESTINATION_AUTHS[0]) + connection_arn = connection_response["ConnectionArn"] + + with pytest.raises(ClientError) as e: + aws_client.events.create_api_destination( + Name=invalid_name, + ConnectionArn=connection_arn, + HttpMethod="POST", + InvocationEndpoint="https://example.com/api", + ) + api_destination_snapshot.match( + "create-api-destination-invalid-name-error", e.value.response + ) + + +class TestEventBridgeConnections: + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_create_connection( + self, aws_client, connection_snapshot, create_connection, connection_name + ): + response = create_connection( + "API_KEY", + { + "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, + "InvocationHttpParameters": {}, + }, + ) + connection_snapshot.match("create-connection", response) + + describe_response = aws_client.events.describe_connection(Name=connection_name) + connection_snapshot.match("describe-connection", describe_response) + + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + @pytest.mark.parametrize("auth_params", API_DESTINATION_AUTH_PARAMS) + def test_create_connection_with_auth( + self, aws_client, connection_snapshot, create_connection, auth_params, connection_name + ): + response = create_connection( + auth_params["AuthorizationType"], + auth_params["AuthParameters"], + ) + connection_snapshot.match("create-connection-auth", response) + + describe_response = aws_client.events.describe_connection(Name=connection_name) + connection_snapshot.match("describe-connection-auth", describe_response) + + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_list_connections( + self, aws_client, connection_snapshot, create_connection, connection_name + ): + create_connection( + "BASIC", + { + "BasicAuthParameters": {"Username": "user", "Password": "pass"}, + "InvocationHttpParameters": {}, + }, + ) + + response = aws_client.events.list_connections(NamePrefix=connection_name) + connection_snapshot.match("list-connections", response) + + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_delete_connection( + self, aws_client, connection_snapshot, create_connection, connection_name + ): + response = create_connection( + "API_KEY", + { + "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, + "InvocationHttpParameters": {}, + }, + ) + connection_snapshot.match("create-connection-response", response) + + secret_arn = aws_client.events.describe_connection(Name=connection_name)["SecretArn"] + # check if secret exists + aws_client.secretsmanager.describe_secret(SecretId=secret_arn) + + delete_response = aws_client.events.delete_connection(Name=connection_name) + connection_snapshot.match("delete-connection", delete_response) + + # wait until connection is deleted + def is_connection_deleted(): + try: + aws_client.events.describe_connection(Name=connection_name) + return False + except Exception: + return True + + poll_condition(is_connection_deleted) + + with pytest.raises(aws_client.events.exceptions.ResourceNotFoundException) as exc: + aws_client.events.describe_connection(Name=connection_name) + connection_snapshot.match("describe-deleted-connection", exc.value.response) + + def is_secret_deleted(): + try: + aws_client.secretsmanager.describe_secret(SecretId=secret_arn) + return False + except Exception: + return True + + poll_condition(is_secret_deleted) + + with pytest.raises(aws_client.secretsmanager.exceptions.ResourceNotFoundException): + aws_client.secretsmanager.describe_secret(SecretId=secret_arn) + + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_create_connection_invalid_parameters( + self, aws_client, connection_snapshot, connection_name + ): + with pytest.raises(ClientError) as e: + aws_client.events.create_connection( + Name=connection_name, + AuthorizationType="INVALID_AUTH_TYPE", + AuthParameters={}, + ) + connection_snapshot.match("create-connection-invalid-auth-error", e.value.response) + + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_update_connection( + self, aws_client, snapshot, connection_snapshot, create_connection, connection_name + ): + create_response = create_connection( + "BASIC", + { + "BasicAuthParameters": {"Username": "user", "Password": "pass"}, + "InvocationHttpParameters": {}, + }, + ) + connection_snapshot.match("create-connection", create_response) + + describe_response = aws_client.events.describe_connection(Name=connection_name) + connection_snapshot.match("describe-created-connection", describe_response) + + # add secret id transformer + secret_id = describe_response["SecretArn"] + secret_uuid, _, secret_suffix = secret_id.rpartition("/")[2].rpartition("-") + connection_snapshot.add_transformer( + snapshot.transform.regex(secret_uuid, ""), priority=-1 + ) + connection_snapshot.add_transformer( + snapshot.transform.regex(secret_suffix, ""), priority=-1 + ) + + get_secret_response = aws_client.secretsmanager.get_secret_value(SecretId=secret_id) + connection_snapshot.match("connection-secret-before-update", get_secret_response) + + update_response = aws_client.events.update_connection( + Name=connection_name, + AuthorizationType="BASIC", + AuthParameters={ + "BasicAuthParameters": {"Username": "new_user", "Password": "new_pass"}, + "InvocationHttpParameters": {}, + }, + ) + connection_snapshot.match("update-connection", update_response) + + describe_response = aws_client.events.describe_connection(Name=connection_name) + connection_snapshot.match("describe-updated-connection", describe_response) + + get_secret_response = aws_client.secretsmanager.get_secret_value(SecretId=secret_id) + connection_snapshot.match("connection-secret-after-update", get_secret_response) + + @markers.aws.validated + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_create_connection_name_validation(self, aws_client, connection_snapshot): + invalid_name = "Invalid Name With Spaces!" + + with pytest.raises(ClientError) as e: + aws_client.events.create_connection( + Name=invalid_name, + AuthorizationType="API_KEY", + AuthParameters={ + "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, + "InvocationHttpParameters": {}, + }, + ) + connection_snapshot.match("create-connection-invalid-name-error", e.value.response) + + @markers.aws.validated + @pytest.mark.parametrize( + "auth_params", API_DESTINATION_AUTH_PARAMS, ids=["basic", "api-key", "oauth"] + ) + @pytest.mark.skipif( + is_old_provider(), + reason="V1 provider does not support this feature", + ) + def test_connection_secrets( + self, + aws_client, + snapshot, + connection_snapshot, + create_connection, + connection_name, + auth_params, + ): + response = create_connection( + auth_params["AuthorizationType"], + auth_params["AuthParameters"], + ) + connection_snapshot.match("create-connection-auth", response) + + describe_response = aws_client.events.describe_connection(Name=connection_name) + connection_snapshot.match("describe-connection-auth", describe_response) + + secret_id = describe_response["SecretArn"] + secret_uuid, _, secret_suffix = secret_id.rpartition("/")[2].rpartition("-") + connection_snapshot.add_transformer( + snapshot.transform.regex(secret_uuid, ""), priority=-1 + ) + connection_snapshot.add_transformer( + snapshot.transform.regex(secret_suffix, ""), priority=-1 + ) + get_secret_response = aws_client.secretsmanager.get_secret_value(SecretId=secret_id) + connection_snapshot.match("connection-secret", get_secret_response) diff --git a/tests/aws/services/events/test_api_destinations_and_connection.snapshot.json b/tests/aws/services/events/test_api_destinations_and_connection.snapshot.json new file mode 100644 index 0000000000000..3a1216c94be8f --- /dev/null +++ b/tests/aws/services/events/test_api_destinations_and_connection.snapshot.json @@ -0,0 +1,798 @@ +{ + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection": { + "recorded-date": "09-12-2024, 10:16:11", + "recorded-content": { + "create-connection": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-connection": { + "AuthParameters": { + "ApiKeyAuthParameters": { + "ApiKeyName": "ApiKey" + }, + "InvocationHttpParameters": {} + }, + "AuthorizationType": "API_KEY", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params0]": { + "recorded-date": "09-12-2024, 10:16:12", + "recorded-content": { + "create-connection-auth": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-connection-auth": { + "AuthParameters": { + "BasicAuthParameters": { + "Username": "user" + } + }, + "AuthorizationType": "BASIC", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params1]": { + "recorded-date": "09-12-2024, 10:16:13", + "recorded-content": { + "create-connection-auth": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-connection-auth": { + "AuthParameters": { + "ApiKeyAuthParameters": { + "ApiKeyName": "ApiKey" + } + }, + "AuthorizationType": "API_KEY", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params2]": { + "recorded-date": "09-12-2024, 10:16:13", + "recorded-content": { + "create-connection-auth": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZING", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-connection-auth": { + "AuthParameters": { + "OAuthParameters": { + "AuthorizationEndpoint": "https://example.com/oauth", + "ClientParameters": { + "ClientID": "client_id" + }, + "HttpMethod": "POST" + } + }, + "AuthorizationType": "OAUTH_CLIENT_CREDENTIALS", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZING", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_list_connections": { + "recorded-date": "09-12-2024, 10:16:14", + "recorded-content": { + "list-connections": { + "Connections": [ + { + "AuthorizationType": "BASIC", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "" + } + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_delete_connection": { + "recorded-date": "09-12-2024, 10:16:19", + "recorded-content": { + "create-connection-response": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "delete-connection": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "DELETING", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-deleted-connection": { + "Error": { + "Code": "ResourceNotFoundException", + "Message": "Failed to describe the connection(s). Connection '' does not exist." + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_invalid_parameters": { + "recorded-date": "09-12-2024, 10:16:20", + "recorded-content": { + "create-connection-invalid-auth-error": { + "Error": { + "Code": "ValidationException", + "Message": "1 validation error detected: Value 'INVALID_AUTH_TYPE' at 'authorizationType' failed to satisfy constraint: Member must satisfy enum value set: [BASIC, OAUTH_CLIENT_CREDENTIALS, API_KEY]" + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_update_connection": { + "recorded-date": "09-12-2024, 10:16:22", + "recorded-content": { + "create-connection": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-created-connection": { + "AuthParameters": { + "BasicAuthParameters": { + "Username": "user" + }, + "InvocationHttpParameters": {} + }, + "AuthorizationType": "BASIC", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "connection-secret-before-update": { + "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", + "CreatedDate": "datetime", + "Name": "events!connection//", + "SecretString": { + "username": "user", + "password": "pass", + "invocation_http_parameters": {} + }, + "VersionId": "", + "VersionStages": [ + "AWSCURRENT" + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "update-connection": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-updated-connection": { + "AuthParameters": { + "BasicAuthParameters": { + "Username": "new_user" + }, + "InvocationHttpParameters": {} + }, + "AuthorizationType": "BASIC", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "connection-secret-after-update": { + "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", + "CreatedDate": "datetime", + "Name": "events!connection//", + "SecretString": { + "username": "new_user", + "password": "new_pass", + "invocation_http_parameters": {} + }, + "VersionId": "", + "VersionStages": [ + "AWSCURRENT" + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_name_validation": { + "recorded-date": "09-12-2024, 10:16:22", + "recorded-content": { + "create-connection-invalid-name-error": { + "Error": { + "Code": "ValidationException", + "Message": "1 validation error detected: Value 'Invalid Name With Spaces!' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\.\\-_A-Za-z0-9]+" + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_connection_secrets[basic]": { + "recorded-date": "09-12-2024, 10:16:24", + "recorded-content": { + "create-connection-auth": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-connection-auth": { + "AuthParameters": { + "BasicAuthParameters": { + "Username": "user" + } + }, + "AuthorizationType": "BASIC", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "connection-secret": { + "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", + "CreatedDate": "datetime", + "Name": "events!connection//", + "SecretString": { + "username": "user", + "password": "pass" + }, + "VersionId": "", + "VersionStages": [ + "AWSCURRENT" + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_connection_secrets[api-key]": { + "recorded-date": "09-12-2024, 10:16:25", + "recorded-content": { + "create-connection-auth": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-connection-auth": { + "AuthParameters": { + "ApiKeyAuthParameters": { + "ApiKeyName": "ApiKey" + } + }, + "AuthorizationType": "API_KEY", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZED", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "connection-secret": { + "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", + "CreatedDate": "datetime", + "Name": "events!connection//", + "SecretString": { + "api_key_name": "ApiKey", + "api_key_value": "secret" + }, + "VersionId": "", + "VersionStages": [ + "AWSCURRENT" + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_connection_secrets[oauth]": { + "recorded-date": "09-12-2024, 10:16:25", + "recorded-content": { + "create-connection-auth": { + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZING", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-connection-auth": { + "AuthParameters": { + "OAuthParameters": { + "AuthorizationEndpoint": "https://example.com/oauth", + "ClientParameters": { + "ClientID": "client_id" + }, + "HttpMethod": "POST" + } + }, + "AuthorizationType": "OAUTH_CLIENT_CREDENTIALS", + "ConnectionArn": "arn::events::111111111111:connection//", + "ConnectionState": "AUTHORIZING", + "CreationTime": "datetime", + "LastAuthorizedTime": "datetime", + "LastModifiedTime": "datetime", + "Name": "", + "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "connection-secret": { + "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", + "CreatedDate": "datetime", + "Name": "events!connection//", + "SecretString": { + "client_id": "client_id", + "client_secret": "client_secret", + "authorization_endpoint": "https://example.com/oauth", + "http_method": "POST" + }, + "VersionId": "", + "VersionStages": [ + "AWSCURRENT" + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_api_destinations[auth0]": { + "recorded-date": "09-12-2024, 10:21:06", + "recorded-content": { + "create-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "Description": "Test API destination", + "HttpMethod": "POST", + "InvocationEndpoint": "https://example.com/api", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "list-api-destinations": { + "ApiDestinations": [ + { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "HttpMethod": "POST", + "InvocationEndpoint": "https://example.com/api", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "" + } + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "update-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-updated-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "Description": "Updated API destination", + "HttpMethod": "PUT", + "InvocationEndpoint": "https://example.com/api/v2", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "delete-api-destination": { + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-api-destination-not-found-error": { + "Error": { + "Code": "ResourceNotFoundException", + "Message": "Failed to describe the api-destination(s). An api-destination '' does not exist." + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_api_destinations[auth1]": { + "recorded-date": "09-12-2024, 10:21:08", + "recorded-content": { + "create-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "Description": "Test API destination", + "HttpMethod": "POST", + "InvocationEndpoint": "https://example.com/api", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "list-api-destinations": { + "ApiDestinations": [ + { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "HttpMethod": "POST", + "InvocationEndpoint": "https://example.com/api", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "" + } + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "update-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-updated-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "ACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "Description": "Updated API destination", + "HttpMethod": "PUT", + "InvocationEndpoint": "https://example.com/api/v2", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "delete-api-destination": { + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-api-destination-not-found-error": { + "Error": { + "Code": "ResourceNotFoundException", + "Message": "Failed to describe the api-destination(s). An api-destination '' does not exist." + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_api_destinations[auth2]": { + "recorded-date": "09-12-2024, 10:21:10", + "recorded-content": { + "create-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "INACTIVE", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "INACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "Description": "Test API destination", + "HttpMethod": "POST", + "InvocationEndpoint": "https://example.com/api", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "list-api-destinations": { + "ApiDestinations": [ + { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "INACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "HttpMethod": "POST", + "InvocationEndpoint": "https://example.com/api", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "" + } + ], + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "update-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "INACTIVE", + "CreationTime": "datetime", + "LastModifiedTime": "datetime", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-updated-api-destination": { + "ApiDestinationArn": "api-destination-arn", + "ApiDestinationState": "INACTIVE", + "ConnectionArn": "connection-arn", + "CreationTime": "datetime", + "Description": "Updated API destination", + "HttpMethod": "PUT", + "InvocationEndpoint": "https://example.com/api/v2", + "InvocationRateLimitPerSecond": 300, + "LastModifiedTime": "datetime", + "Name": "", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "delete-api-destination": { + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "describe-api-destination-not-found-error": { + "Error": { + "Code": "ResourceNotFoundException", + "Message": "Failed to describe the api-destination(s). An api-destination '' does not exist." + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_create_api_destination_invalid_parameters": { + "recorded-date": "09-12-2024, 10:21:11", + "recorded-content": { + "create-api-destination-invalid-parameters-error": { + "Error": { + "Code": "ValidationException", + "Message": "2 validation errors detected: Value 'invalid-connection-arn' at 'connectionArn' failed to satisfy constraint: Member must satisfy regular expression pattern: ^arn:aws([a-z]|\\-)*:events:([a-z]|\\d|\\-)*:([0-9]{12})?:connection\\/[\\.\\-_A-Za-z0-9]+\\/[\\-A-Za-z0-9]+$; Value 'INVALID_METHOD' at 'httpMethod' failed to satisfy constraint: Member must satisfy enum value set: [HEAD, POST, PATCH, DELETE, PUT, GET, OPTIONS]" + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_create_api_destination_name_validation": { + "recorded-date": "09-12-2024, 10:21:12", + "recorded-content": { + "create-api-destination-invalid-name-error": { + "Error": { + "Code": "ValidationException", + "Message": "1 validation error detected: Value 'Invalid Name With Spaces!' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\.\\-_A-Za-z0-9]+" + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + } +} diff --git a/tests/aws/services/events/test_api_destinations_and_connection.validation.json b/tests/aws/services/events/test_api_destinations_and_connection.validation.json new file mode 100644 index 0000000000000..580cdf7853b68 --- /dev/null +++ b/tests/aws/services/events/test_api_destinations_and_connection.validation.json @@ -0,0 +1,53 @@ +{ + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_api_destinations[auth0]": { + "last_validated_date": "2024-12-09T10:21:06+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_api_destinations[auth1]": { + "last_validated_date": "2024-12-09T10:21:08+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_api_destinations[auth2]": { + "last_validated_date": "2024-12-09T10:21:10+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_create_api_destination_invalid_parameters": { + "last_validated_date": "2024-12-09T10:21:11+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeApiDestinations::test_create_api_destination_name_validation": { + "last_validated_date": "2024-12-09T10:21:12+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_connection_secrets[api-key]": { + "last_validated_date": "2024-12-09T10:16:25+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_connection_secrets[basic]": { + "last_validated_date": "2024-12-09T10:16:24+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_connection_secrets[oauth]": { + "last_validated_date": "2024-12-09T10:16:25+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection": { + "last_validated_date": "2024-12-09T10:16:11+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_invalid_parameters": { + "last_validated_date": "2024-12-09T10:16:20+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_name_validation": { + "last_validated_date": "2024-12-09T10:16:22+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params0]": { + "last_validated_date": "2024-12-09T10:16:12+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params1]": { + "last_validated_date": "2024-12-09T10:16:12+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params2]": { + "last_validated_date": "2024-12-09T10:16:13+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_delete_connection": { + "last_validated_date": "2024-12-09T10:16:19+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_list_connections": { + "last_validated_date": "2024-12-09T10:16:14+00:00" + }, + "tests/aws/services/events/test_api_destinations_and_connection.py::TestEventBridgeConnections::test_update_connection": { + "last_validated_date": "2024-12-09T10:16:22+00:00" + } +} diff --git a/tests/aws/services/events/test_events.py b/tests/aws/services/events/test_events.py index ffb3add447e3f..4264bdad28de8 100644 --- a/tests/aws/services/events/test_events.py +++ b/tests/aws/services/events/test_events.py @@ -2,7 +2,6 @@ Test creating and modifying event buses, as well as putting events to custom and the default bus. """ -import base64 import datetime import json import os @@ -13,18 +12,15 @@ import pytest from botocore.exceptions import ClientError from localstack_snapshot.snapshots.transformer import SortingTransformer -from pytest_httpserver import HTTPServer -from werkzeug import Request, Response from localstack import config from localstack.services.events.v1.provider import _get_events_tmp_dir from localstack.testing.aws.eventbus_utils import allow_event_rule_to_sqs_queue from localstack.testing.aws.util import is_aws_cloud from localstack.testing.pytest import markers -from localstack.testing.snapshots.transformer_utility import TransformerUtility from localstack.utils.files import load_file -from localstack.utils.strings import long_uid, short_uid, to_str -from localstack.utils.sync import poll_condition, retry +from localstack.utils.strings import long_uid, short_uid +from localstack.utils.sync import retry from tests.aws.services.events.helper_functions import ( assert_valid_event, is_old_provider, @@ -50,32 +46,6 @@ "detail": {"command": ["update-account"]}, } -API_DESTINATION_AUTHS = [ - { - "type": "BASIC", - "key": "BasicAuthParameters", - "parameters": {"Username": "user", "Password": "pass"}, - }, - { - "type": "API_KEY", - "key": "ApiKeyAuthParameters", - "parameters": {"ApiKeyName": "Api", "ApiKeyValue": "apikey_secret"}, - }, - { - "type": "OAUTH_CLIENT_CREDENTIALS", - "key": "OAuthParameters", - "parameters": { - "AuthorizationEndpoint": "replace_this", - "ClientParameters": {"ClientID": "id", "ClientSecret": "password"}, - "HttpMethod": "put", - "OAuthHttpParameters": { - "BodyParameters": [{"Key": "oauthbody", "Value": "value1"}], - "HeaderParameters": [{"Key": "oauthheader", "Value": "value2"}], - "QueryStringParameters": [{"Key": "oauthquery", "Value": "value3"}], - }, - }, - }, -] EVENT_BUS_ROLE = { "Statement": { @@ -283,165 +253,6 @@ def test_events_written_to_disk_are_timestamp_prefixed_for_chronological_orderin assert [json.loads(event["Detail"]) for event in sorted_events] == event_details_to_publish - @markers.aws.only_localstack - @pytest.mark.parametrize("auth", API_DESTINATION_AUTHS) - def test_api_destinations(self, httpserver: HTTPServer, auth, aws_client, clean_up): - token = short_uid() - bearer = f"Bearer {token}" - - def _handler(_request: Request): - return Response( - json.dumps( - { - "access_token": token, - "token_type": "Bearer", - "expires_in": 86400, - } - ), - mimetype="application/json", - ) - - httpserver.expect_request("").respond_with_handler(_handler) - http_endpoint = httpserver.url_for("/") - - if auth.get("type") == "OAUTH_CLIENT_CREDENTIALS": - auth["parameters"]["AuthorizationEndpoint"] = http_endpoint - - connection_name = f"c-{short_uid()}" - connection_arn = aws_client.events.create_connection( - Name=connection_name, - AuthorizationType=auth.get("type"), - AuthParameters={ - auth.get("key"): auth.get("parameters"), - "InvocationHttpParameters": { - "BodyParameters": [ - { - "Key": "connection_body_param", - "Value": "value", - "IsValueSecret": False, - }, - ], - "HeaderParameters": [ - { - "Key": "connection-header-param", - "Value": "value", - "IsValueSecret": False, - }, - { - "Key": "overwritten-header", - "Value": "original", - "IsValueSecret": False, - }, - ], - "QueryStringParameters": [ - { - "Key": "connection_query_param", - "Value": "value", - "IsValueSecret": False, - }, - { - "Key": "overwritten_query", - "Value": "original", - "IsValueSecret": False, - }, - ], - }, - }, - )["ConnectionArn"] - - # create api destination - dest_name = f"d-{short_uid()}" - result = aws_client.events.create_api_destination( - Name=dest_name, - ConnectionArn=connection_arn, - InvocationEndpoint=http_endpoint, - HttpMethod="POST", - ) - - # create rule and target - rule_name = f"r-{short_uid()}" - target_id = f"target-{short_uid()}" - pattern = json.dumps({"source": ["source-123"], "detail-type": ["type-123"]}) - aws_client.events.put_rule(Name=rule_name, EventPattern=pattern) - aws_client.events.put_targets( - Rule=rule_name, - Targets=[ - { - "Id": target_id, - "Arn": result["ApiDestinationArn"], - "Input": '{"target_value":"value"}', - "HttpParameters": { - "PathParameterValues": ["target_path"], - "HeaderParameters": { - "target-header": "target_header_value", - "overwritten_header": "changed", - }, - "QueryStringParameters": { - "target_query": "t_query", - "overwritten_query": "changed", - }, - }, - } - ], - ) - - entries = [ - { - "Source": "source-123", - "DetailType": "type-123", - "Detail": '{"i": 0}', - } - ] - aws_client.events.put_events(Entries=entries) - - # clean up - aws_client.events.delete_connection(Name=connection_name) - aws_client.events.delete_api_destination(Name=dest_name) - clean_up(rule_name=rule_name, target_ids=target_id) - - to_recv = 2 if auth["type"] == "OAUTH_CLIENT_CREDENTIALS" else 1 - poll_condition(lambda: len(httpserver.log) >= to_recv, timeout=5) - - event_request, _ = httpserver.log[-1] - event = event_request.get_json(force=True) - headers = event_request.headers - query_args = event_request.args - - # Connection data validation - assert event["connection_body_param"] == "value" - assert headers["Connection-Header-Param"] == "value" - assert query_args["connection_query_param"] == "value" - - # Target parameters validation - assert "/target_path" in event_request.path - assert event["target_value"] == "value" - assert headers["Target-Header"] == "target_header_value" - assert query_args["target_query"] == "t_query" - - # connection/target overwrite test - assert headers["Overwritten-Header"] == "original" - assert query_args["overwritten_query"] == "original" - - # Auth validation - match auth["type"]: - case "BASIC": - user_pass = to_str(base64.b64encode(b"user:pass")) - assert headers["Authorization"] == f"Basic {user_pass}" - case "API_KEY": - assert headers["Api"] == "apikey_secret" - - case "OAUTH_CLIENT_CREDENTIALS": - assert headers["Authorization"] == bearer - - oauth_request, _ = httpserver.log[0] - oauth_login = oauth_request.get_json(force=True) - # Oauth login validation - assert oauth_login["client_id"] == "id" - assert oauth_login["client_secret"] == "password" - assert oauth_login["oauthbody"] == "value1" - assert oauth_request.headers["oauthheader"] == "value2" - assert oauth_request.args["oauthquery"] == "value3" - @markers.aws.validated @pytest.mark.skipif(is_old_provider(), reason="V1 provider does not support this feature") def test_create_connection_validations(self, aws_client, snapshot): @@ -1809,382 +1620,3 @@ def test_put_target_id_validation( {"Id": target_id, "Arn": queue_arn, "InputPath": "$.detail"}, ], ) - - -API_DESTINATION_AUTH_PARAMS = [ - { - "AuthorizationType": "BASIC", - "AuthParameters": { - "BasicAuthParameters": {"Username": "user", "Password": "pass"}, - }, - }, - { - "AuthorizationType": "API_KEY", - "AuthParameters": { - "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, - }, - }, - { - "AuthorizationType": "OAUTH_CLIENT_CREDENTIALS", - "AuthParameters": { - "OAuthParameters": { - "AuthorizationEndpoint": "https://example.com/oauth", - "ClientParameters": {"ClientID": "client_id", "ClientSecret": "client_secret"}, - "HttpMethod": "POST", - } - }, - }, -] - - -class TestEventBridgeConnections: - @pytest.fixture(autouse=True) - def connection_snapshots(self, snapshot, connection_name): - """Common snapshot transformers for connection tests.""" - return TransformerUtility.eventbridge_connection(snapshot, connection_name) - - @markers.aws.validated - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_create_connection(self, aws_client, snapshot, create_connection, connection_name): - response = create_connection( - "API_KEY", - { - "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, - "InvocationHttpParameters": {}, - }, - ) - snapshot.match("create-connection", response) - - describe_response = aws_client.events.describe_connection(Name=connection_name) - snapshot.match("describe-connection", describe_response) - - @markers.aws.validated - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - @pytest.mark.parametrize("auth_params", API_DESTINATION_AUTH_PARAMS) - def test_create_connection_with_auth( - self, aws_client, snapshot, create_connection, auth_params, connection_name - ): - response = create_connection( - auth_params["AuthorizationType"], - auth_params["AuthParameters"], - ) - snapshot.match("create-connection-auth", response) - - describe_response = aws_client.events.describe_connection(Name=connection_name) - snapshot.match("describe-connection-auth", describe_response) - - @markers.aws.validated - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_list_connections(self, aws_client, snapshot, create_connection, connection_name): - create_connection( - "BASIC", - { - "BasicAuthParameters": {"Username": "user", "Password": "pass"}, - "InvocationHttpParameters": {}, - }, - ) - - response = aws_client.events.list_connections(NamePrefix=connection_name) - snapshot.match("list-connections", response) - - @markers.aws.validated - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_delete_connection(self, aws_client, snapshot, create_connection, connection_name): - response = create_connection( - "API_KEY", - { - "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, - "InvocationHttpParameters": {}, - }, - ) - snapshot.match("create-connection-response", response) - - secret_arn = aws_client.events.describe_connection(Name=connection_name)["SecretArn"] - # check if secret exists - aws_client.secretsmanager.describe_secret(SecretId=secret_arn) - - delete_response = aws_client.events.delete_connection(Name=connection_name) - snapshot.match("delete-connection", delete_response) - - # wait until connection is deleted - def is_connection_deleted(): - try: - aws_client.events.describe_connection(Name=connection_name) - return False - except Exception: - return True - - poll_condition(is_connection_deleted) - - with pytest.raises(aws_client.events.exceptions.ResourceNotFoundException) as exc: - aws_client.events.describe_connection(Name=connection_name) - snapshot.match("describe-deleted-connection", exc.value.response) - - def is_secret_deleted(): - try: - aws_client.secretsmanager.describe_secret(SecretId=secret_arn) - return False - except Exception: - return True - - poll_condition(is_secret_deleted) - - with pytest.raises(aws_client.secretsmanager.exceptions.ResourceNotFoundException): - aws_client.secretsmanager.describe_secret(SecretId=secret_arn) - - @markers.aws.validated - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_create_connection_invalid_parameters(self, aws_client, snapshot, connection_name): - with pytest.raises(ClientError) as e: - aws_client.events.create_connection( - Name=connection_name, - AuthorizationType="INVALID_AUTH_TYPE", - AuthParameters={}, - ) - snapshot.match("create-connection-invalid-auth-error", e.value.response) - - @markers.aws.validated - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_update_connection(self, aws_client, snapshot, create_connection, connection_name): - create_response = create_connection( - "BASIC", - { - "BasicAuthParameters": {"Username": "user", "Password": "pass"}, - "InvocationHttpParameters": {}, - }, - ) - snapshot.match("create-connection", create_response) - - describe_response = aws_client.events.describe_connection(Name=connection_name) - snapshot.match("describe-created-connection", describe_response) - - # add secret id transformer - secret_id = describe_response["SecretArn"] - secret_uuid, _, secret_suffix = secret_id.rpartition("/")[2].rpartition("-") - snapshot.add_transformer( - snapshot.transform.regex(secret_uuid, ""), priority=-1 - ) - snapshot.add_transformer( - snapshot.transform.regex(secret_suffix, ""), priority=-1 - ) - - get_secret_response = aws_client.secretsmanager.get_secret_value(SecretId=secret_id) - snapshot.match("connection-secret-before-update", get_secret_response) - - update_response = aws_client.events.update_connection( - Name=connection_name, - AuthorizationType="BASIC", - AuthParameters={ - "BasicAuthParameters": {"Username": "new_user", "Password": "new_pass"}, - "InvocationHttpParameters": {}, - }, - ) - snapshot.match("update-connection", update_response) - - describe_response = aws_client.events.describe_connection(Name=connection_name) - snapshot.match("describe-updated-connection", describe_response) - - get_secret_response = aws_client.secretsmanager.get_secret_value(SecretId=secret_id) - snapshot.match("connection-secret-after-update", get_secret_response) - - @markers.aws.validated - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_create_connection_name_validation(self, aws_client, snapshot, connection_name): - invalid_name = "Invalid Name With Spaces!" - - with pytest.raises(ClientError) as e: - aws_client.events.create_connection( - Name=invalid_name, - AuthorizationType="API_KEY", - AuthParameters={ - "ApiKeyAuthParameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, - "InvocationHttpParameters": {}, - }, - ) - snapshot.match("create-connection-invalid-name-error", e.value.response) - - @markers.aws.validated - @pytest.mark.parametrize( - "auth_params", API_DESTINATION_AUTH_PARAMS, ids=["basic", "api-key", "oauth"] - ) - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_connection_secrets( - self, aws_client, snapshot, create_connection, connection_name, auth_params - ): - response = create_connection( - auth_params["AuthorizationType"], - auth_params["AuthParameters"], - ) - snapshot.match("create-connection-auth", response) - - describe_response = aws_client.events.describe_connection(Name=connection_name) - snapshot.match("describe-connection-auth", describe_response) - - secret_id = describe_response["SecretArn"] - secret_uuid, _, secret_suffix = secret_id.rpartition("/")[2].rpartition("-") - snapshot.add_transformer( - snapshot.transform.regex(secret_uuid, ""), priority=-1 - ) - snapshot.add_transformer( - snapshot.transform.regex(secret_suffix, ""), priority=-1 - ) - get_secret_response = aws_client.secretsmanager.get_secret_value(SecretId=secret_id) - snapshot.match("connection-secret", get_secret_response) - - -API_DESTINATION_AUTHS = [ - { - "type": "BASIC", - "key": "BasicAuthParameters", - "parameters": {"Username": "user", "Password": "pass"}, - }, - { - "type": "API_KEY", - "key": "ApiKeyAuthParameters", - "parameters": {"ApiKeyName": "ApiKey", "ApiKeyValue": "secret"}, - }, - { - "type": "OAUTH_CLIENT_CREDENTIALS", - "key": "OAuthParameters", - "parameters": { - "ClientParameters": {"ClientID": "id", "ClientSecret": "password"}, - "AuthorizationEndpoint": "https://example.com/oauth", - "HttpMethod": "POST", - "OAuthHttpParameters": { - "BodyParameters": [{"Key": "oauthbody", "Value": "value1", "IsValueSecret": False}], - "HeaderParameters": [ - {"Key": "oauthheader", "Value": "value2", "IsValueSecret": False} - ], - "QueryStringParameters": [ - {"Key": "oauthquery", "Value": "value3", "IsValueSecret": False} - ], - }, - }, - }, -] - - -class TestEventBridgeApiDestinations: - @pytest.fixture - def api_destination_snapshots(self, snapshot, destination_name): - """Common snapshot transformers for API destination tests.""" - return TransformerUtility.eventbridge_api_destination(snapshot, destination_name) - - @markers.aws.validated - @pytest.mark.parametrize("auth", API_DESTINATION_AUTHS) - @pytest.mark.skipif( - is_old_provider(), - reason="V1 provider does not support this feature", - ) - def test_api_destinations( - self, - aws_client, - api_destination_snapshots, - create_connection, - create_api_destination, - connection_name, - destination_name, - auth, - ): - connection_response = create_connection(auth) - connection_arn = connection_response["ConnectionArn"] - - response = create_api_destination( - ConnectionArn=connection_arn, - HttpMethod="POST", - InvocationEndpoint="https://example.com/api", - Description="Test API destination", - ) - api_destination_snapshots.match("create-api-destination", response) - - describe_response = aws_client.events.describe_api_destination(Name=destination_name) - api_destination_snapshots.match("describe-api-destination", describe_response) - - list_response = aws_client.events.list_api_destinations(NamePrefix=destination_name) - api_destination_snapshots.match("list-api-destinations", list_response) - - update_response = aws_client.events.update_api_destination( - Name=destination_name, - ConnectionArn=connection_arn, - HttpMethod="PUT", - InvocationEndpoint="https://example.com/api/v2", - Description="Updated API destination", - ) - api_destination_snapshots.match("update-api-destination", update_response) - - describe_updated_response = aws_client.events.describe_api_destination( - Name=destination_name - ) - api_destination_snapshots.match( - "describe-updated-api-destination", describe_updated_response - ) - - delete_response = aws_client.events.delete_api_destination(Name=destination_name) - api_destination_snapshots.match("delete-api-destination", delete_response) - - with pytest.raises(aws_client.events.exceptions.ResourceNotFoundException) as exc_info: - aws_client.events.describe_api_destination(Name=destination_name) - api_destination_snapshots.match( - "describe-api-destination-not-found-error", exc_info.value.response - ) - - @markers.aws.validated - @pytest.mark.skipif(is_old_provider(), reason="V1 provider does not support this feature") - def test_create_api_destination_invalid_parameters( - self, aws_client, api_destination_snapshots, connection_name, destination_name - ): - with pytest.raises(ClientError) as e: - aws_client.events.create_api_destination( - Name=destination_name, - ConnectionArn="invalid-connection-arn", - HttpMethod="INVALID_METHOD", - InvocationEndpoint="invalid-endpoint", - ) - api_destination_snapshots.match( - "create-api-destination-invalid-parameters-error", e.value.response - ) - - @markers.aws.validated - @pytest.mark.skipif(is_old_provider(), reason="V1 provider does not support this feature") - def test_create_api_destination_name_validation( - self, aws_client, api_destination_snapshots, create_connection, connection_name - ): - invalid_name = "Invalid Name With Spaces!" - - connection_response = create_connection(API_DESTINATION_AUTHS[0]) - connection_arn = connection_response["ConnectionArn"] - - with pytest.raises(ClientError) as e: - aws_client.events.create_api_destination( - Name=invalid_name, - ConnectionArn=connection_arn, - HttpMethod="POST", - InvocationEndpoint="https://example.com/api", - ) - api_destination_snapshots.match( - "create-api-destination-invalid-name-error", e.value.response - ) diff --git a/tests/aws/services/events/test_events.snapshot.json b/tests/aws/services/events/test_events.snapshot.json index 4b6964be9b41d..33ae5bc1c260f 100644 --- a/tests/aws/services/events/test_events.snapshot.json +++ b/tests/aws/services/events/test_events.snapshot.json @@ -1,6 +1,6 @@ { "tests/aws/services/events/test_events.py::TestEvents::test_put_events_without_source": { - "recorded-date": "19-06-2024, 10:40:50", + "recorded-date": "09-12-2024, 10:35:56", "recorded-content": { "put-events": { "Entries": [ @@ -18,7 +18,7 @@ } }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_without_detail": { - "recorded-date": "19-06-2024, 10:40:51", + "recorded-date": "09-12-2024, 10:35:56", "recorded-content": { "put-events": { "Entries": [ @@ -35,8 +35,113 @@ } } }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_with_too_big_detail": { + "recorded-date": "09-12-2024, 10:35:57", + "recorded-content": { + "put-events-too-big-detail-error": { + "Error": { + "Code": "ValidationException", + "Message": "Total size of the entries in the request is over the limit." + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_without_detail_type": { + "recorded-date": "09-12-2024, 10:35:57", + "recorded-content": { + "put-events": { + "Entries": [ + { + "ErrorCode": "InvalidArgument", + "ErrorMessage": "Parameter DetailType is not valid. Reason: DetailType is a required argument." + } + ], + "FailedEntryCount": 1, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[STRING]": { + "recorded-date": "09-12-2024, 10:35:57", + "recorded-content": { + "put-events": { + "Entries": [ + { + "ErrorCode": "MalformedDetail", + "ErrorMessage": "Detail is malformed." + } + ], + "FailedEntryCount": 1, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[ARRAY]": { + "recorded-date": "09-12-2024, 10:35:58", + "recorded-content": { + "put-events": { + "Entries": [ + { + "ErrorCode": "MalformedDetail", + "ErrorMessage": "Detail is malformed." + } + ], + "FailedEntryCount": 1, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[MALFORMED_JSON]": { + "recorded-date": "09-12-2024, 10:35:58", + "recorded-content": { + "put-events": { + "Entries": [ + { + "ErrorCode": "MalformedDetail", + "ErrorMessage": "Detail is malformed." + } + ], + "FailedEntryCount": 1, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[SERIALIZED_STRING]": { + "recorded-date": "09-12-2024, 10:35:58", + "recorded-content": { + "put-events": { + "Entries": [ + { + "ErrorCode": "MalformedDetail", + "ErrorMessage": "Detail is malformed." + } + ], + "FailedEntryCount": 1, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_time": { - "recorded-date": "27-08-2024, 10:02:33", + "recorded-date": "09-12-2024, 10:36:00", "recorded-content": { "messages": [ { @@ -97,7 +202,7 @@ } }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_exceed_limit_ten_entries[custom]": { - "recorded-date": "19-06-2024, 10:40:54", + "recorded-date": "09-12-2024, 10:36:02", "recorded-content": { "put-events-exceed-limit-error": { "Error": { @@ -112,7 +217,7 @@ } }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_exceed_limit_ten_entries[default]": { - "recorded-date": "19-06-2024, 10:40:55", + "recorded-date": "09-12-2024, 10:36:03", "recorded-content": { "put-events-exceed-limit-error": { "Error": { @@ -126,8 +231,132 @@ } } }, + "tests/aws/services/events/test_events.py::TestEvents::test_create_connection_validations": { + "recorded-date": "13-12-2024, 10:54:30", + "recorded-content": { + "create_connection_exc": { + "Error": { + "Code": "ValidationException", + "Message": "3 validation errors detected: Value 'This should fail with two errors 123467890123412341234123412341234' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\.\\-_A-Za-z0-9]+; Value 'This should fail with two errors 123467890123412341234123412341234' at 'name' failed to satisfy constraint: Member must have length less than or equal to 64; Value 'INVALID' at 'authorizationType' failed to satisfy constraint: Member must satisfy enum value set: [BASIC, OAUTH_CLIENT_CREDENTIALS, API_KEY]" + }, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 400 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_events_response_entries_order": { + "recorded-date": "09-12-2024, 10:41:48", + "recorded-content": { + "put-events-response": { + "Entries": [ + { + "EventId": "event-id" + } + ], + "FailedEntryCount": 0, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "sqs-messages": { + "queue1_messages": [ + { + "Body": { + "version": "0", + "id": "", + "detail-type": "core.update-account-command", + "source": "core.update-account-command", + "account": "111111111111", + "time": "date", + "region": "", + "resources": [], + "detail": "detail" + }, + "MD5OfBody": "", + "MessageId": "", + "ReceiptHandle": "" + } + ], + "queue2_messages": [ + { + "Body": { + "version": "0", + "id": "", + "detail-type": "core.update-account-command", + "source": "core.update-account-command", + "account": "111111111111", + "time": "date", + "region": "", + "resources": [], + "detail": "detail" + }, + "MD5OfBody": "", + "MessageId": "", + "ReceiptHandle": "" + } + ] + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_target_delivery_failure": { + "recorded-date": "09-12-2024, 10:38:50", + "recorded-content": { + "put-events-response": { + "Entries": [ + { + "EventId": "" + } + ], + "FailedEntryCount": 0, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + } + } + }, + "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_time_field": { + "recorded-date": "09-12-2024, 10:38:51", + "recorded-content": { + "put-events": { + "Entries": [ + { + "EventId": "" + } + ], + "FailedEntryCount": 0, + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "sqs-messages": [ + { + "MessageId": "", + "ReceiptHandle": "", + "MD5OfBody": "m-d5-of-body", + "Body": { + "version": "0", + "id": "", + "detail-type": "test-detail-type", + "source": "test-source", + "account": "111111111111", + "time": "date", + "region": "", + "resources": [], + "detail": { + "message": "test message" + } + } + } + ] + } + }, "tests/aws/services/events/test_events.py::TestEventBus::test_create_list_describe_delete_custom_event_buses[regions0]": { - "recorded-date": "19-06-2024, 10:54:07", + "recorded-date": "09-12-2024, 10:38:53", "recorded-content": { "create-custom-event-bus-us-east-1": { "EventBusArn": "arn::events::111111111111:event-bus/", @@ -176,7 +405,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_create_list_describe_delete_custom_event_buses[regions1]": { - "recorded-date": "19-06-2024, 10:54:09", + "recorded-date": "09-12-2024, 10:38:55", "recorded-content": { "create-custom-event-bus-us-east-1": { "EventBusArn": "arn::events::111111111111:event-bus/", @@ -313,26 +542,26 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_create_multiple_event_buses_same_name": { - "recorded-date": "19-06-2024, 10:41:05", + "recorded-date": "09-12-2024, 10:38:55", "recorded-content": { "create-multiple-event-buses-same-name": " already exists.') tblen=4>" } }, "tests/aws/services/events/test_events.py::TestEventBus::test_describe_delete_not_existing_event_bus": { - "recorded-date": "19-06-2024, 10:41:07", + "recorded-date": "09-12-2024, 10:38:57", "recorded-content": { "describe-not-existing-event-bus-error": " does not exist.') tblen=3>", "delete-not-existing-event-bus": " does not exist.') tblen=3>" } }, "tests/aws/services/events/test_events.py::TestEventBus::test_delete_default_event_bus": { - "recorded-date": "19-06-2024, 10:41:07", + "recorded-date": "09-12-2024, 10:38:57", "recorded-content": { "delete-default-event-bus-error": "" } }, "tests/aws/services/events/test_events.py::TestEventBus::test_list_event_buses_with_prefix": { - "recorded-date": "19-06-2024, 10:49:27", + "recorded-date": "09-12-2024, 10:38:58", "recorded-content": { "list-event-buses-prefix-complete-name": { "EventBuses": [ @@ -365,7 +594,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_list_event_buses_with_limit": { - "recorded-date": "19-06-2024, 10:50:45", + "recorded-date": "09-12-2024, 10:39:00", "recorded-content": { "list-event-buses-limit": { "EventBuses": [ @@ -423,7 +652,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_permission[custom]": { - "recorded-date": "19-06-2024, 10:41:14", + "recorded-date": "09-12-2024, 10:39:05", "recorded-content": { "put-permission": { "ResponseMetadata": { @@ -555,7 +784,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_permission[default]": { - "recorded-date": "19-06-2024, 10:41:15", + "recorded-date": "09-12-2024, 10:39:07", "recorded-content": { "put-permission": { "ResponseMetadata": { @@ -687,13 +916,13 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_permission_non_existing_event_bus": { - "recorded-date": "19-06-2024, 10:41:15", + "recorded-date": "09-12-2024, 10:39:07", "recorded-content": { "remove-permission-non-existing-sid-error": " does not exist.') tblen=3>" } }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission[custom]": { - "recorded-date": "19-06-2024, 10:41:17", + "recorded-date": "09-12-2024, 10:39:09", "recorded-content": { "remove-permission": { "ResponseMetadata": { @@ -744,7 +973,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission[default]": { - "recorded-date": "19-06-2024, 10:41:18", + "recorded-date": "09-12-2024, 10:39:10", "recorded-content": { "remove-permission": { "ResponseMetadata": { @@ -795,48 +1024,135 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[True-custom]": { - "recorded-date": "19-06-2024, 10:41:18", + "recorded-date": "09-12-2024, 10:39:11", "recorded-content": { "remove-permission-non-existing-sid-error": "" } }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[True-default]": { - "recorded-date": "19-06-2024, 10:41:19", + "recorded-date": "09-12-2024, 10:39:12", "recorded-content": { "remove-permission-non-existing-sid-error": "" } }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[False-custom]": { - "recorded-date": "19-06-2024, 10:41:20", + "recorded-date": "09-12-2024, 10:39:13", "recorded-content": { "remove-permission-non-existing-sid-error": "" } }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[False-default]": { - "recorded-date": "19-06-2024, 10:41:21", + "recorded-date": "09-12-2024, 10:39:14", "recorded-content": { "remove-permission-non-existing-sid-error": "" } }, - "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_to_default_eventbus_for_custom_eventbus": { - "recorded-date": "19-06-2024, 10:41:47", + "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[standard]": { + "recorded-date": "09-12-2024, 10:39:27", "recorded-content": { - "create-custom-event-bus": { - "EventBusArn": "arn::events::111111111111:event-bus/", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "create-rule-1": { - "RuleArn": "arn::events::111111111111:rule/", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 + "messages": [ + { + "MessageId": "", + "ReceiptHandle": "receipt-handle", + "MD5OfBody": "m-d5-of-body", + "Body": { + "version": "0", + "id": "", + "detail-type": "core.update-account-command", + "source": "core.update-account-command", + "account": "111111111111", + "time": "date", + "region": "", + "resources": [], + "detail": { + "command": "update-account", + "payload": { + "acc_id": "0a787ecb-4015", + "sf_id": "baz" + } + } + } } - }, - "create-rule-2": { - "RuleArn": "arn::events::111111111111:rule//", + ] + } + }, + "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[domain]": { + "recorded-date": "09-12-2024, 10:39:42", + "recorded-content": { + "messages": [ + { + "MessageId": "", + "ReceiptHandle": "receipt-handle", + "MD5OfBody": "m-d5-of-body", + "Body": { + "version": "0", + "id": "", + "detail-type": "core.update-account-command", + "source": "core.update-account-command", + "account": "111111111111", + "time": "date", + "region": "", + "resources": [], + "detail": { + "command": "update-account", + "payload": { + "acc_id": "0a787ecb-4015", + "sf_id": "baz" + } + } + } + } + ] + } + }, + "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[path]": { + "recorded-date": "09-12-2024, 10:39:57", + "recorded-content": { + "messages": [ + { + "MessageId": "", + "ReceiptHandle": "receipt-handle", + "MD5OfBody": "m-d5-of-body", + "Body": { + "version": "0", + "id": "", + "detail-type": "core.update-account-command", + "source": "core.update-account-command", + "account": "111111111111", + "time": "date", + "region": "", + "resources": [], + "detail": { + "command": "update-account", + "payload": { + "acc_id": "0a787ecb-4015", + "sf_id": "baz" + } + } + } + } + ] + } + }, + "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_to_default_eventbus_for_custom_eventbus": { + "recorded-date": "09-12-2024, 10:40:25", + "recorded-content": { + "create-custom-event-bus": { + "EventBusArn": "arn::events::111111111111:event-bus/", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "create-rule-1": { + "RuleArn": "arn::events::111111111111:rule/", + "ResponseMetadata": { + "HTTPHeaders": {}, + "HTTPStatusCode": 200 + } + }, + "create-rule-2": { + "RuleArn": "arn::events::111111111111:rule//", "ResponseMetadata": { "HTTPHeaders": {}, "HTTPStatusCode": 200 @@ -898,7 +1214,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_nonexistent_event_bus": { - "recorded-date": "19-06-2024, 10:45:41", + "recorded-date": "09-12-2024, 10:44:29", "recorded-content": { "put-events": { "Entries": [ @@ -948,7 +1264,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventRule::test_put_list_with_prefix_describe_delete_rule[custom]": { - "recorded-date": "19-06-2024, 10:42:07", + "recorded-date": "09-12-2024, 10:40:45", "recorded-content": { "put-rule": { "RuleArn": "arn::events::111111111111:rule//", @@ -1024,7 +1340,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventRule::test_put_list_with_prefix_describe_delete_rule[default]": { - "recorded-date": "19-06-2024, 10:42:08", + "recorded-date": "09-12-2024, 10:40:47", "recorded-content": { "put-rule": { "RuleArn": "arn::events::111111111111:rule/", @@ -1100,7 +1416,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventRule::test_put_multiple_rules_with_same_name": { - "recorded-date": "19-06-2024, 10:42:09", + "recorded-date": "09-12-2024, 10:40:48", "recorded-content": { "put-rule": { "RuleArn": "arn::events::111111111111:rule//", @@ -1146,7 +1462,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventRule::test_list_rule_with_limit": { - "recorded-date": "19-06-2024, 10:42:12", + "recorded-date": "09-12-2024, 10:40:51", "recorded-content": { "list-rules-limit": { "NextToken": "", @@ -1282,13 +1598,13 @@ } }, "tests/aws/services/events/test_events.py::TestEventRule::test_describe_nonexistent_rule": { - "recorded-date": "19-06-2024, 10:42:14", + "recorded-date": "09-12-2024, 10:40:53", "recorded-content": { "describe-not-existing-rule-error": " does not exist on EventBus default.') tblen=3>" } }, "tests/aws/services/events/test_events.py::TestEventRule::test_disable_re_enable_rule[custom]": { - "recorded-date": "19-06-2024, 10:42:15", + "recorded-date": "09-12-2024, 10:40:54", "recorded-content": { "disable-rule": { "ResponseMetadata": { @@ -1353,7 +1669,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventRule::test_disable_re_enable_rule[default]": { - "recorded-date": "19-06-2024, 10:42:17", + "recorded-date": "09-12-2024, 10:40:56", "recorded-content": { "disable-rule": { "ResponseMetadata": { @@ -1418,13 +1734,13 @@ } }, "tests/aws/services/events/test_events.py::TestEventRule::test_delete_rule_with_targets": { - "recorded-date": "19-06-2024, 10:42:18", + "recorded-date": "09-12-2024, 10:40:57", "recorded-content": { "delete-rule-with-targets-error": "" } }, "tests/aws/services/events/test_events.py::TestEventRule::test_update_rule_with_targets": { - "recorded-date": "19-06-2024, 10:42:20", + "recorded-date": "09-12-2024, 10:40:59", "recorded-content": { "list-targets": { "Targets": [ @@ -1460,7 +1776,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventPattern::test_put_events_pattern_with_values_in_array": { - "recorded-date": "19-06-2024, 10:42:28", + "recorded-date": "09-12-2024, 10:41:07", "recorded-content": { "messages": [ { @@ -1496,7 +1812,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventPattern::test_put_events_pattern_nested": { - "recorded-date": "19-06-2024, 10:42:40", + "recorded-date": "09-12-2024, 10:41:20", "recorded-content": { "messages": [ { @@ -1515,7 +1831,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventTarget::test_put_list_remove_target[custom]": { - "recorded-date": "19-06-2024, 10:42:42", + "recorded-date": "09-12-2024, 10:41:22", "recorded-content": { "put-target": { "FailedEntries": [], @@ -1555,7 +1871,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventTarget::test_put_list_remove_target[default]": { - "recorded-date": "19-06-2024, 10:42:44", + "recorded-date": "09-12-2024, 10:41:24", "recorded-content": { "put-target": { "FailedEntries": [], @@ -1595,13 +1911,13 @@ } }, "tests/aws/services/events/test_events.py::TestEventTarget::test_add_exceed_fife_targets_per_rule": { - "recorded-date": "19-06-2024, 10:42:45", + "recorded-date": "09-12-2024, 10:41:25", "recorded-content": { "put-targets-client-error": "" } }, "tests/aws/services/events/test_events.py::TestEventTarget::test_list_target_by_rule_limit": { - "recorded-date": "19-06-2024, 10:42:47", + "recorded-date": "09-12-2024, 10:41:27", "recorded-content": { "list-targets-limit": { "NextToken": "", @@ -1643,7 +1959,7 @@ } }, "tests/aws/services/events/test_events.py::TestEventTarget::test_put_target_id_validation": { - "recorded-date": "19-06-2024, 10:42:49", + "recorded-date": "09-12-2024, 10:41:30", "recorded-content": { "put-targets-invalid-id-error": { "Error": { @@ -1666,1157 +1982,5 @@ } } } - }, - "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[standard]": { - "recorded-date": "20-06-2024, 08:47:59", - "recorded-content": { - "messages": [ - { - "MessageId": "", - "ReceiptHandle": "receipt-handle", - "MD5OfBody": "m-d5-of-body", - "Body": { - "version": "0", - "id": "", - "detail-type": "core.update-account-command", - "source": "core.update-account-command", - "account": "111111111111", - "time": "date", - "region": "", - "resources": [], - "detail": { - "command": "update-account", - "payload": { - "acc_id": "0a787ecb-4015", - "sf_id": "baz" - } - } - } - } - ] - } - }, - "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[domain]": { - "recorded-date": "20-06-2024, 08:48:13", - "recorded-content": { - "messages": [ - { - "MessageId": "", - "ReceiptHandle": "receipt-handle", - "MD5OfBody": "m-d5-of-body", - "Body": { - "version": "0", - "id": "", - "detail-type": "core.update-account-command", - "source": "core.update-account-command", - "account": "111111111111", - "time": "date", - "region": "", - "resources": [], - "detail": { - "command": "update-account", - "payload": { - "acc_id": "0a787ecb-4015", - "sf_id": "baz" - } - } - } - } - ] - } - }, - "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[path]": { - "recorded-date": "20-06-2024, 08:48:28", - "recorded-content": { - "messages": [ - { - "MessageId": "", - "ReceiptHandle": "receipt-handle", - "MD5OfBody": "m-d5-of-body", - "Body": { - "version": "0", - "id": "", - "detail-type": "core.update-account-command", - "source": "core.update-account-command", - "account": "111111111111", - "time": "date", - "region": "", - "resources": [], - "detail": { - "command": "update-account", - "payload": { - "acc_id": "0a787ecb-4015", - "sf_id": "baz" - } - } - } - } - ] - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_event_with_too_big_detail": { - "recorded-date": "18-10-2024, 07:36:18", - "recorded-content": { - "put-events-too-big-detail-error": { - "Error": { - "Code": "ValidationException", - "Message": "Total size of the entries in the request is over the limit."}, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_create_connection_validations": { - "recorded-date": "14-11-2024, 20:29:49", - "recorded-content": { - "create_connection_exc": { - "Error": { - "Code": "ValidationException", - "Message": "3 validation errors detected: Value 'This should fail with two errors 123467890123412341234123412341234' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\.\\-_A-Za-z0-9]+; Value 'This should fail with two errors 123467890123412341234123412341234' at 'name' failed to satisfy constraint: Member must have length less than or equal to 64; Value 'INVALID' at 'authorizationType' failed to satisfy constraint: Member must satisfy enum value set: [BASIC, OAUTH_CLIENT_CREDENTIALS, API_KEY]" - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection": { - "recorded-date": "21-11-2024, 14:49:50", - "recorded-content": { - "create-connection": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-connection": { - "AuthParameters": { - "ApiKeyAuthParameters": { - "ApiKeyName": "ApiKey" - }, - "InvocationHttpParameters": {} - }, - "AuthorizationType": "API_KEY", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params0]": { - "recorded-date": "21-11-2024, 14:49:51", - "recorded-content": { - "create-connection-auth": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-connection-auth": { - "AuthParameters": { - "BasicAuthParameters": { - "Username": "user" - } - }, - "AuthorizationType": "BASIC", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params1]": { - "recorded-date": "21-11-2024, 14:49:51", - "recorded-content": { - "create-connection-auth": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-connection-auth": { - "AuthParameters": { - "ApiKeyAuthParameters": { - "ApiKeyName": "ApiKey" - } - }, - "AuthorizationType": "API_KEY", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params2]": { - "recorded-date": "21-11-2024, 14:49:51", - "recorded-content": { - "create-connection-auth": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZING", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-connection-auth": { - "AuthParameters": { - "OAuthParameters": { - "AuthorizationEndpoint": "https://example.com/oauth", - "ClientParameters": { - "ClientID": "client_id" - }, - "HttpMethod": "POST" - } - }, - "AuthorizationType": "OAUTH_CLIENT_CREDENTIALS", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZING", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_list_connections": { - "recorded-date": "21-11-2024, 14:49:52", - "recorded-content": { - "list-connections": { - "Connections": [ - { - "AuthorizationType": "BASIC", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "" - } - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_invalid_parameters": { - "recorded-date": "21-11-2024, 14:49:53", - "recorded-content": { - "create-connection-invalid-auth-error": { - "Error": { - "Code": "ValidationException", - "Message": "1 validation error detected: Value 'INVALID_AUTH_TYPE' at 'authorizationType' failed to satisfy constraint: Member must satisfy enum value set: [BASIC, OAUTH_CLIENT_CREDENTIALS, API_KEY]" - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_update_connection": { - "recorded-date": "21-11-2024, 15:39:32", - "recorded-content": { - "create-connection": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-created-connection": { - "AuthParameters": { - "BasicAuthParameters": { - "Username": "user" - }, - "InvocationHttpParameters": {} - }, - "AuthorizationType": "BASIC", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "connection-secret-before-update": { - "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", - "CreatedDate": "datetime", - "Name": "events!connection//", - "SecretString": { - "username": "user", - "password": "pass", - "invocation_http_parameters": {} - }, - "VersionId": "", - "VersionStages": [ - "AWSCURRENT" - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "update-connection": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-updated-connection": { - "AuthParameters": { - "BasicAuthParameters": { - "Username": "new_user" - }, - "InvocationHttpParameters": {} - }, - "AuthorizationType": "BASIC", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "connection-secret-after-update": { - "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", - "CreatedDate": "datetime", - "Name": "events!connection//", - "SecretString": { - "username": "new_user", - "password": "new_pass", - "invocation_http_parameters": {} - }, - "VersionId": "", - "VersionStages": [ - "AWSCURRENT" - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_name_validation": { - "recorded-date": "21-11-2024, 14:49:54", - "recorded-content": { - "create-connection-invalid-name-error": { - "Error": { - "Code": "ValidationException", - "Message": "1 validation error detected: Value 'Invalid Name With Spaces!' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\.\\-_A-Za-z0-9]+" - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_delete_connection": { - "recorded-date": "21-11-2024, 15:47:45", - "recorded-content": { - "create-connection-response": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "delete-connection": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "DELETING", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-deleted-connection": { - "Error": { - "Code": "ResourceNotFoundException", - "Message": "Failed to describe the connection(s). Connection '' does not exist." - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeEndpoints::test_create_endpoint": { - "recorded-date": "16-11-2024, 13:01:35", - "recorded-content": {} - }, - "tests/aws/services/events/test_events.py::TestEventBridgeEndpoints::test_list_endpoints": { - "recorded-date": "16-11-2024, 13:01:36", - "recorded-content": {} - }, - "tests/aws/services/events/test_events.py::TestEventBridgeEndpoints::test_delete_endpoint": { - "recorded-date": "16-11-2024, 12:56:52", - "recorded-content": {} - }, - "tests/aws/services/events/test_events.py::TestEventBridgeEndpoints::test_update_endpoint": { - "recorded-date": "16-11-2024, 12:56:52", - "recorded-content": {} - }, - "tests/aws/services/events/test_events.py::TestEventBridgeEndpoints::test_create_endpoint_invalid_parameters": { - "recorded-date": "16-11-2024, 12:56:52", - "recorded-content": {} - }, - "tests/aws/services/events/test_events.py::TestEventBridgeEndpoints::test_create_endpoint_name_validation": { - "recorded-date": "16-11-2024, 12:56:52", - "recorded-content": {} - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_api_destinations[auth0]": { - "recorded-date": "16-11-2024, 13:44:03", - "recorded-content": { - "create-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "Description": "Test API destination", - "HttpMethod": "POST", - "InvocationEndpoint": "https://example.com/api", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "list-api-destinations": { - "ApiDestinations": [ - { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "HttpMethod": "POST", - "InvocationEndpoint": "https://example.com/api", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "" - } - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "update-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-updated-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "Description": "Updated API destination", - "HttpMethod": "PUT", - "InvocationEndpoint": "https://example.com/api/v2", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "delete-api-destination": { - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-api-destination-not-found-error": { - "Error": { - "Code": "ResourceNotFoundException", - "Message": "Failed to describe the api-destination(s). An api-destination '' does not exist." - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_api_destinations[auth1]": { - "recorded-date": "16-11-2024, 13:44:04", - "recorded-content": { - "create-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "Description": "Test API destination", - "HttpMethod": "POST", - "InvocationEndpoint": "https://example.com/api", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "list-api-destinations": { - "ApiDestinations": [ - { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "HttpMethod": "POST", - "InvocationEndpoint": "https://example.com/api", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "" - } - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "update-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-updated-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "ACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "Description": "Updated API destination", - "HttpMethod": "PUT", - "InvocationEndpoint": "https://example.com/api/v2", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "delete-api-destination": { - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-api-destination-not-found-error": { - "Error": { - "Code": "ResourceNotFoundException", - "Message": "Failed to describe the api-destination(s). An api-destination '' does not exist." - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_api_destinations[auth2]": { - "recorded-date": "16-11-2024, 13:44:07", - "recorded-content": { - "create-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "INACTIVE", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "INACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "Description": "Test API destination", - "HttpMethod": "POST", - "InvocationEndpoint": "https://example.com/api", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "list-api-destinations": { - "ApiDestinations": [ - { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "INACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "HttpMethod": "POST", - "InvocationEndpoint": "https://example.com/api", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "" - } - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "update-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "INACTIVE", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-updated-api-destination": { - "ApiDestinationArn": "api-destination-arn", - "ApiDestinationState": "INACTIVE", - "ConnectionArn": "connection-arn", - "CreationTime": "datetime", - "Description": "Updated API destination", - "HttpMethod": "PUT", - "InvocationEndpoint": "https://example.com/api/v2", - "InvocationRateLimitPerSecond": 300, - "LastModifiedTime": "datetime", - "Name": "", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "delete-api-destination": { - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-api-destination-not-found-error": { - "Error": { - "Code": "ResourceNotFoundException", - "Message": "Failed to describe the api-destination(s). An api-destination '' does not exist." - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_create_api_destination_invalid_parameters": { - "recorded-date": "16-11-2024, 13:44:07", - "recorded-content": { - "create-api-destination-invalid-parameters-error": { - "Error": { - "Code": "ValidationException", - "Message": "2 validation errors detected: Value 'invalid-connection-arn' at 'connectionArn' failed to satisfy constraint: Member must satisfy regular expression pattern: ^arn:aws([a-z]|\\-)*:events:([a-z]|\\d|\\-)*:([0-9]{12})?:connection\\/[\\.\\-_A-Za-z0-9]+\\/[\\-A-Za-z0-9]+$; Value 'INVALID_METHOD' at 'httpMethod' failed to satisfy constraint: Member must satisfy enum value set: [HEAD, POST, PATCH, DELETE, PUT, GET, OPTIONS]" - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_create_api_destination_name_validation": { - "recorded-date": "16-11-2024, 13:44:08", - "recorded-content": { - "create-api-destination-invalid-name-error": { - "Error": { - "Code": "ValidationException", - "Message": "1 validation error detected: Value 'Invalid Name With Spaces!' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\.\\-_A-Za-z0-9]+" - }, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 400 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_event_without_detail_type": { - "recorded-date": "14-11-2024, 22:43:09", - "recorded-content": { - "put-events": { - "Entries": [ - { - "ErrorCode": "InvalidArgument", - "ErrorMessage": "Parameter DetailType is not valid. Reason: DetailType is a required argument." - } - ], - "FailedEntryCount": 1, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_events_response_entries_order": { - "recorded-date": "20-11-2024, 12:32:18", - "recorded-content": { - "put-events-response": { - "Entries": [ - { - "EventId": "event-id" - } - ], - "FailedEntryCount": 0, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "sqs-messages": { - "queue1_messages": [ - { - "Body": { - "version": "0", - "id": "", - "detail-type": "core.update-account-command", - "source": "core.update-account-command", - "account": "111111111111", - "time": "date", - "region": "", - "resources": [], - "detail": "detail" - }, - "MD5OfBody": "", - "MessageId": "", - "ReceiptHandle": "" - } - ], - "queue2_messages": [ - { - "Body": { - "version": "0", - "id": "", - "detail-type": "core.update-account-command", - "source": "core.update-account-command", - "account": "111111111111", - "time": "date", - "region": "", - "resources": [], - "detail": "detail" - }, - "MD5OfBody": "", - "MessageId": "", - "ReceiptHandle": "" - } - ] - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_iam_permission_failure": { - "recorded-date": "20-11-2024, 12:32:10", - "recorded-content": { - "put-events-response": { - "Entries": [ - { - "EventId": "" - } - ], - "FailedEntryCount": 0, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_target_delivery_failure": { - "recorded-date": "20-11-2024, 17:19:19", - "recorded-content": { - "put-events-response": { - "Entries": [ - { - "EventId": "" - } - ], - "FailedEntryCount": 0, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_connection_secrets[basic]": { - "recorded-date": "21-11-2024, 15:16:35", - "recorded-content": { - "create-connection-auth": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-connection-auth": { - "AuthParameters": { - "BasicAuthParameters": { - "Username": "user" - } - }, - "AuthorizationType": "BASIC", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "connection-secret": { - "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", - "CreatedDate": "datetime", - "Name": "events!connection//", - "SecretString": { - "username": "user", - "password": "pass" - }, - "VersionId": "", - "VersionStages": [ - "AWSCURRENT" - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_connection_secrets[api-key]": { - "recorded-date": "21-11-2024, 15:16:35", - "recorded-content": { - "create-connection-auth": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-connection-auth": { - "AuthParameters": { - "ApiKeyAuthParameters": { - "ApiKeyName": "ApiKey" - } - }, - "AuthorizationType": "API_KEY", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZED", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "connection-secret": { - "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", - "CreatedDate": "datetime", - "Name": "events!connection//", - "SecretString": { - "api_key_name": "ApiKey", - "api_key_value": "secret" - }, - "VersionId": "", - "VersionStages": [ - "AWSCURRENT" - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_connection_secrets[oauth]": { - "recorded-date": "21-11-2024, 15:16:36", - "recorded-content": { - "create-connection-auth": { - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZING", - "CreationTime": "datetime", - "LastModifiedTime": "datetime", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "describe-connection-auth": { - "AuthParameters": { - "OAuthParameters": { - "AuthorizationEndpoint": "https://example.com/oauth", - "ClientParameters": { - "ClientID": "client_id" - }, - "HttpMethod": "POST" - } - }, - "AuthorizationType": "OAUTH_CLIENT_CREDENTIALS", - "ConnectionArn": "arn::events::111111111111:connection//", - "ConnectionState": "AUTHORIZING", - "CreationTime": "datetime", - "LastAuthorizedTime": "datetime", - "LastModifiedTime": "datetime", - "Name": "", - "SecretArn": "arn::secretsmanager::111111111111:secret:events!connection//-", - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "connection-secret": { - "ARN": "arn::secretsmanager::111111111111:secret:events!connection//-", - "CreatedDate": "datetime", - "Name": "events!connection//", - "SecretString": { - "client_id": "client_id", - "client_secret": "client_secret", - "authorization_endpoint": "https://example.com/oauth", - "http_method": "POST" - }, - "VersionId": "", - "VersionStages": [ - "AWSCURRENT" - ], - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_time_field": { - "recorded-date": "28-11-2024, 21:25:00", - "recorded-content": { - "put-events": { - "Entries": [ - { - "EventId": "" - } - ], - "FailedEntryCount": 0, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - }, - "sqs-messages": [ - { - "MessageId": "", - "ReceiptHandle": "", - "MD5OfBody": "m-d5-of-body", - "Body": { - "version": "0", - "id": "", - "detail-type": "test-detail-type", - "source": "test-source", - "account": "111111111111", - "time": "date", - "region": "", - "resources": [], - "detail": { - "message": "test message" - } - } - } - ] - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[STRING]": { - "recorded-date": "05-12-2024, 14:33:58", - "recorded-content": { - "put-events": { - "Entries": [ - { - "ErrorCode": "MalformedDetail", - "ErrorMessage": "Detail is malformed." - } - ], - "FailedEntryCount": 1, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[ARRAY]": { - "recorded-date": "05-12-2024, 14:33:58", - "recorded-content": { - "put-events": { - "Entries": [ - { - "ErrorCode": "MalformedDetail", - "ErrorMessage": "Detail is malformed." - } - ], - "FailedEntryCount": 1, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[MALFORMED_JSON]": { - "recorded-date": "05-12-2024, 14:33:58", - "recorded-content": { - "put-events": { - "Entries": [ - { - "ErrorCode": "MalformedDetail", - "ErrorMessage": "Detail is malformed." - } - ], - "FailedEntryCount": 1, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[SERIALIZED_STRING]": { - "recorded-date": "05-12-2024, 14:33:58", - "recorded-content": { - "put-events": { - "Entries": [ - { - "ErrorCode": "MalformedDetail", - "ErrorMessage": "Detail is malformed." - } - ], - "FailedEntryCount": 1, - "ResponseMetadata": { - "HTTPHeaders": {}, - "HTTPStatusCode": 200 - } - } - } } } diff --git a/tests/aws/services/events/test_events.validation.json b/tests/aws/services/events/test_events.validation.json index 4cd06cde562ec..c7a4c7efa0a3b 100644 --- a/tests/aws/services/events/test_events.validation.json +++ b/tests/aws/services/events/test_events.validation.json @@ -1,211 +1,172 @@ { - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_api_destinations[auth0]": { - "last_validated_date": "2024-11-16T13:44:03+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_api_destinations[auth1]": { - "last_validated_date": "2024-11-16T13:44:04+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_api_destinations[auth2]": { - "last_validated_date": "2024-11-16T13:44:07+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_create_api_destination_invalid_parameters": { - "last_validated_date": "2024-11-16T13:44:07+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeApiDestinations::test_create_api_destination_name_validation": { - "last_validated_date": "2024-11-16T13:44:08+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_connection_secrets[api-key]": { - "last_validated_date": "2024-11-21T15:16:35+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_connection_secrets[basic]": { - "last_validated_date": "2024-11-21T15:16:35+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_connection_secrets[oauth]": { - "last_validated_date": "2024-11-21T15:16:36+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection": { - "last_validated_date": "2024-11-21T14:58:26+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_invalid_parameters": { - "last_validated_date": "2024-11-21T14:58:29+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_name_validation": { - "last_validated_date": "2024-11-21T14:58:30+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params0]": { - "last_validated_date": "2024-11-21T14:58:27+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params1]": { - "last_validated_date": "2024-11-21T14:58:27+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_create_connection_with_auth[auth_params2]": { - "last_validated_date": "2024-11-21T14:58:28+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_delete_connection": { - "last_validated_date": "2024-11-21T15:47:45+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_list_connections": { - "last_validated_date": "2024-11-21T14:58:28+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBridgeConnections::test_update_connection": { - "last_validated_date": "2024-11-21T15:39:32+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBus::test_create_list_describe_delete_custom_event_buses[regions0]": { - "last_validated_date": "2024-06-19T10:54:07+00:00" - }, - "tests/aws/services/events/test_events.py::TestEventBus::test_create_list_describe_delete_custom_event_buses[regions1]": { - "last_validated_date": "2024-06-19T10:54:09+00:00" + "tests/aws/services/events/test_events.py::TestEvents::test_create_connection_validations": { + "last_validated_date": "2024-12-13T10:54:30+00:00" + } +} + } +} + +} +" + } +} +" + } +} + } +} + "tests/aws/services/events/test_events.py::TestEventBus::test_create_list_describe_delete_custom_event_buses[regions1]": { + "last_validated_date": "2024-12-06T16:56:17+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_create_multiple_event_buses_same_name": { - "last_validated_date": "2024-06-19T10:41:05+00:00" + "last_validated_date": "2024-12-06T16:56:18+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_delete_default_event_bus": { - "last_validated_date": "2024-06-19T10:41:07+00:00" + "last_validated_date": "2024-12-06T16:56:19+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_describe_delete_not_existing_event_bus": { - "last_validated_date": "2024-06-19T10:41:07+00:00" + "last_validated_date": "2024-12-06T16:56:19+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_list_event_buses_with_limit": { - "last_validated_date": "2024-06-19T10:50:45+00:00" + "last_validated_date": "2024-12-06T16:56:22+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_list_event_buses_with_prefix": { - "last_validated_date": "2024-06-19T10:49:27+00:00" + "last_validated_date": "2024-12-06T16:56:20+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[domain]": { - "last_validated_date": "2024-06-20T08:48:13+00:00" + "last_validated_date": "2024-12-06T16:57:03+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[path]": { - "last_validated_date": "2024-06-20T08:48:28+00:00" + "last_validated_date": "2024-12-06T16:57:18+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_bus_to_bus[standard]": { - "last_validated_date": "2024-06-20T08:47:59+00:00" + "last_validated_date": "2024-12-06T16:56:49+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_nonexistent_event_bus": { - "last_validated_date": "2024-06-19T10:45:41+00:00" + "last_validated_date": "2024-12-06T16:59:38+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_events_to_default_eventbus_for_custom_eventbus": { - "last_validated_date": "2024-06-19T10:41:47+00:00" + "last_validated_date": "2024-12-06T17:01:18+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_permission[custom]": { - "last_validated_date": "2024-06-19T10:41:14+00:00" + "last_validated_date": "2024-12-06T16:56:27+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_permission[default]": { - "last_validated_date": "2024-06-19T10:41:15+00:00" + "last_validated_date": "2024-12-06T16:56:29+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_put_permission_non_existing_event_bus": { - "last_validated_date": "2024-06-19T10:41:15+00:00" + "last_validated_date": "2024-12-06T16:56:29+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission[custom]": { - "last_validated_date": "2024-06-19T10:41:17+00:00" + "last_validated_date": "2024-12-06T16:56:31+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission[default]": { - "last_validated_date": "2024-06-19T10:41:18+00:00" + "last_validated_date": "2024-12-06T16:56:32+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[False-custom]": { - "last_validated_date": "2024-06-19T10:41:20+00:00" + "last_validated_date": "2024-12-06T16:56:34+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[False-default]": { - "last_validated_date": "2024-06-19T10:41:21+00:00" + "last_validated_date": "2024-12-06T16:56:36+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[True-custom]": { - "last_validated_date": "2024-06-19T10:41:18+00:00" + "last_validated_date": "2024-12-06T16:56:33+00:00" }, "tests/aws/services/events/test_events.py::TestEventBus::test_remove_permission_non_existing_sid[True-default]": { - "last_validated_date": "2024-06-19T10:41:19+00:00" + "last_validated_date": "2024-12-06T16:56:34+00:00" }, "tests/aws/services/events/test_events.py::TestEventPattern::test_put_events_pattern_nested": { - "last_validated_date": "2024-06-19T10:42:40+00:00" + "last_validated_date": "2024-12-06T17:00:14+00:00" }, "tests/aws/services/events/test_events.py::TestEventPattern::test_put_events_pattern_with_values_in_array": { - "last_validated_date": "2024-06-19T10:42:28+00:00" + "last_validated_date": "2024-12-06T17:00:02+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_delete_rule_with_targets": { - "last_validated_date": "2024-06-19T10:42:18+00:00" + "last_validated_date": "2024-12-06T16:59:52+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_describe_nonexistent_rule": { - "last_validated_date": "2024-06-19T10:42:14+00:00" + "last_validated_date": "2024-12-06T16:59:48+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_disable_re_enable_rule[custom]": { - "last_validated_date": "2024-06-19T10:42:15+00:00" + "last_validated_date": "2024-12-06T16:59:49+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_disable_re_enable_rule[default]": { - "last_validated_date": "2024-06-19T10:42:17+00:00" + "last_validated_date": "2024-12-06T16:59:51+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_list_rule_with_limit": { - "last_validated_date": "2024-06-19T10:42:12+00:00" + "last_validated_date": "2024-12-06T16:59:46+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_put_list_with_prefix_describe_delete_rule[custom]": { - "last_validated_date": "2024-06-19T10:42:07+00:00" + "last_validated_date": "2024-12-09T10:35:32+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_put_list_with_prefix_describe_delete_rule[default]": { - "last_validated_date": "2024-06-19T10:42:08+00:00" + "last_validated_date": "2024-12-06T16:59:42+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_put_multiple_rules_with_same_name": { - "last_validated_date": "2024-06-19T10:42:09+00:00" + "last_validated_date": "2024-12-06T16:59:43+00:00" }, "tests/aws/services/events/test_events.py::TestEventRule::test_update_rule_with_targets": { - "last_validated_date": "2024-06-19T10:42:20+00:00" + "last_validated_date": "2024-12-06T16:59:54+00:00" }, "tests/aws/services/events/test_events.py::TestEventTarget::test_add_exceed_fife_targets_per_rule": { - "last_validated_date": "2024-06-19T10:42:45+00:00" + "last_validated_date": "2024-12-06T17:00:20+00:00" }, "tests/aws/services/events/test_events.py::TestEventTarget::test_list_target_by_rule_limit": { - "last_validated_date": "2024-06-19T10:42:47+00:00" + "last_validated_date": "2024-12-06T17:00:21+00:00" }, "tests/aws/services/events/test_events.py::TestEventTarget::test_put_list_remove_target[custom]": { - "last_validated_date": "2024-06-19T10:42:42+00:00" + "last_validated_date": "2024-12-06T17:00:17+00:00" }, "tests/aws/services/events/test_events.py::TestEventTarget::test_put_list_remove_target[default]": { - "last_validated_date": "2024-06-19T10:42:44+00:00" + "last_validated_date": "2024-12-06T17:00:19+00:00" }, "tests/aws/services/events/test_events.py::TestEventTarget::test_put_target_id_validation": { - "last_validated_date": "2024-06-19T10:42:49+00:00" + "last_validated_date": "2024-12-06T17:00:24+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_create_connection_validations": { - "last_validated_date": "2024-11-14T20:29:49+00:00" + "last_validated_date": "2024-12-06T16:53:21+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[ARRAY]": { - "last_validated_date": "2024-12-05T14:33:58+00:00" + "last_validated_date": "2024-12-06T16:53:16+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[MALFORMED_JSON]": { - "last_validated_date": "2024-12-05T14:33:58+00:00" + "last_validated_date": "2024-12-06T16:53:16+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[SERIALIZED_STRING]": { - "last_validated_date": "2024-12-05T14:33:58+00:00" + "last_validated_date": "2024-12-06T16:53:16+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_malformed_detail[STRING]": { - "last_validated_date": "2024-12-05T14:33:58+00:00" + "last_validated_date": "2024-12-06T16:53:15+00:00" + }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_with_too_big_detail": { - "last_validated_date": "2024-10-18T07:36:18+00:00" + "last_validated_date": "2024-12-06T16:53:15+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_without_detail": { - "last_validated_date": "2024-06-19T10:40:51+00:00" + "last_validated_date": "2024-12-06T16:53:14+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_event_without_detail_type": { - "last_validated_date": "2024-11-14T22:43:51+00:00" + "last_validated_date": "2024-12-06T16:53:15+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_exceed_limit_ten_entries[custom]": { - "last_validated_date": "2024-06-19T10:40:54+00:00" + "last_validated_date": "2024-12-06T16:53:20+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_exceed_limit_ten_entries[default]": { - "last_validated_date": "2024-06-19T10:40:55+00:00" + "last_validated_date": "2024-12-06T16:53:20+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_response_entries_order": { "last_validated_date": "2024-11-21T11:48:24+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_time": { - "last_validated_date": "2024-08-27T10:02:33+00:00" - }, - "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_iam_permission_failure": { - "last_validated_date": "2024-11-20T12:32:10+00:00" + "last_validated_date": "2024-12-06T16:53:18+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_target_delivery_failure": { - "last_validated_date": "2024-11-20T17:19:19+00:00" + "last_validated_date": "2024-12-06T16:56:07+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_with_time_field": { - "last_validated_date": "2024-11-28T21:25:00+00:00" + "last_validated_date": "2024-12-06T17:04:30+00:00" }, "tests/aws/services/events/test_events.py::TestEvents::test_put_events_without_source": { - "last_validated_date": "2024-06-19T10:40:50+00:00" + "last_validated_date": "2024-12-06T16:53:14+00:00" } } +} diff --git a/tests/aws/services/events/test_events_targets.py b/tests/aws/services/events/test_events_targets.py index 8839299ed6357..bfa433591fb33 100644 --- a/tests/aws/services/events/test_events_targets.py +++ b/tests/aws/services/events/test_events_targets.py @@ -2,22 +2,26 @@ Tests are separated in different classes for each target service. Classes are ordered alphabetically.""" +import base64 import json import time import aws_cdk as cdk import pytest +from pytest_httpserver import HTTPServer +from werkzeug import Request, Response from localstack import config from localstack.aws.api.lambda_ import Runtime from localstack.testing.aws.util import is_aws_cloud from localstack.testing.pytest import markers from localstack.utils.aws import arns -from localstack.utils.strings import short_uid -from localstack.utils.sync import retry +from localstack.utils.strings import short_uid, to_str +from localstack.utils.sync import poll_condition, retry from localstack.utils.testutil import check_expected_lambda_log_events_length from tests.aws.scenario.kinesis_firehose.conftest import get_all_expected_messages_from_s3 from tests.aws.services.events.helper_functions import is_old_provider, sqs_collect_messages +from tests.aws.services.events.test_api_destinations_and_connection import API_DESTINATION_AUTHS from tests.aws.services.events.test_events import EVENT_DETAIL, TEST_EVENT_PATTERN from tests.aws.services.firehose.helper_functions import get_firehose_iam_documents from tests.aws.services.kinesis.helper_functions import get_shard_iterator @@ -26,7 +30,6 @@ TEST_LAMBDA_PYTHON_ECHO, ) - # TODO: # These tests should go into LocalStack Pro: # - AppSync (pro) @@ -34,103 +37,171 @@ # - Container (pro) # - Redshift (pro) # - Sagemaker (pro) -class TestEventsTargetCloudWatchLogs: - @markers.aws.validated - def test_put_events_with_target_cloudwatch_logs( - self, - events_create_event_bus, - events_put_rule, - events_log_group, - aws_client, - snapshot, - cleanups, - ): - snapshot.add_transformers_list( - [ - snapshot.transform.key_value("EventId"), - snapshot.transform.key_value("RuleArn"), - snapshot.transform.key_value("EventBusArn"), - ] - ) - event_bus_name = f"test-bus-{short_uid()}" - event_bus_response = events_create_event_bus(Name=event_bus_name) - snapshot.match("event_bus_response", event_bus_response) - log_group = events_log_group() - log_group_name = log_group["log_group_name"] - log_group_arn = log_group["log_group_arn"] - - resource_policy = { - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "EventBridgePutLogEvents", - "Effect": "Allow", - "Principal": {"Service": "events.amazonaws.com"}, - "Action": ["logs:CreateLogStream", "logs:PutLogEvents"], - "Resource": f"{log_group_arn}:*", - } - ], - } - policy_name = f"EventBridgePolicy-{short_uid()}" - aws_client.logs.put_resource_policy( - policyName=policy_name, policyDocument=json.dumps(resource_policy) - ) +class TestEventsTargetApiDestination: + # TODO validate against AWS + @markers.aws.only_localstack + @pytest.mark.skipif(is_old_provider(), reason="not supported by the old provider") + @pytest.mark.parametrize("auth", API_DESTINATION_AUTHS) + def test_put_events_to_target_api_destinations( + self, httpserver: HTTPServer, auth, aws_client, clean_up + ): + token = short_uid() + bearer = f"Bearer {token}" - if is_aws_cloud(): - # Wait for IAM role propagation in AWS cloud environment before proceeding - # This delay is necessary as IAM changes can take several seconds to propagate globally - time.sleep(10) + def _handler(_request: Request): + return Response( + json.dumps( + { + "access_token": token, + "token_type": "Bearer", + "expires_in": 86400, + } + ), + mimetype="application/json", + ) - rule_name = f"test-rule-{short_uid()}" - rule_response = events_put_rule( - Name=rule_name, - EventBusName=event_bus_name, - EventPattern=json.dumps(TEST_EVENT_PATTERN), + httpserver.expect_request("").respond_with_handler(_handler) + http_endpoint = httpserver.url_for("/") + + if auth.get("type") == "OAUTH_CLIENT_CREDENTIALS": + auth["parameters"]["AuthorizationEndpoint"] = http_endpoint + + connection_name = f"c-{short_uid()}" + connection_arn = aws_client.events.create_connection( + Name=connection_name, + AuthorizationType=auth.get("type"), + AuthParameters={ + auth.get("key"): auth.get("parameters"), + "InvocationHttpParameters": { + "BodyParameters": [ + { + "Key": "connection_body_param", + "Value": "value", + "IsValueSecret": False, + }, + ], + "HeaderParameters": [ + { + "Key": "connection-header-param", + "Value": "value", + "IsValueSecret": False, + }, + { + "Key": "overwritten-header", + "Value": "original", + "IsValueSecret": False, + }, + ], + "QueryStringParameters": [ + { + "Key": "connection_query_param", + "Value": "value", + "IsValueSecret": False, + }, + { + "Key": "overwritten_query", + "Value": "original", + "IsValueSecret": False, + }, + ], + }, + }, + )["ConnectionArn"] + + # create api destination + dest_name = f"d-{short_uid()}" + result = aws_client.events.create_api_destination( + Name=dest_name, + ConnectionArn=connection_arn, + InvocationEndpoint=http_endpoint, + HttpMethod="POST", ) - snapshot.match("rule_response", rule_response) + # create rule and target + rule_name = f"r-{short_uid()}" target_id = f"target-{short_uid()}" - put_targets_response = aws_client.events.put_targets( + pattern = json.dumps({"source": ["source-123"], "detail-type": ["type-123"]}) + aws_client.events.put_rule(Name=rule_name, EventPattern=pattern) + aws_client.events.put_targets( Rule=rule_name, - EventBusName=event_bus_name, Targets=[ { "Id": target_id, - "Arn": log_group_arn, + "Arn": result["ApiDestinationArn"], + "Input": '{"target_value":"value"}', + "HttpParameters": { + "PathParameterValues": ["target_path"], + "HeaderParameters": { + "target-header": "target_header_value", + "overwritten_header": "changed", + }, + "QueryStringParameters": { + "target_query": "t_query", + "overwritten_query": "changed", + }, + }, } ], ) - snapshot.match("put_targets_response", put_targets_response) - assert put_targets_response["FailedEntryCount"] == 0 - event_entry = { - "EventBusName": event_bus_name, - "Source": TEST_EVENT_PATTERN["source"][0], - "DetailType": TEST_EVENT_PATTERN["detail-type"][0], - "Detail": json.dumps(EVENT_DETAIL), - } - put_events_response = aws_client.events.put_events(Entries=[event_entry]) - snapshot.match("put_events_response", put_events_response) - assert put_events_response["FailedEntryCount"] == 0 - - def get_log_events(): - response = aws_client.logs.describe_log_streams(logGroupName=log_group_name) - log_streams = response.get("logStreams", []) - assert log_streams, "No log streams found" - - log_stream_name = log_streams[0]["logStreamName"] - events_response = aws_client.logs.get_log_events( - logGroupName=log_group_name, - logStreamName=log_stream_name, - ) - events = events_response.get("events", []) - assert events, "No log events found" - return events - - events = retry(get_log_events, retries=5, sleep=5) - snapshot.match("log_events", events) + entries = [ + { + "Source": "source-123", + "DetailType": "type-123", + "Detail": '{"i": 0}', + } + ] + aws_client.events.put_events(Entries=entries) + + # clean up + aws_client.events.delete_connection(Name=connection_name) + aws_client.events.delete_api_destination(Name=dest_name) + clean_up(rule_name=rule_name, target_ids=target_id) + + to_recv = 2 if auth["type"] == "OAUTH_CLIENT_CREDENTIALS" else 1 + poll_condition(lambda: len(httpserver.log) >= to_recv, timeout=5) + + event_request, _ = httpserver.log[-1] + event = event_request.get_json(force=True) + headers = event_request.headers + query_args = event_request.args + + # Connection data validation + assert event["connection_body_param"] == "value" + assert headers["Connection-Header-Param"] == "value" + assert query_args["connection_query_param"] == "value" + + # Target parameters validation + assert "/target_path" in event_request.path + assert event["target_value"] == "value" + assert headers["Target-Header"] == "target_header_value" + assert query_args["target_query"] == "t_query" + + # connection/target overwrite test + assert headers["Overwritten-Header"] == "original" + assert query_args["overwritten_query"] == "original" + + # Auth validation + match auth["type"]: + case "BASIC": + user_pass = to_str(base64.b64encode(b"user:pass")) + assert headers["Authorization"] == f"Basic {user_pass}" + case "API_KEY": + assert headers["Api"] == "apikey_secret" + + case "OAUTH_CLIENT_CREDENTIALS": + assert headers["Authorization"] == bearer + + oauth_request, _ = httpserver.log[0] + oauth_login = oauth_request.get_json(force=True) + # Oauth login validation + assert oauth_login["client_id"] == "id" + assert oauth_login["client_secret"] == "password" + assert oauth_login["oauthbody"] == "value1" + assert oauth_request.headers["oauthheader"] == "value2" + assert oauth_request.args["oauthquery"] == "value3" class TestEventsTargetApiGateway: @@ -387,6 +458,105 @@ def test_put_events_with_target_api_gateway( snapshot.match("lambda_logs", events) +class TestEventsTargetCloudWatchLogs: + @markers.aws.validated + def test_put_events_with_target_cloudwatch_logs( + self, + events_create_event_bus, + events_put_rule, + events_log_group, + aws_client, + snapshot, + cleanups, + ): + snapshot.add_transformers_list( + [ + snapshot.transform.key_value("EventId"), + snapshot.transform.key_value("RuleArn"), + snapshot.transform.key_value("EventBusArn"), + ] + ) + + event_bus_name = f"test-bus-{short_uid()}" + event_bus_response = events_create_event_bus(Name=event_bus_name) + snapshot.match("event_bus_response", event_bus_response) + + log_group = events_log_group() + log_group_name = log_group["log_group_name"] + log_group_arn = log_group["log_group_arn"] + + resource_policy = { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "EventBridgePutLogEvents", + "Effect": "Allow", + "Principal": {"Service": "events.amazonaws.com"}, + "Action": ["logs:CreateLogStream", "logs:PutLogEvents"], + "Resource": f"{log_group_arn}:*", + } + ], + } + policy_name = f"EventBridgePolicy-{short_uid()}" + aws_client.logs.put_resource_policy( + policyName=policy_name, policyDocument=json.dumps(resource_policy) + ) + + if is_aws_cloud(): + # Wait for IAM role propagation in AWS cloud environment before proceeding + # This delay is necessary as IAM changes can take several seconds to propagate globally + time.sleep(10) + + rule_name = f"test-rule-{short_uid()}" + rule_response = events_put_rule( + Name=rule_name, + EventBusName=event_bus_name, + EventPattern=json.dumps(TEST_EVENT_PATTERN), + ) + snapshot.match("rule_response", rule_response) + + target_id = f"target-{short_uid()}" + put_targets_response = aws_client.events.put_targets( + Rule=rule_name, + EventBusName=event_bus_name, + Targets=[ + { + "Id": target_id, + "Arn": log_group_arn, + } + ], + ) + snapshot.match("put_targets_response", put_targets_response) + assert put_targets_response["FailedEntryCount"] == 0 + + event_entry = { + "EventBusName": event_bus_name, + "Source": TEST_EVENT_PATTERN["source"][0], + "DetailType": TEST_EVENT_PATTERN["detail-type"][0], + "Detail": json.dumps(EVENT_DETAIL), + } + put_events_response = aws_client.events.put_events(Entries=[event_entry]) + snapshot.match("put_events_response", put_events_response) + assert put_events_response["FailedEntryCount"] == 0 + + def get_log_events(): + response = aws_client.logs.describe_log_streams(logGroupName=log_group_name) + log_streams = response.get("logStreams", []) + assert log_streams, "No log streams found" + + log_stream_name = log_streams[0]["logStreamName"] + events_response = aws_client.logs.get_log_events( + logGroupName=log_group_name, + logStreamName=log_stream_name, + ) + events = events_response.get("events", []) + assert events, "No log events found" + return events + + events = retry(get_log_events, retries=5, sleep=5) + snapshot.match("log_events", events) + + class TestEventsTargetEvents: # cross region and cross account event bus to event buss tests are in test_events_cross_account_region.py