events: fix archive event pattern match check (#3671)
* events: fix archive event pattern match check There is a missing `return True` for the positive match case in matches_pattern, causing all valid patterns to fail. * events: add test for valid, non-empty pattern match
This commit is contained in:
parent
9feabf5479
commit
5fd20626b3
@ -287,6 +287,8 @@ class Archive(CloudFormationModel):
|
|||||||
if event_value not in pattern_value:
|
if event_value not in pattern_value:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def get_cfn_attribute(self, attribute_name):
|
def get_cfn_attribute(self, attribute_name):
|
||||||
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
|
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
|
||||||
|
|
||||||
|
@ -1241,7 +1241,8 @@ def test_archive_actual_events():
|
|||||||
# given
|
# given
|
||||||
client = boto3.client("events", "eu-central-1")
|
client = boto3.client("events", "eu-central-1")
|
||||||
name = "test-archive"
|
name = "test-archive"
|
||||||
name_2 = "test-archive-2"
|
name_2 = "test-archive-no-match"
|
||||||
|
name_3 = "test-archive-matches"
|
||||||
event_bus_arn = "arn:aws:events:eu-central-1:{}:event-bus/default".format(
|
event_bus_arn = "arn:aws:events:eu-central-1:{}:event-bus/default".format(
|
||||||
ACCOUNT_ID
|
ACCOUNT_ID
|
||||||
)
|
)
|
||||||
@ -1256,6 +1257,11 @@ def test_archive_actual_events():
|
|||||||
EventSourceArn=event_bus_arn,
|
EventSourceArn=event_bus_arn,
|
||||||
EventPattern=json.dumps({"DetailType": ["type"], "Source": ["test"]}),
|
EventPattern=json.dumps({"DetailType": ["type"], "Source": ["test"]}),
|
||||||
)
|
)
|
||||||
|
client.create_archive(
|
||||||
|
ArchiveName=name_3,
|
||||||
|
EventSourceArn=event_bus_arn,
|
||||||
|
EventPattern=json.dumps({"DetailType": ["type"], "Source": ["source"]}),
|
||||||
|
)
|
||||||
|
|
||||||
# when
|
# when
|
||||||
response = client.put_events(Entries=[event])
|
response = client.put_events(Entries=[event])
|
||||||
@ -1271,3 +1277,7 @@ def test_archive_actual_events():
|
|||||||
response = client.describe_archive(ArchiveName=name_2)
|
response = client.describe_archive(ArchiveName=name_2)
|
||||||
response["EventCount"].should.equal(0)
|
response["EventCount"].should.equal(0)
|
||||||
response["SizeBytes"].should.equal(0)
|
response["SizeBytes"].should.equal(0)
|
||||||
|
|
||||||
|
response = client.describe_archive(ArchiveName=name_3)
|
||||||
|
response["EventCount"].should.equal(1)
|
||||||
|
response["SizeBytes"].should.be.greater_than(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user