Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COST-962: Filtering out Endpoint Authentication messages #2626

Merged
merged 4 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion koku/sources/kafka_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def get_sources_msg_data(msg, app_type_id):
)
elif event_type in (KAFKA_AUTHENTICATION_CREATE, KAFKA_AUTHENTICATION_UPDATE):
LOG.debug("Authentication Message: %s", str(msg))
if value.get("resource_type") in ("Endpoint", "Application"):
if value.get("resource_type") in ("Application",):
msg_data["event_type"] = event_type
msg_data["offset"] = msg.offset()
msg_data["partition"] = msg.partition()
Expand Down
11 changes: 3 additions & 8 deletions koku/sources/test/test_kafka_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ def test_get_sources_msg_data_destroy(self):
self.assertEqual(response.get("source_id"), 1)
self.assertEqual(response.get("auth_header"), test_auth_header)

def test_get_sources_msg_authentication(self):
"""Test to get sources details from msg for Authentication.create event."""
def test_get_sources_msg_authentication_unsuported_auth_endpoint(self):
"""Test to ensure Authentication event for Endpoint is filtered."""
test_topic = "platform.sources.event-stream"
authentication_events = ["Authentication.create", "Authentication.update"]
test_offset = 5
Expand All @@ -394,13 +394,8 @@ def test_get_sources_msg_authentication(self):
auth_header=test_auth_header,
value=bytes(test_value, encoding="utf-8"),
)

response = source_integration.get_sources_msg_data(msg, cost_management_app_type)
self.assertEqual(response.get("event_type"), event)
self.assertEqual(response.get("resource_id"), 1)
self.assertEqual(response.get("resource_type"), "Endpoint")
self.assertEqual(response.get("auth_header"), test_auth_header)
self.assertEqual(response.get("offset"), test_offset)
self.assertEqual(response, {})

def test_get_sources_msg_data_other(self):
"""Test to get sources details from other message."""
Expand Down