Skip to content

Commit

Permalink
Merge pull request #234 from Jakub007d/regex
Browse files Browse the repository at this point in the history
[CCXDEV-12759] S3Engine cluster_id regex update
  • Loading branch information
Jakub007d authored Jun 17, 2024
2 parents aefbdc0 + f913ce3 commit 2308402
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ccx_messaging/consumers/idp_kafka_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# to extract named groups for the different meaningful components
S3_ARCHIVE_PATTERN = re.compile(
r"(?P<org_id>[0-9]+)\/" # extract named group for organization id
r"(?P<cluster_id>[0-9,a-z,-]{36})\/" # extract named group for the cluster_id
r"(?P<cluster_id>[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\/" # extract named group for the cluster_id # noqa: E501
r"(?P<archive>" # extract named group for the archive name, including the following 3 lines
r"(?P<timestamp>" # extract the timestamp named group, including the following line
# Next line extract year, month, day and time named groups from the timestamp
Expand Down
32 changes: 32 additions & 0 deletions test/consumers/idp_kafka_consumer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,35 @@ def test_create_broker_bad_path():
sut = IDPConsumer(None, None, None, incoming_topic=None)
with pytest.raises(CCXMessagingError):
sut.create_broker(input_msg)


@patch("ccx_messaging.consumers.kafka_consumer.ConfluentConsumer", lambda *a, **k: MagicMock())
def test_create_broker_bad_cluster_id_format():
"""Test that `create_broker` generates a broker with the expected values."""
path = (
"00000000/aaaaaaaa-bbbb-xxxx-ffff-badbadbadbad/"
"66666666666666-77777777777777777777777777777777"
)
input_msg = {
"path": path,
}

sut = IDPConsumer(None, None, None, incoming_topic=None)
with pytest.raises(CCXMessagingError):
sut.create_broker(input_msg)


@patch("ccx_messaging.consumers.kafka_consumer.ConfluentConsumer", lambda *a, **k: MagicMock())
def test_create_broker_bad_cluster_id_short():
"""Test that `create_broker` generates a broker with the expected values."""
path = (
"00000000/aa-bbbb-cc-ffff-badbadbadbad/"
"66666666666666-77777777777777777777777777777777"
)
input_msg = {
"path": path,
}

sut = IDPConsumer(None, None, None, incoming_topic=None)
with pytest.raises(CCXMessagingError):
sut.create_broker(input_msg)

0 comments on commit 2308402

Please sign in to comment.