|
24 | 24 | EventBusNameOrArn,
|
25 | 25 | EventPattern,
|
26 | 26 | EventsApi,
|
27 |
| - InvalidEventPatternException, |
28 | 27 | PutRuleResponse,
|
29 | 28 | PutTargetsResponse,
|
30 | 29 | RoleArn,
|
|
40 | 39 | from localstack.constants import APPLICATION_AMZ_JSON_1_1
|
41 | 40 | from localstack.http import route
|
42 | 41 | from localstack.services.edge import ROUTER
|
43 |
| -from localstack.services.events.models import ( |
44 |
| - InvalidEventPatternException as InternalInvalidEventPatternException, |
45 |
| -) |
46 | 42 | from localstack.services.events.scheduler import JobScheduler
|
47 | 43 | from localstack.services.events.v1.models import EventsStore, events_stores
|
48 |
| -from localstack.services.events.v1.utils import matches_event |
49 | 44 | from localstack.services.moto import call_moto
|
50 | 45 | from localstack.services.plugins import ServiceLifecycleHook
|
51 | 46 | from localstack.utils.aws.arns import event_bus_arn, parse_arn
|
52 | 47 | from localstack.utils.aws.client_types import ServicePrincipal
|
53 | 48 | from localstack.utils.aws.message_forwarding import send_event_to_target
|
54 | 49 | from localstack.utils.collections import pick_attributes
|
55 | 50 | from localstack.utils.common import TMP_FILES, mkdir, save_file, truncate
|
56 |
| -from localstack.utils.event_matcher import matches_event as matches_rule |
| 51 | +from localstack.utils.event_matcher import matches_event |
57 | 52 | from localstack.utils.json import extract_jsonpath
|
58 | 53 | from localstack.utils.strings import long_uid, short_uid
|
59 | 54 | from localstack.utils.time import TIMESTAMP_FORMAT_TZ, timestamp
|
@@ -115,44 +110,7 @@ def test_event_pattern(
|
115 | 110 | """Test event pattern uses EventBridge event pattern matching:
|
116 | 111 | https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html
|
117 | 112 | """
|
118 |
| - if config.EVENT_RULE_ENGINE == "java": |
119 |
| - try: |
120 |
| - result = matches_rule(event, event_pattern) |
121 |
| - except InternalInvalidEventPatternException as e: |
122 |
| - raise InvalidEventPatternException(e.message) from e |
123 |
| - else: |
124 |
| - event_pattern_dict = json.loads(event_pattern) |
125 |
| - event_dict = json.loads(event) |
126 |
| - result = matches_event(event_pattern_dict, event_dict) |
127 |
| - |
128 |
| - # TODO: unify the different implementations below: |
129 |
| - # event_pattern_dict = json.loads(event_pattern) |
130 |
| - # event_dict = json.loads(event) |
131 |
| - |
132 |
| - # EventBridge: |
133 |
| - # result = matches_event(event_pattern_dict, event_dict) |
134 |
| - |
135 |
| - # Lambda EventSourceMapping: |
136 |
| - # from localstack.services.lambda_.event_source_listeners.utils import does_match_event |
137 |
| - # |
138 |
| - # result = does_match_event(event_pattern_dict, event_dict) |
139 |
| - |
140 |
| - # moto-ext EventBridge: |
141 |
| - # from moto.events.models import EventPattern as EventPatternMoto |
142 |
| - # |
143 |
| - # event_pattern = EventPatternMoto.load(event_pattern) |
144 |
| - # result = event_pattern.matches_event(event_dict) |
145 |
| - |
146 |
| - # SNS: The SNS rule engine seems to differ slightly, for example not allowing the wildcard pattern. |
147 |
| - # from localstack.services.sns.publisher import SubscriptionFilter |
148 |
| - # subscription_filter = SubscriptionFilter() |
149 |
| - # result = subscription_filter._evaluate_nested_filter_policy_on_dict(event_pattern_dict, event_dict) |
150 |
| - |
151 |
| - # moto-ext SNS: |
152 |
| - # from moto.sns.utils import FilterPolicyMatcher |
153 |
| - # filter_policy_matcher = FilterPolicyMatcher(event_pattern_dict, "MessageBody") |
154 |
| - # result = filter_policy_matcher._body_based_match(event_dict) |
155 |
| - |
| 113 | + result = matches_event(event_pattern, event) |
156 | 114 | return TestEventPatternResponse(Result=result)
|
157 | 115 |
|
158 | 116 | @staticmethod
|
@@ -430,13 +388,7 @@ def filter_event_based_on_event_format(
|
430 | 388 | return False
|
431 | 389 | if rule_information.event_pattern._pattern:
|
432 | 390 | event_pattern = rule_information.event_pattern._pattern
|
433 |
| - if config.EVENT_RULE_ENGINE == "java": |
434 |
| - event_str = json.dumps(event) |
435 |
| - event_pattern_str = json.dumps(event_pattern) |
436 |
| - match_result = matches_rule(event_str, event_pattern_str) |
437 |
| - else: |
438 |
| - match_result = matches_event(event_pattern, event) |
439 |
| - if not match_result: |
| 391 | + if not matches_event(event_pattern, event): |
440 | 392 | return False
|
441 | 393 | return True
|
442 | 394 |
|
|
0 commit comments