Skip to content

Rename ReporterConfig to ServiceConfig #45

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

Merged
merged 1 commit into from
Aug 7, 2024
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
6 changes: 3 additions & 3 deletions aikido_firewall/background_process/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from aikido_firewall import PKG_VERSION
from aikido_firewall.background_process.heartbeats import send_heartbeats_every_x_secs
from aikido_firewall.background_process.routes import Routes
from .reporter_config import ReporterConfig
from .service_config import ServiceConfig
from aikido_firewall.ratelimiting.rate_limiter import RateLimiter


Expand All @@ -29,7 +29,7 @@
self.api = api
self.token = token # Should be instance of the Token class!
self.routes = Routes(200)
self.conf = ReporterConfig([], get_unixtime_ms())
self.conf = ServiceConfig([], get_unixtime_ms())

Check warning on line 32 in aikido_firewall/background_process/reporter.py

View check run for this annotation

Codecov / codecov/patch

aikido_firewall/background_process/reporter.py#L32

Added line #L32 was not covered by tests
self.rate_limiter = RateLimiter(
max_items=5000, time_to_live_in_ms=120 * 60 * 1000 # 120 minutes
)
Expand Down Expand Up @@ -168,6 +168,6 @@
if res["endpoints"]:
if not isinstance(res["endpoints"], list):
res["endpoints"] = [] # Empty list
self.conf = ReporterConfig(
self.conf = ServiceConfig(

Check warning on line 171 in aikido_firewall/background_process/reporter.py

View check run for this annotation

Codecov / codecov/patch

aikido_firewall/background_process/reporter.py#L171

Added line #L171 was not covered by tests
endpoints=res["endpoints"], last_updated_at=get_unixtime_ms()
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from aikido_firewall.helpers.match_endpoint import match_endpoint


class ReporterConfig:
class ServiceConfig:
"""Class holding the config of the reporter"""

def __init__(self, endpoints, last_updated_at):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .reporter_config import ReporterConfig
from .service_config import ServiceConfig


def test_reporter_config_initialization():
def test_service_config_initialization():
endpoints = [
{
"graphql": False,
Expand Down Expand Up @@ -38,10 +38,10 @@ def test_reporter_config_initialization():
},
]
last_updated_at = "2023-10-01"
reporter_config = ReporterConfig(endpoints, last_updated_at)
service_config = ServiceConfig(endpoints, last_updated_at)

# Check that non-GraphQL endpoints are correctly filtered
assert len(reporter_config.endpoints) == 2
assert reporter_config.endpoints[0]["route"] == "/v1"
assert reporter_config.endpoints[1]["route"] == "/v3"
assert reporter_config.last_updated_at == last_updated_at
assert len(service_config.endpoints) == 2
assert service_config.endpoints[0]["route"] == "/v1"
assert service_config.endpoints[1]["route"] == "/v3"
assert service_config.last_updated_at == last_updated_at
Loading