-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Properly load auth settings for producer/consumer (#27)
Common auth settings were ignored since 0.3.1.
- Loading branch information
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
Kafka implementation for Open edX event bus. | ||
""" | ||
|
||
__version__ = '0.4.1' | ||
__version__ = '0.4.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
Test common configuration loading. | ||
""" | ||
|
||
from unittest import TestCase | ||
|
||
from django.test.utils import override_settings | ||
|
||
from edx_event_bus_kafka import config | ||
|
||
# See https://github.com/openedx/event-bus-kafka/blob/main/docs/decisions/0005-optional-import-of-confluent-kafka.rst | ||
try: | ||
from confluent_kafka.schema_registry import SchemaRegistryClient | ||
except ImportError: # pragma: no cover | ||
pass | ||
|
||
|
||
class TestSchemaRegistryClient(TestCase): | ||
def test_unconfigured(self): | ||
assert config.create_schema_registry_client() is None | ||
|
||
def test_configured(self): | ||
with override_settings(EVENT_BUS_KAFKA_SCHEMA_REGISTRY_URL='http://localhost:12345'): | ||
assert isinstance(config.create_schema_registry_client(), SchemaRegistryClient) | ||
|
||
|
||
class TestCommonSettings(TestCase): | ||
def test_unconfigured(self): | ||
assert config.load_common_settings() is None | ||
|
||
def test_minimal(self): | ||
with override_settings( | ||
EVENT_BUS_KAFKA_BOOTSTRAP_SERVERS='http://localhost:54321', | ||
): | ||
assert config.load_common_settings() == { | ||
'bootstrap.servers': 'http://localhost:54321', | ||
} | ||
|
||
def test_full(self): | ||
with override_settings( | ||
EVENT_BUS_KAFKA_BOOTSTRAP_SERVERS='http://localhost:54321', | ||
EVENT_BUS_KAFKA_API_KEY='some_other_key', | ||
EVENT_BUS_KAFKA_API_SECRET='some_other_secret', | ||
): | ||
assert config.load_common_settings() == { | ||
'bootstrap.servers': 'http://localhost:54321', | ||
'sasl.mechanism': 'PLAIN', | ||
'security.protocol': 'SASL_SSL', | ||
'sasl.username': 'some_other_key', | ||
'sasl.password': 'some_other_secret', | ||
} |