From ea4f33b2ea033f021b3eebecdd32f07fa07c694d Mon Sep 17 00:00:00 2001 From: robooo Date: Fri, 7 Nov 2025 23:30:16 +0100 Subject: [PATCH 1/4] Update to 2.12.0 --- pyproject.toml | 2 +- src/ConfluentKafkaLibrary/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5b20dd2..d72dbcd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ requires-python = ">=3.8" dependencies = [ "robotframework >= 3.2.1", - "confluent-kafka == 2.11.1", + "confluent-kafka == 2.12.0", "requests >= 2.25.1", ] diff --git a/src/ConfluentKafkaLibrary/version.py b/src/ConfluentKafkaLibrary/version.py index 55b2885..5a041f9 100644 --- a/src/ConfluentKafkaLibrary/version.py +++ b/src/ConfluentKafkaLibrary/version.py @@ -1 +1 @@ -VERSION = '2.11.1.post1' +VERSION = '2.12.0.post1' From 0000636be7bdb7cd268653cff34269cf3e83ccb5 Mon Sep 17 00:00:00 2001 From: robooo Date: Sat, 8 Nov 2025 23:53:35 +0100 Subject: [PATCH 2/4] Fix dependencies --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d72dbcd..4a7fe99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ requires-python = ">=3.8" dependencies = [ "robotframework >= 3.2.1", - "confluent-kafka == 2.12.0", + "confluent-kafka == 2.12.2", "requests >= 2.25.1", ] @@ -36,6 +36,7 @@ avro = [ json = [ "jsonschema >= 3.2.0", "pyrsistent >= 0.20.0", + "orjson >= 3.10", ] protobuf = [ "protobuf >= 4.22.0", @@ -45,8 +46,8 @@ schemaregistry = [ "httpx>=0.26", "cachetools >= 5.5.0", "attrs >= 24.3.0", + "certifi", "authlib >= 1.0.0", - "orjson >= 3.10", ] all = [ "robotframework-confluentkafkalibrary[avro]", From 594cd8e6559fd122d80f563042122772bc0ea489 Mon Sep 17 00:00:00 2001 From: robooo Date: Sat, 8 Nov 2025 23:54:26 +0100 Subject: [PATCH 3/4] Update to 2.12.2 --- src/ConfluentKafkaLibrary/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ConfluentKafkaLibrary/version.py b/src/ConfluentKafkaLibrary/version.py index 5a041f9..c30bddd 100644 --- a/src/ConfluentKafkaLibrary/version.py +++ b/src/ConfluentKafkaLibrary/version.py @@ -1 +1 @@ -VERSION = '2.12.0.post1' +VERSION = '2.12.2.post1' From cb8ed77e878ae713f7df65e1b238f99d380e1a94 Mon Sep 17 00:00:00 2001 From: robooo Date: Mon, 10 Nov 2025 21:23:36 +0100 Subject: [PATCH 4/4] Add oauth test case --- .github/workflows/main.yml | 2 +- examples/docker-compose.yml | 1 - examples/oauth2_test.py | 46 +++++++++++++++++++++++++++++++++++++ examples/oauth_example.py | 11 --------- examples/test_oauth.robot | 35 +++++++++++++++------------- 5 files changed, 66 insertions(+), 29 deletions(-) create mode 100644 examples/oauth2_test.py delete mode 100644 examples/oauth_example.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index de0b4d2..e4504b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: - name: Show python version run: python3 --version - name: Execute tests - run: python3 -m robot -d ./docs examples/ + run: cd examples && python3 -m robot -d ../docs . - name: Archive test log if: ${{ always() }} uses: actions/upload-artifact@v4 diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml index 50c86bb..30da028 100644 --- a/examples/docker-compose.yml +++ b/examples/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: broker: image: confluentinc/cp-server:7.8.0 diff --git a/examples/oauth2_test.py b/examples/oauth2_test.py new file mode 100644 index 0000000..c36deeb --- /dev/null +++ b/examples/oauth2_test.py @@ -0,0 +1,46 @@ +import time +import functools +import json +from robot.libraries.BuiltIn import BuiltIn + + +def create_test_token(): + """Create a test OAuth2 token for unsecured testing""" + token_payload = { + "sub": "test-user", + "iss": "test-issuer", + "aud": "kafka", + "exp": int(time.time()) + 3600, + "iat": int(time.time()), + "scope": "kafka-producer kafka-consumer" + } + + import base64 + token_json = json.dumps(token_payload) + test_token = base64.b64encode(token_json.encode()).decode() + + return test_token + + +def oauth_cb_test_producer(oauth_config): + BuiltIn().set_global_variable("${SEEN_RF_OAUTH_CB_PRODUCER}", True) + test_token = create_test_token() + expiry_time = time.time() + 3600 + BuiltIn().log(f"Generated test token: {test_token[:50]}...") + return test_token, expiry_time + + +def oauth_cb_test_consumer(oauth_config): + BuiltIn().set_global_variable("${SEEN_RF_OAUTH_CB_CONSUMER}", True) + test_token = create_test_token() + expiry_time = time.time() + 3600 + + return test_token, expiry_time + + +def get_test_producer_token(oauth_config=None): + return functools.partial(oauth_cb_test_producer, oauth_config or {}) + + +def get_test_consumer_token(oauth_config=None): + return functools.partial(oauth_cb_test_consumer, oauth_config or {}) \ No newline at end of file diff --git a/examples/oauth_example.py b/examples/oauth_example.py deleted file mode 100644 index 585cacb..0000000 --- a/examples/oauth_example.py +++ /dev/null @@ -1,11 +0,0 @@ -import time -import functools -from robot.libraries.BuiltIn import BuiltIn - - -def oauth_cb(oauth_config): - BuiltIn().set_global_variable("${SEEN_RF_OAUTH_CB}", True) - return 'token', time.time() + 300.0 - -def get_token(oauth_config): - return functools.partial(oauth_cb, oauth_config) diff --git a/examples/test_oauth.robot b/examples/test_oauth.robot index 06d1178..815375b 100644 --- a/examples/test_oauth.robot +++ b/examples/test_oauth.robot @@ -1,29 +1,32 @@ *** Settings *** Library ConfluentKafkaLibrary -Library oauth_example +Library oauth2_test Library Collections Library String *** Variables *** -${SEEN_RF_OAUTH_CB} ${False} +${SEEN_RF_OAUTH_CB_PRODUCER} ${False} +${SEEN_RF_OAUTH_CB_CONSUMER} ${False} +${KAFKA_BOOTSTRAP_SERVERS} localhost:9092 +${TEST_TOPIC} oauth2-test-topic *** Test Cases *** -Example Oauth - [Documentation] Example of how to use OAUTH with library and call functools - ... via get_token function. For better handling there could be - ... some global variable which can be set inside of python lib. - ... Not executable right now, needs update env (issue #21). +Test OAuth2 Token Generation + ${test_token}= oauth2_test.create_test_token + Should Not Be Empty ${test_token} + ${producer_token_func}= oauth2_test.get_test_producer_token + ${consumer_token_func}= oauth2_test.get_test_consumer_token - Skip +Test OAuth2 Library Integration ${string_serializer}= Get String Serializer - ${value_serializer}= Get String Serializer - - # This returns: functools.partial(, 'configuration') - ${fun}= oauth_example.get_token configuration - - ${producer_id}= Create Producer key_serializer=${string_serializer} value_serializer=${value_serializer} legacy=${False} security.protocol=sasl_plaintext sasl.mechanisms=OAUTHBEARER oauth_cb=${fun} - - #... + ${oauth_func}= oauth2_test.get_test_producer_token + + ${status} ${error}= Run Keyword And Ignore Error + ... Create Producer localhost:9092 + ... oauth_cb=${oauth_func} + ... security.protocol=sasl_plaintext + ... sasl.mechanisms=OAUTHBEARER + Should Be Equal ${status} PASS \ No newline at end of file