@ohos-ports/confluentinc-kafka-javascript 1.10.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +457 -0
- package/LICENSE.kafkajs +31 -0
- package/LICENSE.node-rdkafka +25 -0
- package/LICENSE.txt +20 -0
- package/README.md +133 -0
- package/binding.gyp +184 -0
- package/build/Release/confluent-kafka-javascript.node +0 -0
- package/build/deps/librdkafka++.so.1 +0 -0
- package/build/deps/librdkafka.Makefile +6 -0
- package/build/deps/librdkafka.so.1 +0 -0
- package/build/deps/librdkafka.target.mk +55 -0
- package/deps/librdkafka/.clang-format +136 -0
- package/deps/librdkafka/.clang-format-cpp +103 -0
- package/deps/librdkafka/.dir-locals.el +10 -0
- package/deps/librdkafka/.formatignore +35 -0
- package/deps/librdkafka/.gdbmacros +19 -0
- package/deps/librdkafka/CHANGELOG.md +2477 -0
- package/deps/librdkafka/CMakeLists.txt +291 -0
- package/deps/librdkafka/CODE_OF_CONDUCT.md +46 -0
- package/deps/librdkafka/CONFIGURATION.md +212 -0
- package/deps/librdkafka/CONTRIBUTING.md +431 -0
- package/deps/librdkafka/Doxyfile +2375 -0
- package/deps/librdkafka/INTRODUCTION.md +2752 -0
- package/deps/librdkafka/LICENSE +26 -0
- package/deps/librdkafka/LICENSE.cjson +22 -0
- package/deps/librdkafka/LICENSE.crc32c +28 -0
- package/deps/librdkafka/LICENSE.fnv1a +18 -0
- package/deps/librdkafka/LICENSE.hdrhistogram +27 -0
- package/deps/librdkafka/LICENSE.lz4 +26 -0
- package/deps/librdkafka/LICENSE.murmur2 +25 -0
- package/deps/librdkafka/LICENSE.nanopb +22 -0
- package/deps/librdkafka/LICENSE.opentelemetry +203 -0
- package/deps/librdkafka/LICENSE.pycrc +23 -0
- package/deps/librdkafka/LICENSE.queue +31 -0
- package/deps/librdkafka/LICENSE.regexp +5 -0
- package/deps/librdkafka/LICENSE.snappy +36 -0
- package/deps/librdkafka/LICENSE.tinycthread +26 -0
- package/deps/librdkafka/LICENSE.wingetopt +49 -0
- package/deps/librdkafka/LICENSES.txt +625 -0
- package/deps/librdkafka/Makefile +125 -0
- package/deps/librdkafka/README.md +201 -0
- package/deps/librdkafka/README.win32 +26 -0
- package/deps/librdkafka/STATISTICS.md +624 -0
- package/deps/librdkafka/configure +214 -0
- package/deps/librdkafka/configure.self +341 -0
- package/deps/librdkafka/dev-conf.sh +123 -0
- package/deps/librdkafka/lds-gen.py +73 -0
- package/deps/librdkafka/mainpage.doxy +40 -0
- package/deps/librdkafka/mklove/Makefile.base +329 -0
- package/deps/librdkafka/mklove/modules/configure.atomics +144 -0
- package/deps/librdkafka/mklove/modules/configure.base +2484 -0
- package/deps/librdkafka/mklove/modules/configure.builtin +70 -0
- package/deps/librdkafka/mklove/modules/configure.cc +186 -0
- package/deps/librdkafka/mklove/modules/configure.cxx +8 -0
- package/deps/librdkafka/mklove/modules/configure.fileversion +65 -0
- package/deps/librdkafka/mklove/modules/configure.gitversion +29 -0
- package/deps/librdkafka/mklove/modules/configure.good_cflags +18 -0
- package/deps/librdkafka/mklove/modules/configure.host +132 -0
- package/deps/librdkafka/mklove/modules/configure.lib +49 -0
- package/deps/librdkafka/mklove/modules/configure.libcurl +99 -0
- package/deps/librdkafka/mklove/modules/configure.libsasl2 +36 -0
- package/deps/librdkafka/mklove/modules/configure.libssl +147 -0
- package/deps/librdkafka/mklove/modules/configure.libzstd +58 -0
- package/deps/librdkafka/mklove/modules/configure.parseversion +95 -0
- package/deps/librdkafka/mklove/modules/configure.pic +16 -0
- package/deps/librdkafka/mklove/modules/configure.socket +20 -0
- package/deps/librdkafka/mklove/modules/configure.zlib +61 -0
- package/deps/librdkafka/mklove/modules/patches/README.md +8 -0
- package/deps/librdkafka/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch +11 -0
- package/deps/librdkafka/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch +56 -0
- package/deps/librdkafka/service.yml +182 -0
- package/deps/librdkafka/src/CMakeLists.txt +379 -0
- package/deps/librdkafka/src/Makefile +105 -0
- package/deps/librdkafka/src/README.lz4.md +30 -0
- package/deps/librdkafka/src/cJSON.c +3191 -0
- package/deps/librdkafka/src/cJSON.h +306 -0
- package/deps/librdkafka/src/crc32c.c +430 -0
- package/deps/librdkafka/src/crc32c.h +38 -0
- package/deps/librdkafka/src/generate_proto.sh +66 -0
- package/deps/librdkafka/src/librdkafka_cgrp_synch.png +0 -0
- package/deps/librdkafka/src/lz4.c +2727 -0
- package/deps/librdkafka/src/lz4.h +842 -0
- package/deps/librdkafka/src/lz4frame.c +2078 -0
- package/deps/librdkafka/src/lz4frame.h +692 -0
- package/deps/librdkafka/src/lz4frame_static.h +47 -0
- package/deps/librdkafka/src/lz4hc.c +1631 -0
- package/deps/librdkafka/src/lz4hc.h +413 -0
- package/deps/librdkafka/src/nanopb/pb.h +917 -0
- package/deps/librdkafka/src/nanopb/pb_common.c +388 -0
- package/deps/librdkafka/src/nanopb/pb_common.h +49 -0
- package/deps/librdkafka/src/nanopb/pb_decode.c +1727 -0
- package/deps/librdkafka/src/nanopb/pb_decode.h +193 -0
- package/deps/librdkafka/src/nanopb/pb_encode.c +1000 -0
- package/deps/librdkafka/src/nanopb/pb_encode.h +185 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.c +32 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.h +170 -0
- package/deps/librdkafka/src/opentelemetry/metrics.options +2 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.c +67 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.h +966 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.c +12 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.h +58 -0
- package/deps/librdkafka/src/queue.h +850 -0
- package/deps/librdkafka/src/rd.h +592 -0
- package/deps/librdkafka/src/rdaddr.c +255 -0
- package/deps/librdkafka/src/rdaddr.h +202 -0
- package/deps/librdkafka/src/rdatomic.h +262 -0
- package/deps/librdkafka/src/rdavg.h +260 -0
- package/deps/librdkafka/src/rdavl.c +210 -0
- package/deps/librdkafka/src/rdavl.h +250 -0
- package/deps/librdkafka/src/rdbase64.c +200 -0
- package/deps/librdkafka/src/rdbase64.h +43 -0
- package/deps/librdkafka/src/rdbuf.c +1884 -0
- package/deps/librdkafka/src/rdbuf.h +375 -0
- package/deps/librdkafka/src/rdcrc32.c +114 -0
- package/deps/librdkafka/src/rdcrc32.h +170 -0
- package/deps/librdkafka/src/rddl.c +179 -0
- package/deps/librdkafka/src/rddl.h +43 -0
- package/deps/librdkafka/src/rdendian.h +175 -0
- package/deps/librdkafka/src/rdfloat.h +67 -0
- package/deps/librdkafka/src/rdfnv1a.c +113 -0
- package/deps/librdkafka/src/rdfnv1a.h +35 -0
- package/deps/librdkafka/src/rdgz.c +120 -0
- package/deps/librdkafka/src/rdgz.h +46 -0
- package/deps/librdkafka/src/rdhdrhistogram.c +721 -0
- package/deps/librdkafka/src/rdhdrhistogram.h +87 -0
- package/deps/librdkafka/src/rdhttp.c +831 -0
- package/deps/librdkafka/src/rdhttp.h +101 -0
- package/deps/librdkafka/src/rdinterval.h +177 -0
- package/deps/librdkafka/src/rdkafka.c +7287 -0
- package/deps/librdkafka/src/rdkafka.h +11795 -0
- package/deps/librdkafka/src/rdkafka_admin.c +10165 -0
- package/deps/librdkafka/src/rdkafka_admin.h +658 -0
- package/deps/librdkafka/src/rdkafka_assignment.c +1282 -0
- package/deps/librdkafka/src/rdkafka_assignment.h +73 -0
- package/deps/librdkafka/src/rdkafka_assignor.c +1800 -0
- package/deps/librdkafka/src/rdkafka_assignor.h +402 -0
- package/deps/librdkafka/src/rdkafka_aux.c +409 -0
- package/deps/librdkafka/src/rdkafka_aux.h +174 -0
- package/deps/librdkafka/src/rdkafka_background.c +222 -0
- package/deps/librdkafka/src/rdkafka_broker.c +6736 -0
- package/deps/librdkafka/src/rdkafka_broker.h +851 -0
- package/deps/librdkafka/src/rdkafka_buf.c +543 -0
- package/deps/librdkafka/src/rdkafka_buf.h +1525 -0
- package/deps/librdkafka/src/rdkafka_cert.c +576 -0
- package/deps/librdkafka/src/rdkafka_cert.h +62 -0
- package/deps/librdkafka/src/rdkafka_cgrp.c +8310 -0
- package/deps/librdkafka/src/rdkafka_cgrp.h +589 -0
- package/deps/librdkafka/src/rdkafka_conf.c +5177 -0
- package/deps/librdkafka/src/rdkafka_conf.h +746 -0
- package/deps/librdkafka/src/rdkafka_confval.h +97 -0
- package/deps/librdkafka/src/rdkafka_coord.c +623 -0
- package/deps/librdkafka/src/rdkafka_coord.h +132 -0
- package/deps/librdkafka/src/rdkafka_error.c +228 -0
- package/deps/librdkafka/src/rdkafka_error.h +80 -0
- package/deps/librdkafka/src/rdkafka_event.c +502 -0
- package/deps/librdkafka/src/rdkafka_event.h +126 -0
- package/deps/librdkafka/src/rdkafka_feature.c +898 -0
- package/deps/librdkafka/src/rdkafka_feature.h +104 -0
- package/deps/librdkafka/src/rdkafka_fetcher.c +3820 -0
- package/deps/librdkafka/src/rdkafka_fetcher.h +62 -0
- package/deps/librdkafka/src/rdkafka_header.c +220 -0
- package/deps/librdkafka/src/rdkafka_header.h +76 -0
- package/deps/librdkafka/src/rdkafka_idempotence.c +807 -0
- package/deps/librdkafka/src/rdkafka_idempotence.h +144 -0
- package/deps/librdkafka/src/rdkafka_int.h +1505 -0
- package/deps/librdkafka/src/rdkafka_interceptor.c +842 -0
- package/deps/librdkafka/src/rdkafka_interceptor.h +104 -0
- package/deps/librdkafka/src/rdkafka_lz4.c +450 -0
- package/deps/librdkafka/src/rdkafka_lz4.h +49 -0
- package/deps/librdkafka/src/rdkafka_metadata.c +2347 -0
- package/deps/librdkafka/src/rdkafka_metadata.h +350 -0
- package/deps/librdkafka/src/rdkafka_metadata_cache.c +1183 -0
- package/deps/librdkafka/src/rdkafka_mock.c +4514 -0
- package/deps/librdkafka/src/rdkafka_mock.h +867 -0
- package/deps/librdkafka/src/rdkafka_mock_cgrp.c +1877 -0
- package/deps/librdkafka/src/rdkafka_mock_handlers.c +5255 -0
- package/deps/librdkafka/src/rdkafka_mock_int.h +1005 -0
- package/deps/librdkafka/src/rdkafka_mock_sharegrp.c +1207 -0
- package/deps/librdkafka/src/rdkafka_msg.c +2619 -0
- package/deps/librdkafka/src/rdkafka_msg.h +629 -0
- package/deps/librdkafka/src/rdkafka_msgbatch.h +62 -0
- package/deps/librdkafka/src/rdkafka_msgset.h +105 -0
- package/deps/librdkafka/src/rdkafka_msgset_reader.c +2099 -0
- package/deps/librdkafka/src/rdkafka_msgset_writer.c +1474 -0
- package/deps/librdkafka/src/rdkafka_offset.c +1565 -0
- package/deps/librdkafka/src/rdkafka_offset.h +150 -0
- package/deps/librdkafka/src/rdkafka_op.c +1219 -0
- package/deps/librdkafka/src/rdkafka_op.h +1065 -0
- package/deps/librdkafka/src/rdkafka_partition.c +5109 -0
- package/deps/librdkafka/src/rdkafka_partition.h +1215 -0
- package/deps/librdkafka/src/rdkafka_pattern.c +228 -0
- package/deps/librdkafka/src/rdkafka_pattern.h +70 -0
- package/deps/librdkafka/src/rdkafka_plugin.c +213 -0
- package/deps/librdkafka/src/rdkafka_plugin.h +41 -0
- package/deps/librdkafka/src/rdkafka_proto.h +739 -0
- package/deps/librdkafka/src/rdkafka_protocol.h +131 -0
- package/deps/librdkafka/src/rdkafka_queue.c +1351 -0
- package/deps/librdkafka/src/rdkafka_queue.h +1235 -0
- package/deps/librdkafka/src/rdkafka_range_assignor.c +1748 -0
- package/deps/librdkafka/src/rdkafka_request.c +7298 -0
- package/deps/librdkafka/src/rdkafka_request.h +761 -0
- package/deps/librdkafka/src/rdkafka_roundrobin_assignor.c +123 -0
- package/deps/librdkafka/src/rdkafka_sasl.c +589 -0
- package/deps/librdkafka/src/rdkafka_sasl.h +63 -0
- package/deps/librdkafka/src/rdkafka_sasl_cyrus.c +722 -0
- package/deps/librdkafka/src/rdkafka_sasl_int.h +89 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.c +1833 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +1827 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_plain.c +142 -0
- package/deps/librdkafka/src/rdkafka_sasl_scram.c +858 -0
- package/deps/librdkafka/src/rdkafka_sasl_win32.c +550 -0
- package/deps/librdkafka/src/rdkafka_share_acknowledgement.c +1445 -0
- package/deps/librdkafka/src/rdkafka_share_acknowledgement.h +373 -0
- package/deps/librdkafka/src/rdkafka_ssl.c +2235 -0
- package/deps/librdkafka/src/rdkafka_ssl.h +86 -0
- package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4785 -0
- package/deps/librdkafka/src/rdkafka_subscription.c +411 -0
- package/deps/librdkafka/src/rdkafka_telemetry.c +761 -0
- package/deps/librdkafka/src/rdkafka_telemetry.h +52 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.c +1307 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.h +59 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.c +1309 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.h +459 -0
- package/deps/librdkafka/src/rdkafka_timer.c +407 -0
- package/deps/librdkafka/src/rdkafka_timer.h +117 -0
- package/deps/librdkafka/src/rdkafka_topic.c +2382 -0
- package/deps/librdkafka/src/rdkafka_topic.h +369 -0
- package/deps/librdkafka/src/rdkafka_transport.c +1309 -0
- package/deps/librdkafka/src/rdkafka_transport.h +99 -0
- package/deps/librdkafka/src/rdkafka_transport_int.h +100 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.c +3256 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.h +171 -0
- package/deps/librdkafka/src/rdkafka_zstd.c +226 -0
- package/deps/librdkafka/src/rdkafka_zstd.h +57 -0
- package/deps/librdkafka/src/rdlist.c +593 -0
- package/deps/librdkafka/src/rdlist.h +444 -0
- package/deps/librdkafka/src/rdlog.c +89 -0
- package/deps/librdkafka/src/rdlog.h +41 -0
- package/deps/librdkafka/src/rdmap.c +508 -0
- package/deps/librdkafka/src/rdmap.h +492 -0
- package/deps/librdkafka/src/rdmurmur2.c +167 -0
- package/deps/librdkafka/src/rdmurmur2.h +35 -0
- package/deps/librdkafka/src/rdports.c +61 -0
- package/deps/librdkafka/src/rdports.h +38 -0
- package/deps/librdkafka/src/rdposix.h +250 -0
- package/deps/librdkafka/src/rdrand.c +151 -0
- package/deps/librdkafka/src/rdrand.h +72 -0
- package/deps/librdkafka/src/rdregex.c +156 -0
- package/deps/librdkafka/src/rdregex.h +43 -0
- package/deps/librdkafka/src/rdsignal.h +57 -0
- package/deps/librdkafka/src/rdstring.c +645 -0
- package/deps/librdkafka/src/rdstring.h +98 -0
- package/deps/librdkafka/src/rdsysqueue.h +404 -0
- package/deps/librdkafka/src/rdtime.h +356 -0
- package/deps/librdkafka/src/rdtypes.h +86 -0
- package/deps/librdkafka/src/rdunittest.c +564 -0
- package/deps/librdkafka/src/rdunittest.h +232 -0
- package/deps/librdkafka/src/rdunittest_acknowledge.c +1177 -0
- package/deps/librdkafka/src/rdunittest_fetcher.c +1211 -0
- package/deps/librdkafka/src/rdunittest_msgset_errors.c +1521 -0
- package/deps/librdkafka/src/rdvarint.c +134 -0
- package/deps/librdkafka/src/rdvarint.h +165 -0
- package/deps/librdkafka/src/rdwin32.h +382 -0
- package/deps/librdkafka/src/rdxxhash.c +1030 -0
- package/deps/librdkafka/src/rdxxhash.h +328 -0
- package/deps/librdkafka/src/regexp.c +1352 -0
- package/deps/librdkafka/src/regexp.h +41 -0
- package/deps/librdkafka/src/snappy.c +1866 -0
- package/deps/librdkafka/src/snappy.h +62 -0
- package/deps/librdkafka/src/snappy_compat.h +138 -0
- package/deps/librdkafka/src/statistics_schema.json +444 -0
- package/deps/librdkafka/src/tinycthread.c +932 -0
- package/deps/librdkafka/src/tinycthread.h +503 -0
- package/deps/librdkafka/src/tinycthread_extra.c +210 -0
- package/deps/librdkafka/src/tinycthread_extra.h +218 -0
- package/deps/librdkafka/src/win32_config.h +58 -0
- package/deps/librdkafka/src-cpp/CMakeLists.txt +90 -0
- package/deps/librdkafka/src-cpp/ConfImpl.cpp +84 -0
- package/deps/librdkafka/src-cpp/ConsumerImpl.cpp +244 -0
- package/deps/librdkafka/src-cpp/HandleImpl.cpp +436 -0
- package/deps/librdkafka/src-cpp/HeadersImpl.cpp +48 -0
- package/deps/librdkafka/src-cpp/KafkaConsumerImpl.cpp +296 -0
- package/deps/librdkafka/src-cpp/Makefile +55 -0
- package/deps/librdkafka/src-cpp/MessageImpl.cpp +38 -0
- package/deps/librdkafka/src-cpp/MetadataImpl.cpp +170 -0
- package/deps/librdkafka/src-cpp/ProducerImpl.cpp +197 -0
- package/deps/librdkafka/src-cpp/QueueImpl.cpp +70 -0
- package/deps/librdkafka/src-cpp/README.md +16 -0
- package/deps/librdkafka/src-cpp/RdKafka.cpp +59 -0
- package/deps/librdkafka/src-cpp/TopicImpl.cpp +124 -0
- package/deps/librdkafka/src-cpp/TopicPartitionImpl.cpp +57 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp.h +3797 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp_int.h +1641 -0
- package/deps/librdkafka/tests/0000-unittests.c +72 -0
- package/deps/librdkafka/tests/0001-multiobj.c +102 -0
- package/deps/librdkafka/tests/0002-unkpart.c +244 -0
- package/deps/librdkafka/tests/0003-msgmaxsize.c +173 -0
- package/deps/librdkafka/tests/0004-conf.c +934 -0
- package/deps/librdkafka/tests/0005-order.c +133 -0
- package/deps/librdkafka/tests/0006-symbols.c +163 -0
- package/deps/librdkafka/tests/0007-autotopic.c +136 -0
- package/deps/librdkafka/tests/0008-reqacks.c +179 -0
- package/deps/librdkafka/tests/0009-mock_cluster.c +272 -0
- package/deps/librdkafka/tests/0011-produce_batch.c +753 -0
- package/deps/librdkafka/tests/0012-produce_consume.c +537 -0
- package/deps/librdkafka/tests/0013-null-msgs.c +473 -0
- package/deps/librdkafka/tests/0014-reconsume-191.c +512 -0
- package/deps/librdkafka/tests/0015-offset_seeks.c +172 -0
- package/deps/librdkafka/tests/0016-client_swname.c +181 -0
- package/deps/librdkafka/tests/0017-compression.c +140 -0
- package/deps/librdkafka/tests/0018-cgrp_term.c +444 -0
- package/deps/librdkafka/tests/0019-list_groups.c +289 -0
- package/deps/librdkafka/tests/0020-destroy_hang.c +162 -0
- package/deps/librdkafka/tests/0021-rkt_destroy.c +72 -0
- package/deps/librdkafka/tests/0022-consume_batch.c +331 -0
- package/deps/librdkafka/tests/0025-timers.c +147 -0
- package/deps/librdkafka/tests/0026-consume_pause.c +547 -0
- package/deps/librdkafka/tests/0028-long_topicnames.c +79 -0
- package/deps/librdkafka/tests/0029-assign_offset.c +202 -0
- package/deps/librdkafka/tests/0030-offset_commit.c +589 -0
- package/deps/librdkafka/tests/0031-get_offsets.c +235 -0
- package/deps/librdkafka/tests/0033-regex_subscribe.c +536 -0
- package/deps/librdkafka/tests/0034-offset_reset.c +398 -0
- package/deps/librdkafka/tests/0035-api_version.c +73 -0
- package/deps/librdkafka/tests/0036-partial_fetch.c +87 -0
- package/deps/librdkafka/tests/0037-destroy_hang_local.c +85 -0
- package/deps/librdkafka/tests/0038-performance.c +121 -0
- package/deps/librdkafka/tests/0039-event.c +284 -0
- package/deps/librdkafka/tests/0040-io_event.c +257 -0
- package/deps/librdkafka/tests/0041-fetch_max_bytes.c +97 -0
- package/deps/librdkafka/tests/0042-many_topics.c +252 -0
- package/deps/librdkafka/tests/0043-no_connection.c +77 -0
- package/deps/librdkafka/tests/0044-partition_cnt.c +94 -0
- package/deps/librdkafka/tests/0045-subscribe_update.c +1010 -0
- package/deps/librdkafka/tests/0046-rkt_cache.c +65 -0
- package/deps/librdkafka/tests/0047-partial_buf_tmout.c +98 -0
- package/deps/librdkafka/tests/0048-partitioner.c +283 -0
- package/deps/librdkafka/tests/0049-consume_conn_close.c +162 -0
- package/deps/librdkafka/tests/0050-subscribe_adds.c +145 -0
- package/deps/librdkafka/tests/0051-assign_adds.c +126 -0
- package/deps/librdkafka/tests/0052-msg_timestamps.c +238 -0
- package/deps/librdkafka/tests/0053-stats_cb.cpp +527 -0
- package/deps/librdkafka/tests/0054-offset_time.cpp +236 -0
- package/deps/librdkafka/tests/0055-producer_latency.c +539 -0
- package/deps/librdkafka/tests/0056-balanced_group_mt.c +315 -0
- package/deps/librdkafka/tests/0057-invalid_topic.cpp +112 -0
- package/deps/librdkafka/tests/0058-log.cpp +123 -0
- package/deps/librdkafka/tests/0059-bsearch.cpp +241 -0
- package/deps/librdkafka/tests/0060-op_prio.cpp +163 -0
- package/deps/librdkafka/tests/0061-consumer_lag.cpp +295 -0
- package/deps/librdkafka/tests/0062-stats_event.c +126 -0
- package/deps/librdkafka/tests/0063-clusterid.cpp +180 -0
- package/deps/librdkafka/tests/0064-interceptors.c +529 -0
- package/deps/librdkafka/tests/0065-yield.cpp +140 -0
- package/deps/librdkafka/tests/0066-plugins.cpp +143 -0
- package/deps/librdkafka/tests/0067-empty_topic.cpp +151 -0
- package/deps/librdkafka/tests/0068-produce_timeout.c +136 -0
- package/deps/librdkafka/tests/0069-consumer_add_parts.c +119 -0
- package/deps/librdkafka/tests/0070-null_empty.cpp +197 -0
- package/deps/librdkafka/tests/0072-headers_ut.c +448 -0
- package/deps/librdkafka/tests/0073-headers.c +381 -0
- package/deps/librdkafka/tests/0074-producev.c +87 -0
- package/deps/librdkafka/tests/0075-retry.c +290 -0
- package/deps/librdkafka/tests/0076-produce_retry.c +452 -0
- package/deps/librdkafka/tests/0077-compaction.c +366 -0
- package/deps/librdkafka/tests/0078-c_from_cpp.cpp +96 -0
- package/deps/librdkafka/tests/0079-fork.c +93 -0
- package/deps/librdkafka/tests/0080-admin_ut.c +3095 -0
- package/deps/librdkafka/tests/0081-admin.c +5633 -0
- package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +137 -0
- package/deps/librdkafka/tests/0083-cb_event.c +233 -0
- package/deps/librdkafka/tests/0084-destroy_flags.c +208 -0
- package/deps/librdkafka/tests/0085-headers.cpp +392 -0
- package/deps/librdkafka/tests/0086-purge.c +368 -0
- package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +162 -0
- package/deps/librdkafka/tests/0089-max_poll_interval.c +511 -0
- package/deps/librdkafka/tests/0090-idempotence.c +171 -0
- package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +295 -0
- package/deps/librdkafka/tests/0092-mixed_msgver.c +103 -0
- package/deps/librdkafka/tests/0093-holb.c +200 -0
- package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +231 -0
- package/deps/librdkafka/tests/0095-all_brokers_down.cpp +122 -0
- package/deps/librdkafka/tests/0097-ssl_verify.cpp +674 -0
- package/deps/librdkafka/tests/0098-consumer-txn.cpp +1218 -0
- package/deps/librdkafka/tests/0099-commit_metadata.c +194 -0
- package/deps/librdkafka/tests/0100-thread_interceptors.cpp +195 -0
- package/deps/librdkafka/tests/0101-fetch-from-follower.cpp +446 -0
- package/deps/librdkafka/tests/0102-static_group_rebalance.c +836 -0
- package/deps/librdkafka/tests/0103-transactions.c +1383 -0
- package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +625 -0
- package/deps/librdkafka/tests/0105-transactions_mock.c +3930 -0
- package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +318 -0
- package/deps/librdkafka/tests/0107-topic_recreate.c +259 -0
- package/deps/librdkafka/tests/0109-auto_create_topics.cpp +278 -0
- package/deps/librdkafka/tests/0110-batch_size.cpp +182 -0
- package/deps/librdkafka/tests/0111-delay_create_topics.cpp +127 -0
- package/deps/librdkafka/tests/0112-assign_unknown_part.c +87 -0
- package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +3473 -0
- package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +176 -0
- package/deps/librdkafka/tests/0115-producer_auth.cpp +182 -0
- package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +216 -0
- package/deps/librdkafka/tests/0117-mock_errors.c +331 -0
- package/deps/librdkafka/tests/0118-commit_rebalance.c +154 -0
- package/deps/librdkafka/tests/0119-consumer_auth.cpp +167 -0
- package/deps/librdkafka/tests/0120-asymmetric_subscription.c +185 -0
- package/deps/librdkafka/tests/0121-clusterid.c +115 -0
- package/deps/librdkafka/tests/0122-buffer_cleaning_after_rebalance.c +227 -0
- package/deps/librdkafka/tests/0123-connections_max_idle.c +98 -0
- package/deps/librdkafka/tests/0124-openssl_invalid_engine.c +69 -0
- package/deps/librdkafka/tests/0125-immediate_flush.c +144 -0
- package/deps/librdkafka/tests/0126-oauthbearer_oidc.c +1164 -0
- package/deps/librdkafka/tests/0127-fetch_queue_backoff.cpp +165 -0
- package/deps/librdkafka/tests/0128-sasl_callback_queue.cpp +217 -0
- package/deps/librdkafka/tests/0129-fetch_aborted_msgs.c +79 -0
- package/deps/librdkafka/tests/0130-store_offsets.c +178 -0
- package/deps/librdkafka/tests/0131-connect_timeout.c +81 -0
- package/deps/librdkafka/tests/0132-strategy_ordering.c +179 -0
- package/deps/librdkafka/tests/0133-ssl_keys.c +150 -0
- package/deps/librdkafka/tests/0134-ssl_provider.c +92 -0
- package/deps/librdkafka/tests/0135-sasl_credentials.cpp +279 -0
- package/deps/librdkafka/tests/0136-resolve_cb.c +181 -0
- package/deps/librdkafka/tests/0137-barrier_batch_consume.c +752 -0
- package/deps/librdkafka/tests/0138-admin_mock.c +281 -0
- package/deps/librdkafka/tests/0139-offset_validation_mock.c +950 -0
- package/deps/librdkafka/tests/0140-commit_metadata.cpp +108 -0
- package/deps/librdkafka/tests/0142-reauthentication.c +931 -0
- package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +552 -0
- package/deps/librdkafka/tests/0144-idempotence_mock.c +373 -0
- package/deps/librdkafka/tests/0145-pause_resume_mock.c +119 -0
- package/deps/librdkafka/tests/0146-metadata_mock.c +505 -0
- package/deps/librdkafka/tests/0147-consumer_group_consumer_mock.c +1210 -0
- package/deps/librdkafka/tests/0148-offset_fetch_commit_error_mock.c +569 -0
- package/deps/librdkafka/tests/0149-broker-same-host-port.c +140 -0
- package/deps/librdkafka/tests/0150-telemetry_mock.c +651 -0
- package/deps/librdkafka/tests/0151-purge-brokers.c +566 -0
- package/deps/librdkafka/tests/0152-rebootstrap.c +59 -0
- package/deps/librdkafka/tests/0153-memberid.c +128 -0
- package/deps/librdkafka/tests/0155-share_group_heartbeat_mock.c +2695 -0
- package/deps/librdkafka/tests/0156-share_consumer_fetch_mock.c +1551 -0
- package/deps/librdkafka/tests/0157-share_consumer_ack_mock.c +1788 -0
- package/deps/librdkafka/tests/0158-share_consumer_transactions_mock.c +467 -0
- package/deps/librdkafka/tests/0170-share_consumer_subscription.c +2192 -0
- package/deps/librdkafka/tests/0171-share_consumer_consume.c +2150 -0
- package/deps/librdkafka/tests/0172-share_consumer_acknowledge.c +1919 -0
- package/deps/librdkafka/tests/0173-share_consumer_commit_async.c +2735 -0
- package/deps/librdkafka/tests/0174-share_consumer_concurrency.c +1434 -0
- package/deps/librdkafka/tests/0175-share_consumer_groups.c +574 -0
- package/deps/librdkafka/tests/0176-share_consumer_commit_sync.c +2986 -0
- package/deps/librdkafka/tests/0177-share_consumer_transactions.c +1815 -0
- package/deps/librdkafka/tests/0178-share_consumer_close.c +2102 -0
- package/deps/librdkafka/tests/0179-share_consumer_destroy.c +2482 -0
- package/deps/librdkafka/tests/0180-share_consumer_config.c +1677 -0
- package/deps/librdkafka/tests/0181-share_consumer_topic_delete.c +354 -0
- package/deps/librdkafka/tests/0182-share_consumer_error_handling_mock.c +3358 -0
- package/deps/librdkafka/tests/0183-share_consumer_leader_change_mock.c +1234 -0
- package/deps/librdkafka/tests/0184-share_consumer_topic_recreate.c +1356 -0
- package/deps/librdkafka/tests/0185-share_consumer_max_poll_interval.c +557 -0
- package/deps/librdkafka/tests/0186-share_consumer_fatal_error.c +360 -0
- package/deps/librdkafka/tests/0190-share_consumer_telemetry.c +387 -0
- package/deps/librdkafka/tests/1000-unktopic.c +164 -0
- package/deps/librdkafka/tests/8000-idle.cpp +60 -0
- package/deps/librdkafka/tests/8001-fetch_from_follower_mock_manual.c +113 -0
- package/deps/librdkafka/tests/CMakeLists.txt +193 -0
- package/deps/librdkafka/tests/LibrdkafkaTestApp.py +291 -0
- package/deps/librdkafka/tests/Makefile +182 -0
- package/deps/librdkafka/tests/README.md +514 -0
- package/deps/librdkafka/tests/autotest.sh +33 -0
- package/deps/librdkafka/tests/backtrace.gdb +30 -0
- package/deps/librdkafka/tests/broker_version_tests.py +315 -0
- package/deps/librdkafka/tests/buildbox.sh +17 -0
- package/deps/librdkafka/tests/cleanup-checker-tests.sh +20 -0
- package/deps/librdkafka/tests/cluster_testing.py +203 -0
- package/deps/librdkafka/tests/delete-test-topics.sh +56 -0
- package/deps/librdkafka/tests/fixtures/oauthbearer/jwt_assertion_template.json +10 -0
- package/deps/librdkafka/tests/fixtures/ssl/Makefile +8 -0
- package/deps/librdkafka/tests/fixtures/ssl/README.md +13 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.intermediate.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.intermediate.pem +72 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +50 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.intermediate.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +168 -0
- package/deps/librdkafka/tests/fuzzers/Makefile +12 -0
- package/deps/librdkafka/tests/fuzzers/README.md +31 -0
- package/deps/librdkafka/tests/fuzzers/fuzz_regex.c +74 -0
- package/deps/librdkafka/tests/fuzzers/helpers.h +90 -0
- package/deps/librdkafka/tests/gen-ssl-certs.sh +165 -0
- package/deps/librdkafka/tests/interactive_broker_version.py +170 -0
- package/deps/librdkafka/tests/interceptor_test/CMakeLists.txt +16 -0
- package/deps/librdkafka/tests/interceptor_test/Makefile +22 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.c +314 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.h +54 -0
- package/deps/librdkafka/tests/java/IncrementalRebalanceCli.java +97 -0
- package/deps/librdkafka/tests/java/Makefile +13 -0
- package/deps/librdkafka/tests/java/Murmur2Cli.java +46 -0
- package/deps/librdkafka/tests/java/README.md +14 -0
- package/deps/librdkafka/tests/java/TransactionProducerCli.java +162 -0
- package/deps/librdkafka/tests/java/run-class.sh +11 -0
- package/deps/librdkafka/tests/librdkafka.suppressions +483 -0
- package/deps/librdkafka/tests/lz4_manual_test.sh +59 -0
- package/deps/librdkafka/tests/multi-broker-version-test.sh +50 -0
- package/deps/librdkafka/tests/parse-refcnt.sh +43 -0
- package/deps/librdkafka/tests/performance_plot.py +115 -0
- package/deps/librdkafka/tests/plugin_test/Makefile +19 -0
- package/deps/librdkafka/tests/plugin_test/plugin_test.c +58 -0
- package/deps/librdkafka/tests/requirements.txt +2 -0
- package/deps/librdkafka/tests/run-all-tests.sh +81 -0
- package/deps/librdkafka/tests/run-consumer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-producer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-test-batches.py +157 -0
- package/deps/librdkafka/tests/run-test.sh +141 -0
- package/deps/librdkafka/tests/rusage.c +249 -0
- package/deps/librdkafka/tests/sasl_test.py +289 -0
- package/deps/librdkafka/tests/scenarios/README.md +6 -0
- package/deps/librdkafka/tests/scenarios/ak23.json +6 -0
- package/deps/librdkafka/tests/scenarios/default.json +5 -0
- package/deps/librdkafka/tests/scenarios/noautocreate.json +5 -0
- package/deps/librdkafka/tests/share_telemetry_verify/share-otel-collector-config.yaml +28 -0
- package/deps/librdkafka/tests/sockem.c +801 -0
- package/deps/librdkafka/tests/sockem.h +85 -0
- package/deps/librdkafka/tests/sockem_ctrl.c +145 -0
- package/deps/librdkafka/tests/sockem_ctrl.h +61 -0
- package/deps/librdkafka/tests/test.c +8376 -0
- package/deps/librdkafka/tests/test.conf.example +27 -0
- package/deps/librdkafka/tests/test.h +1150 -0
- package/deps/librdkafka/tests/testcpp.cpp +131 -0
- package/deps/librdkafka/tests/testcpp.h +388 -0
- package/deps/librdkafka/tests/testshared.h +416 -0
- package/deps/librdkafka/tests/tools/README.md +4 -0
- package/deps/librdkafka/tests/tools/stats/README.md +21 -0
- package/deps/librdkafka/tests/tools/stats/filter.jq +42 -0
- package/deps/librdkafka/tests/tools/stats/graph.py +150 -0
- package/deps/librdkafka/tests/tools/stats/requirements.txt +3 -0
- package/deps/librdkafka/tests/tools/stats/to_csv.py +124 -0
- package/deps/librdkafka/tests/trivup/trivup-0.15.0.tar.gz +0 -0
- package/deps/librdkafka/tests/until-fail.sh +87 -0
- package/deps/librdkafka/tests/xxxx-assign_partition.c +122 -0
- package/deps/librdkafka/tests/xxxx-metadata.cpp +159 -0
- package/deps/librdkafka/vcpkg.json +23 -0
- package/deps/librdkafka/win32/README.md +5 -0
- package/deps/librdkafka/win32/build-package.bat +3 -0
- package/deps/librdkafka/win32/build.bat +19 -0
- package/deps/librdkafka/win32/common.vcxproj +84 -0
- package/deps/librdkafka/win32/interceptor_test/interceptor_test.vcxproj +87 -0
- package/deps/librdkafka/win32/librdkafka.autopkg.template +54 -0
- package/deps/librdkafka/win32/librdkafka.master.testing.targets +13 -0
- package/deps/librdkafka/win32/librdkafka.sln +226 -0
- package/deps/librdkafka/win32/librdkafka.vcxproj +282 -0
- package/deps/librdkafka/win32/librdkafkacpp/librdkafkacpp.vcxproj +104 -0
- package/deps/librdkafka/win32/msbuild.ps1 +58 -0
- package/deps/librdkafka/win32/openssl_engine_example/openssl_engine_example.vcxproj +132 -0
- package/deps/librdkafka/win32/package-zip.ps1 +46 -0
- package/deps/librdkafka/win32/packages/repositories.config +4 -0
- package/deps/librdkafka/win32/push-package.bat +4 -0
- package/deps/librdkafka/win32/rdkafka_complex_consumer_example_cpp/rdkafka_complex_consumer_example_cpp.vcxproj +67 -0
- package/deps/librdkafka/win32/rdkafka_example/rdkafka_example.vcxproj +97 -0
- package/deps/librdkafka/win32/rdkafka_performance/rdkafka_performance.vcxproj +97 -0
- package/deps/librdkafka/win32/setup-msys2.ps1 +47 -0
- package/deps/librdkafka/win32/setup-vcpkg.ps1 +34 -0
- package/deps/librdkafka/win32/tests/test.conf.example +25 -0
- package/deps/librdkafka/win32/tests/tests.vcxproj +278 -0
- package/deps/librdkafka/win32/win_ssl_cert_store/win_ssl_cert_store.vcxproj +132 -0
- package/deps/librdkafka/win32/wingetopt.c +564 -0
- package/deps/librdkafka/win32/wingetopt.h +101 -0
- package/deps/librdkafka/win32/wintime.h +33 -0
- package/deps/librdkafka.gyp +83 -0
- package/deps/windows-install.py +80 -0
- package/index.d.ts +3 -0
- package/lib/admin.js +732 -0
- package/lib/client.js +679 -0
- package/lib/error.js +501 -0
- package/lib/index.js +8 -0
- package/lib/kafka-consumer-stream.js +399 -0
- package/lib/kafka-consumer.js +798 -0
- package/lib/kafkajs/_admin.js +1052 -0
- package/lib/kafkajs/_common.js +887 -0
- package/lib/kafkajs/_consumer.js +2156 -0
- package/lib/kafkajs/_consumer_cache.js +310 -0
- package/lib/kafkajs/_error.js +298 -0
- package/lib/kafkajs/_kafka.js +125 -0
- package/lib/kafkajs/_linked-list.js +220 -0
- package/lib/kafkajs/_producer.js +863 -0
- package/lib/kafkajs/index.js +5 -0
- package/lib/producer/high-level-producer.js +400 -0
- package/lib/producer-stream.js +337 -0
- package/lib/producer.js +405 -0
- package/lib/rdkafka.js +44 -0
- package/lib/tools/ref-counter.js +53 -0
- package/lib/topic-partition.js +91 -0
- package/lib/topic.js +43 -0
- package/lib/util.js +55 -0
- package/librdkafka.js +12 -0
- package/package.json +85 -0
- package/shim/source_location +54 -0
- package/src/admin.cc +1597 -0
- package/src/admin.h +112 -0
- package/src/binding.cc +76 -0
- package/src/binding.h +25 -0
- package/src/callbacks.cc +676 -0
- package/src/callbacks.h +302 -0
- package/src/common.cc +1628 -0
- package/src/common.h +192 -0
- package/src/config.cc +219 -0
- package/src/config.h +61 -0
- package/src/connection.cc +703 -0
- package/src/connection.h +117 -0
- package/src/errors.cc +119 -0
- package/src/errors.h +60 -0
- package/src/kafka-consumer.cc +1539 -0
- package/src/kafka-consumer.h +147 -0
- package/src/producer.cc +917 -0
- package/src/producer.h +124 -0
- package/src/topic.cc +173 -0
- package/src/topic.h +54 -0
- package/src/workers.cc +1714 -0
- package/src/workers.h +690 -0
- package/types/config.d.ts +1269 -0
- package/types/errors.d.ts +373 -0
- package/types/kafkajs.d.ts +568 -0
- package/types/rdkafka.d.ts +571 -0
- package/util/configure.js +32 -0
- package/util/generate-docs.sh +18 -0
- package/util/get-env.js +6 -0
- package/util/test-compile.js +11 -0
- package/util/test-producer-delivery.js +100 -0
|
@@ -0,0 +1,1164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* librdkafka - Apache Kafka C library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2021-2022, Magnus Edenhill
|
|
5
|
+
* 2025, Confluent Inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions are met:
|
|
10
|
+
*
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
|
12
|
+
* this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
* and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
21
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#include "test.h"
|
|
31
|
+
/* Typical include path would be <librdkafka/rdkafka.h>, but this program
|
|
32
|
+
* is built from within the librdkafka source tree and thus differs. */
|
|
33
|
+
#include "rdkafka.h" /* for Kafka driver */
|
|
34
|
+
|
|
35
|
+
#define TEST_FIXTURES_FOLDER "./fixtures"
|
|
36
|
+
#define TEST_FIXTURES_OAUTHBEARER_FOLDER TEST_FIXTURES_FOLDER "/oauthbearer/"
|
|
37
|
+
#define TEST_FIXTURES_JWT_ASSERTION_TEMPLATE \
|
|
38
|
+
TEST_FIXTURES_OAUTHBEARER_FOLDER "jwt_assertion_template.json"
|
|
39
|
+
|
|
40
|
+
static rd_bool_t error_seen;
|
|
41
|
+
static rd_bool_t user_token_cb_called;
|
|
42
|
+
/**
|
|
43
|
+
* @brief After config OIDC, make sure the producer and consumer
|
|
44
|
+
* can work successfully.
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
static void
|
|
48
|
+
do_test_produce_consumer_with_OIDC(const char *test_name,
|
|
49
|
+
const rd_kafka_conf_t *base_conf) {
|
|
50
|
+
const char *topic;
|
|
51
|
+
uint64_t testid;
|
|
52
|
+
rd_kafka_t *p1;
|
|
53
|
+
rd_kafka_t *c1;
|
|
54
|
+
rd_kafka_conf_t *conf;
|
|
55
|
+
|
|
56
|
+
const char *url = test_getenv("VALID_OIDC_URL", NULL);
|
|
57
|
+
|
|
58
|
+
SUB_TEST("Test producer and consumer with oidc configuration: %s",
|
|
59
|
+
test_name);
|
|
60
|
+
|
|
61
|
+
if (!url) {
|
|
62
|
+
SUB_TEST_SKIP(
|
|
63
|
+
"VALID_OIDC_URL environment variable is not set\n");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
68
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", url);
|
|
69
|
+
|
|
70
|
+
testid = test_id_generate();
|
|
71
|
+
|
|
72
|
+
rd_kafka_conf_set_dr_msg_cb(conf, test_dr_msg_cb);
|
|
73
|
+
|
|
74
|
+
p1 = test_create_handle(RD_KAFKA_PRODUCER, rd_kafka_conf_dup(conf));
|
|
75
|
+
|
|
76
|
+
topic = test_mk_topic_name("0126-oauthbearer_oidc", 1);
|
|
77
|
+
test_create_topic_wait_exists(p1, topic, 1, 3, 5000);
|
|
78
|
+
TEST_SAY("Topic: %s is created\n", topic);
|
|
79
|
+
|
|
80
|
+
test_produce_msgs2(p1, topic, testid, 0, 0, 1, NULL, 0);
|
|
81
|
+
|
|
82
|
+
test_conf_set(conf, "auto.offset.reset", "earliest");
|
|
83
|
+
c1 = test_create_consumer(topic, NULL, conf, NULL);
|
|
84
|
+
test_consumer_subscribe(c1, topic);
|
|
85
|
+
|
|
86
|
+
/* Give it some time to trigger the token refresh. */
|
|
87
|
+
rd_usleep(5 * 1000 * 1000, NULL);
|
|
88
|
+
test_consumer_poll("OIDC.C1", c1, testid, 1, -1, 1, NULL);
|
|
89
|
+
|
|
90
|
+
test_consumer_close(c1);
|
|
91
|
+
|
|
92
|
+
rd_kafka_destroy(p1);
|
|
93
|
+
rd_kafka_destroy(c1);
|
|
94
|
+
SUB_TEST_PASS();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @brief After config OIDC, make sure the share consumer
|
|
100
|
+
* can work successfully.
|
|
101
|
+
*/
|
|
102
|
+
static void
|
|
103
|
+
do_test_produce_share_consumer_with_OIDC(const char *test_name,
|
|
104
|
+
const rd_kafka_conf_t *base_conf) {
|
|
105
|
+
const char *topic;
|
|
106
|
+
rd_kafka_t *p1;
|
|
107
|
+
rd_kafka_share_t *sc1;
|
|
108
|
+
rd_kafka_conf_t *conf;
|
|
109
|
+
rd_kafka_topic_partition_list_t *subs;
|
|
110
|
+
rd_kafka_messages_t *batch = NULL;
|
|
111
|
+
const char *grp_conf[] = {"share.auto.offset.reset", "SET", "earliest"};
|
|
112
|
+
int consumed = 0, attempts;
|
|
113
|
+
const int msg_cnt = 10;
|
|
114
|
+
|
|
115
|
+
const char *url = test_getenv("VALID_OIDC_URL", NULL);
|
|
116
|
+
|
|
117
|
+
SUB_TEST("Test share consumer with oidc configuration: %s", test_name);
|
|
118
|
+
|
|
119
|
+
if (!url) {
|
|
120
|
+
SUB_TEST_SKIP(
|
|
121
|
+
"VALID_OIDC_URL environment variable is not set\n");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
126
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", url);
|
|
127
|
+
|
|
128
|
+
rd_kafka_conf_set_dr_msg_cb(conf, test_dr_msg_cb);
|
|
129
|
+
|
|
130
|
+
p1 = test_create_handle(RD_KAFKA_PRODUCER, conf);
|
|
131
|
+
|
|
132
|
+
topic = test_mk_topic_name("0126-oauthbearer_oidc_share", 1);
|
|
133
|
+
test_create_topic_wait_exists(p1, topic, 1, 3, 5000);
|
|
134
|
+
TEST_SAY("Topic: %s is created\n", topic);
|
|
135
|
+
|
|
136
|
+
test_produce_msgs_easy(topic, 0, 0, msg_cnt);
|
|
137
|
+
|
|
138
|
+
/* Create share consumer (picks up SASL config from test_conf_init) */
|
|
139
|
+
sc1 = test_create_share_consumer("oidc-share-group", NULL);
|
|
140
|
+
|
|
141
|
+
/* Set group config for earliest offset */
|
|
142
|
+
test_IncrementalAlterConfigs_simple(p1, RD_KAFKA_RESOURCE_GROUP,
|
|
143
|
+
"oidc-share-group", grp_conf, 1);
|
|
144
|
+
|
|
145
|
+
/* Subscribe */
|
|
146
|
+
subs = rd_kafka_topic_partition_list_new(1);
|
|
147
|
+
rd_kafka_topic_partition_list_add(subs, topic, RD_KAFKA_PARTITION_UA);
|
|
148
|
+
rd_kafka_share_subscribe(sc1, subs);
|
|
149
|
+
rd_kafka_topic_partition_list_destroy(subs);
|
|
150
|
+
|
|
151
|
+
/* Give it some time to trigger the token refresh. */
|
|
152
|
+
rd_usleep(5 * 1000 * 1000, NULL);
|
|
153
|
+
|
|
154
|
+
/* Consume messages */
|
|
155
|
+
attempts = 50;
|
|
156
|
+
while (consumed < msg_cnt && attempts-- > 0) {
|
|
157
|
+
size_t rcvd = 0;
|
|
158
|
+
size_t m;
|
|
159
|
+
rd_kafka_error_t *err;
|
|
160
|
+
|
|
161
|
+
rd_kafka_messages_destroy(batch);
|
|
162
|
+
batch = NULL;
|
|
163
|
+
|
|
164
|
+
err = rd_kafka_share_poll(sc1, 3000, &batch);
|
|
165
|
+
if (err) {
|
|
166
|
+
rd_kafka_error_destroy(err);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
rcvd = rd_kafka_messages_count(batch);
|
|
171
|
+
for (m = 0; m < rcvd; m++) {
|
|
172
|
+
if (!rd_kafka_messages_get(batch, m)->err)
|
|
173
|
+
consumed++;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
rd_kafka_messages_destroy(batch);
|
|
177
|
+
batch = NULL;
|
|
178
|
+
|
|
179
|
+
TEST_ASSERT(consumed == msg_cnt, "Expected %d messages, consumed %d",
|
|
180
|
+
msg_cnt, consumed);
|
|
181
|
+
TEST_SAY("Share consumer consumed %d/%d messages with OIDC\n", consumed,
|
|
182
|
+
msg_cnt);
|
|
183
|
+
|
|
184
|
+
rd_kafka_share_consumer_close(sc1);
|
|
185
|
+
rd_kafka_share_destroy(sc1);
|
|
186
|
+
rd_kafka_destroy(p1);
|
|
187
|
+
SUB_TEST_PASS();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
static void
|
|
192
|
+
auth_error_cb(rd_kafka_t *rk, int err, const char *reason, void *opaque) {
|
|
193
|
+
if (err == RD_KAFKA_RESP_ERR__AUTHENTICATION ||
|
|
194
|
+
err == RD_KAFKA_RESP_ERR__ALL_BROKERS_DOWN) {
|
|
195
|
+
TEST_SAY("Expected error: %s: %s\n", rd_kafka_err2str(err),
|
|
196
|
+
reason);
|
|
197
|
+
error_seen = rd_true;
|
|
198
|
+
} else
|
|
199
|
+
TEST_FAIL("Unexpected error: %s: %s", rd_kafka_err2str(err),
|
|
200
|
+
reason);
|
|
201
|
+
rd_kafka_yield(rk);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @brief Test-only token-refresh callback used to verify that a
|
|
206
|
+
* user-registered callback pre-empts the built-in OIDC callbacks.
|
|
207
|
+
*/
|
|
208
|
+
static void user_token_refresh_cb(rd_kafka_t *rk,
|
|
209
|
+
const char *oauthbearer_config,
|
|
210
|
+
void *opaque) {
|
|
211
|
+
user_token_cb_called = rd_true;
|
|
212
|
+
rd_kafka_oauthbearer_set_token_failure(
|
|
213
|
+
rk, "aws_iam test user token refresh cb");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @brief After config OIDC, if the token is expired, make sure
|
|
219
|
+
* the authentication fail as expected.
|
|
220
|
+
*
|
|
221
|
+
*/
|
|
222
|
+
static void do_test_produce_consumer_with_OIDC_expired_token_should_fail(
|
|
223
|
+
const rd_kafka_conf_t *base_conf) {
|
|
224
|
+
rd_kafka_t *c1;
|
|
225
|
+
uint64_t testid;
|
|
226
|
+
rd_kafka_conf_t *conf;
|
|
227
|
+
|
|
228
|
+
const char *expired_url = test_getenv("EXPIRED_TOKEN_OIDC_URL", NULL);
|
|
229
|
+
|
|
230
|
+
SUB_TEST("Test OAUTHBEARER/OIDC failing with expired JWT");
|
|
231
|
+
|
|
232
|
+
if (!expired_url) {
|
|
233
|
+
SUB_TEST_SKIP(
|
|
234
|
+
"EXPIRED_TOKEN_OIDC_URL environment variable is not set\n");
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
239
|
+
|
|
240
|
+
error_seen = rd_false;
|
|
241
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", expired_url);
|
|
242
|
+
|
|
243
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
244
|
+
|
|
245
|
+
testid = test_id_generate();
|
|
246
|
+
|
|
247
|
+
c1 = test_create_consumer("OIDC.fail.C1", NULL, conf, NULL);
|
|
248
|
+
|
|
249
|
+
test_consumer_poll_no_msgs("OIDC.fail.C1", c1, testid, 10 * 1000);
|
|
250
|
+
TEST_ASSERT(error_seen);
|
|
251
|
+
|
|
252
|
+
test_consumer_close(c1);
|
|
253
|
+
rd_kafka_destroy(c1);
|
|
254
|
+
SUB_TEST_PASS();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @brief After config OIDC with expired token, make sure the share consumer
|
|
259
|
+
* authentication fails as expected.
|
|
260
|
+
*/
|
|
261
|
+
static void do_test_produce_share_consumer_with_OIDC_expired_token_should_fail(
|
|
262
|
+
const rd_kafka_conf_t *base_conf) {
|
|
263
|
+
rd_kafka_share_t *sc1;
|
|
264
|
+
rd_kafka_conf_t *conf;
|
|
265
|
+
rd_kafka_messages_t *batch = NULL;
|
|
266
|
+
size_t rcvd = 0;
|
|
267
|
+
rd_kafka_error_t *err;
|
|
268
|
+
rd_kafka_topic_partition_list_t *subs;
|
|
269
|
+
int attempts;
|
|
270
|
+
char errstr[512];
|
|
271
|
+
|
|
272
|
+
const char *expired_url = test_getenv("EXPIRED_TOKEN_OIDC_URL", NULL);
|
|
273
|
+
|
|
274
|
+
SUB_TEST(
|
|
275
|
+
"Test OAUTHBEARER/OIDC share consumer failing with "
|
|
276
|
+
"expired JWT");
|
|
277
|
+
|
|
278
|
+
if (!expired_url) {
|
|
279
|
+
SUB_TEST_SKIP(
|
|
280
|
+
"EXPIRED_TOKEN_OIDC_URL environment variable is not "
|
|
281
|
+
"set\n");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
286
|
+
|
|
287
|
+
error_seen = rd_false;
|
|
288
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", expired_url);
|
|
289
|
+
test_conf_set(conf, "group.id", "oidc-share-fail");
|
|
290
|
+
|
|
291
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
292
|
+
|
|
293
|
+
sc1 = rd_kafka_share_consumer_new(conf, errstr, sizeof(errstr));
|
|
294
|
+
TEST_ASSERT(sc1, "Failed to create share consumer: %s", errstr);
|
|
295
|
+
|
|
296
|
+
subs = rd_kafka_topic_partition_list_new(1);
|
|
297
|
+
rd_kafka_topic_partition_list_add(subs, "oidc-share-fail-topic",
|
|
298
|
+
RD_KAFKA_PARTITION_UA);
|
|
299
|
+
rd_kafka_share_subscribe(sc1, subs);
|
|
300
|
+
rd_kafka_topic_partition_list_destroy(subs);
|
|
301
|
+
|
|
302
|
+
attempts = 10;
|
|
303
|
+
while (!error_seen && attempts-- > 0) {
|
|
304
|
+
err = rd_kafka_share_poll(sc1, 3000, &batch);
|
|
305
|
+
if (err)
|
|
306
|
+
rd_kafka_error_destroy(err);
|
|
307
|
+
rcvd = rd_kafka_messages_count(batch);
|
|
308
|
+
TEST_ASSERT(rcvd == 0,
|
|
309
|
+
"Expected no messages with expired token, got %zu",
|
|
310
|
+
rcvd);
|
|
311
|
+
rd_kafka_messages_destroy(batch);
|
|
312
|
+
batch = NULL;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
TEST_ASSERT(error_seen,
|
|
316
|
+
"Expected authentication error for share consumer "
|
|
317
|
+
"with expired token");
|
|
318
|
+
|
|
319
|
+
rd_kafka_share_consumer_close(sc1);
|
|
320
|
+
rd_kafka_share_destroy(sc1);
|
|
321
|
+
SUB_TEST_PASS();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @brief After configiguring OIDC, make sure the
|
|
327
|
+
* authentication fails as expected.
|
|
328
|
+
*/
|
|
329
|
+
static void do_test_produce_consumer_with_OIDC_should_fail(
|
|
330
|
+
const char *test_name,
|
|
331
|
+
const rd_kafka_conf_t *base_conf) {
|
|
332
|
+
rd_kafka_t *c1;
|
|
333
|
+
uint64_t testid;
|
|
334
|
+
rd_kafka_conf_t *conf;
|
|
335
|
+
|
|
336
|
+
const char *url = test_getenv("VALID_OIDC_URL", NULL);
|
|
337
|
+
|
|
338
|
+
SUB_TEST("Test authentication failure with oidc configuration: %s",
|
|
339
|
+
test_name);
|
|
340
|
+
if (!url) {
|
|
341
|
+
SUB_TEST_SKIP(
|
|
342
|
+
"VALID_OIDC_URL environment variable is not set\n");
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
error_seen = rd_false;
|
|
347
|
+
|
|
348
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
349
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", url);
|
|
350
|
+
|
|
351
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
352
|
+
|
|
353
|
+
testid = test_id_generate();
|
|
354
|
+
|
|
355
|
+
c1 = test_create_consumer("OIDC.fail.C1", NULL, conf, NULL);
|
|
356
|
+
|
|
357
|
+
test_consumer_poll_no_msgs("OIDC.fail.C1", c1, testid, 5 * 1000);
|
|
358
|
+
|
|
359
|
+
TEST_ASSERT(error_seen);
|
|
360
|
+
|
|
361
|
+
test_consumer_close(c1);
|
|
362
|
+
rd_kafka_destroy(c1);
|
|
363
|
+
SUB_TEST_PASS();
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @brief After config OIDC, if the token endpoint is not valid, make sure the
|
|
368
|
+
* authentication fail as expected.
|
|
369
|
+
*
|
|
370
|
+
*/
|
|
371
|
+
static void
|
|
372
|
+
do_test_produce_consumer_with_OIDC_should_fail_invalid_token_endpoint(
|
|
373
|
+
const rd_kafka_conf_t *base_conf) {
|
|
374
|
+
rd_kafka_t *c1;
|
|
375
|
+
uint64_t testid;
|
|
376
|
+
rd_kafka_conf_t *conf;
|
|
377
|
+
|
|
378
|
+
const char *invalid_url = test_getenv("INVALID_OIDC_URL", NULL);
|
|
379
|
+
|
|
380
|
+
SUB_TEST("Test OAUTHBEARER/OIDC failing with invalid JWT");
|
|
381
|
+
|
|
382
|
+
if (!invalid_url) {
|
|
383
|
+
SUB_TEST_SKIP(
|
|
384
|
+
"INVALID_OIDC_URL environment variable is not set\n");
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
389
|
+
|
|
390
|
+
error_seen = rd_false;
|
|
391
|
+
|
|
392
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", invalid_url);
|
|
393
|
+
|
|
394
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
395
|
+
|
|
396
|
+
testid = test_id_generate();
|
|
397
|
+
|
|
398
|
+
c1 = test_create_consumer("OIDC.fail.C1", NULL, conf, NULL);
|
|
399
|
+
|
|
400
|
+
test_consumer_poll_no_msgs("OIDC.fail.C1", c1, testid, 10 * 1000);
|
|
401
|
+
|
|
402
|
+
TEST_ASSERT(error_seen);
|
|
403
|
+
|
|
404
|
+
test_consumer_close(c1);
|
|
405
|
+
rd_kafka_destroy(c1);
|
|
406
|
+
SUB_TEST_PASS();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* @brief After config OIDC with invalid token endpoint, make sure the
|
|
412
|
+
* share consumer authentication fails as expected.
|
|
413
|
+
*/
|
|
414
|
+
static void
|
|
415
|
+
do_test_produce_share_consumer_with_OIDC_should_fail_invalid_token_endpoint(
|
|
416
|
+
const rd_kafka_conf_t *base_conf) {
|
|
417
|
+
rd_kafka_share_t *sc1;
|
|
418
|
+
rd_kafka_conf_t *conf;
|
|
419
|
+
rd_kafka_messages_t *batch = NULL;
|
|
420
|
+
size_t rcvd = 0;
|
|
421
|
+
rd_kafka_error_t *err;
|
|
422
|
+
rd_kafka_topic_partition_list_t *subs;
|
|
423
|
+
int attempts;
|
|
424
|
+
char errstr[512];
|
|
425
|
+
|
|
426
|
+
const char *invalid_url = test_getenv("INVALID_OIDC_URL", NULL);
|
|
427
|
+
|
|
428
|
+
SUB_TEST(
|
|
429
|
+
"Test OAUTHBEARER/OIDC share consumer failing with "
|
|
430
|
+
"invalid JWT");
|
|
431
|
+
|
|
432
|
+
if (!invalid_url) {
|
|
433
|
+
SUB_TEST_SKIP(
|
|
434
|
+
"INVALID_OIDC_URL environment variable is not set\n");
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
439
|
+
|
|
440
|
+
error_seen = rd_false;
|
|
441
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", invalid_url);
|
|
442
|
+
test_conf_set(conf, "group.id", "oidc-share-fail-invalid");
|
|
443
|
+
|
|
444
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
445
|
+
|
|
446
|
+
sc1 = rd_kafka_share_consumer_new(conf, errstr, sizeof(errstr));
|
|
447
|
+
TEST_ASSERT(sc1, "Failed to create share consumer: %s", errstr);
|
|
448
|
+
|
|
449
|
+
subs = rd_kafka_topic_partition_list_new(1);
|
|
450
|
+
rd_kafka_topic_partition_list_add(subs, "oidc-share-fail-invalid-topic",
|
|
451
|
+
RD_KAFKA_PARTITION_UA);
|
|
452
|
+
rd_kafka_share_subscribe(sc1, subs);
|
|
453
|
+
rd_kafka_topic_partition_list_destroy(subs);
|
|
454
|
+
|
|
455
|
+
attempts = 10;
|
|
456
|
+
while (!error_seen && attempts-- > 0) {
|
|
457
|
+
err = rd_kafka_share_poll(sc1, 3000, &batch);
|
|
458
|
+
if (err)
|
|
459
|
+
rd_kafka_error_destroy(err);
|
|
460
|
+
rcvd = rd_kafka_messages_count(batch);
|
|
461
|
+
TEST_ASSERT(rcvd == 0,
|
|
462
|
+
"Expected no messages with invalid token "
|
|
463
|
+
"endpoint, got %zu",
|
|
464
|
+
rcvd);
|
|
465
|
+
rd_kafka_messages_destroy(batch);
|
|
466
|
+
batch = NULL;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
TEST_ASSERT(error_seen,
|
|
470
|
+
"Expected authentication error for share consumer "
|
|
471
|
+
"with invalid token endpoint");
|
|
472
|
+
|
|
473
|
+
rd_kafka_share_consumer_close(sc1);
|
|
474
|
+
rd_kafka_share_destroy(sc1);
|
|
475
|
+
SUB_TEST_PASS();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
typedef enum oidc_configuration_jwt_bearer_variation_t {
|
|
479
|
+
/** Use a private key file. */
|
|
480
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_FILE,
|
|
481
|
+
/** Use an encrypted private key file. */
|
|
482
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_FILE_ENCRYPTED,
|
|
483
|
+
/** Use a private key file
|
|
484
|
+
* set as a configuration property. */
|
|
485
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_STRING,
|
|
486
|
+
/** Use an encrypted private key file
|
|
487
|
+
* set as a configuration property. */
|
|
488
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_STRING_ENCRYPTED,
|
|
489
|
+
/** Use a private key file
|
|
490
|
+
* and a template for the JWT assertion. */
|
|
491
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_TEMPLATE_FILE,
|
|
492
|
+
/** Use a private key file and set the JOSE algorithm to ES256.
|
|
493
|
+
* This variation will fail as the private key is RSA in trivup */
|
|
494
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_JOSE_ALGORITHM_ES256,
|
|
495
|
+
/** Invalid scope */
|
|
496
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_INVALID_SCOPE,
|
|
497
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION__CNT
|
|
498
|
+
} oidc_configuration_jwt_bearer_variation_t;
|
|
499
|
+
|
|
500
|
+
#define OIDC_CONFIGURATION_JWT_BEARER_VARIATION__FIRST_FAILING \
|
|
501
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_JOSE_ALGORITHM_ES256
|
|
502
|
+
|
|
503
|
+
static const char *oidc_configuration_jwt_bearer_variation_name(
|
|
504
|
+
oidc_configuration_jwt_bearer_variation_t variation) {
|
|
505
|
+
rd_assert(
|
|
506
|
+
variation >=
|
|
507
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_FILE &&
|
|
508
|
+
variation < OIDC_CONFIGURATION_JWT_BEARER_VARIATION__CNT);
|
|
509
|
+
static const char *names[] = {
|
|
510
|
+
"private key file", "private key encrypted file",
|
|
511
|
+
"private key pem string", "private key encrypted pem string",
|
|
512
|
+
"template file", "JOSE algorithm ES256",
|
|
513
|
+
"invalid scope"};
|
|
514
|
+
return names[variation];
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
static rd_kafka_conf_t *oidc_configuration_jwt_bearer(
|
|
518
|
+
rd_kafka_conf_t *conf,
|
|
519
|
+
oidc_configuration_jwt_bearer_variation_t variation) {
|
|
520
|
+
char file_content[4096];
|
|
521
|
+
const char *private_key_file =
|
|
522
|
+
test_getenv("OAUTHBEARER_CLIENT_PRIVATE_KEY", NULL);
|
|
523
|
+
const char *private_key_encrypted_file =
|
|
524
|
+
test_getenv("OAUTHBEARER_CLIENT_PRIVATE_KEY_ENCRYPTED", NULL);
|
|
525
|
+
const char *private_key_password =
|
|
526
|
+
test_getenv("OAUTHBEARER_CLIENT_PRIVATE_KEY_PASSWORD", NULL);
|
|
527
|
+
|
|
528
|
+
conf = rd_kafka_conf_dup(conf);
|
|
529
|
+
test_conf_set(conf, "sasl.oauthbearer.grant.type",
|
|
530
|
+
"urn:ietf:params:oauth:grant-type:jwt-bearer");
|
|
531
|
+
/* "sub" isn't mandatory if already defined in the template. */
|
|
532
|
+
if (variation != OIDC_CONFIGURATION_JWT_BEARER_VARIATION_TEMPLATE_FILE)
|
|
533
|
+
test_conf_set(conf, "sasl.oauthbearer.assertion.claim.sub",
|
|
534
|
+
"testuser");
|
|
535
|
+
else
|
|
536
|
+
test_conf_set(conf,
|
|
537
|
+
"sasl.oauthbearer.assertion.jwt.template.file",
|
|
538
|
+
TEST_FIXTURES_JWT_ASSERTION_TEMPLATE);
|
|
539
|
+
|
|
540
|
+
if (variation ==
|
|
541
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_JOSE_ALGORITHM_ES256)
|
|
542
|
+
test_conf_set(conf, "sasl.oauthbearer.assertion.algorithm",
|
|
543
|
+
"ES256");
|
|
544
|
+
if (variation == OIDC_CONFIGURATION_JWT_BEARER_VARIATION_INVALID_SCOPE)
|
|
545
|
+
test_conf_set(conf, "sasl.oauthbearer.scope", "invalid_scope");
|
|
546
|
+
|
|
547
|
+
switch (variation) {
|
|
548
|
+
case OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_FILE:
|
|
549
|
+
case OIDC_CONFIGURATION_JWT_BEARER_VARIATION_TEMPLATE_FILE:
|
|
550
|
+
case OIDC_CONFIGURATION_JWT_BEARER_VARIATION_JOSE_ALGORITHM_ES256:
|
|
551
|
+
case OIDC_CONFIGURATION_JWT_BEARER_VARIATION_INVALID_SCOPE:
|
|
552
|
+
if (!private_key_file)
|
|
553
|
+
goto fail;
|
|
554
|
+
|
|
555
|
+
test_conf_set(conf,
|
|
556
|
+
"sasl.oauthbearer.assertion.private.key.file",
|
|
557
|
+
private_key_file);
|
|
558
|
+
break;
|
|
559
|
+
case OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_FILE_ENCRYPTED:
|
|
560
|
+
if (!private_key_encrypted_file || !private_key_password)
|
|
561
|
+
goto fail;
|
|
562
|
+
test_conf_set(conf,
|
|
563
|
+
"sasl.oauthbearer.assertion.private.key.file",
|
|
564
|
+
private_key_encrypted_file);
|
|
565
|
+
test_conf_set(
|
|
566
|
+
conf, "sasl.oauthbearer.assertion.private.key.passphrase",
|
|
567
|
+
private_key_password);
|
|
568
|
+
break;
|
|
569
|
+
case OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_STRING:
|
|
570
|
+
if (!private_key_file)
|
|
571
|
+
goto fail;
|
|
572
|
+
TEST_ASSERT(test_read_file(private_key_file, file_content,
|
|
573
|
+
sizeof(file_content)) > 0);
|
|
574
|
+
|
|
575
|
+
test_conf_set(conf,
|
|
576
|
+
"sasl.oauthbearer.assertion.private.key.pem",
|
|
577
|
+
file_content);
|
|
578
|
+
break;
|
|
579
|
+
case OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_STRING_ENCRYPTED:
|
|
580
|
+
if (!private_key_encrypted_file || !private_key_password)
|
|
581
|
+
goto fail;
|
|
582
|
+
TEST_ASSERT(test_read_file(private_key_file, file_content,
|
|
583
|
+
sizeof(file_content)) > 0);
|
|
584
|
+
|
|
585
|
+
test_conf_set(conf,
|
|
586
|
+
"sasl.oauthbearer.assertion.private.key.pem",
|
|
587
|
+
file_content);
|
|
588
|
+
test_conf_set(
|
|
589
|
+
conf, "sasl.oauthbearer.assertion.private.key.passphrase",
|
|
590
|
+
private_key_password);
|
|
591
|
+
break;
|
|
592
|
+
default:
|
|
593
|
+
rd_assert(!*"Unknown OIDC JWT bearer test variation");
|
|
594
|
+
}
|
|
595
|
+
return conf;
|
|
596
|
+
fail:
|
|
597
|
+
rd_kafka_conf_destroy(conf);
|
|
598
|
+
TEST_WARN("Skipping OIDC JWT bearer test variation: %s",
|
|
599
|
+
oidc_configuration_jwt_bearer_variation_name(variation));
|
|
600
|
+
return NULL;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @brief Share consumer version of
|
|
605
|
+
* do_test_produce_consumer_with_OIDC_should_fail. Verifies authentication
|
|
606
|
+
* failure with share consumer.
|
|
607
|
+
*/
|
|
608
|
+
static void do_test_produce_share_consumer_with_OIDC_should_fail(
|
|
609
|
+
const char *test_name,
|
|
610
|
+
const rd_kafka_conf_t *base_conf) {
|
|
611
|
+
rd_kafka_share_t *sc1;
|
|
612
|
+
rd_kafka_conf_t *conf;
|
|
613
|
+
rd_kafka_messages_t *batch = NULL;
|
|
614
|
+
size_t rcvd = 0;
|
|
615
|
+
rd_kafka_error_t *err;
|
|
616
|
+
rd_kafka_topic_partition_list_t *subs;
|
|
617
|
+
int attempts;
|
|
618
|
+
char errstr[512];
|
|
619
|
+
|
|
620
|
+
const char *url = test_getenv("VALID_OIDC_URL", NULL);
|
|
621
|
+
|
|
622
|
+
SUB_TEST("Test share consumer auth failure with oidc configuration: %s",
|
|
623
|
+
test_name);
|
|
624
|
+
if (!url) {
|
|
625
|
+
SUB_TEST_SKIP(
|
|
626
|
+
"VALID_OIDC_URL environment variable is not set\n");
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
error_seen = rd_false;
|
|
631
|
+
|
|
632
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
633
|
+
test_conf_set(conf, "sasl.oauthbearer.token.endpoint.url", url);
|
|
634
|
+
test_conf_set(conf, "group.id", "oidc-share-should-fail");
|
|
635
|
+
|
|
636
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
637
|
+
|
|
638
|
+
sc1 = rd_kafka_share_consumer_new(conf, errstr, sizeof(errstr));
|
|
639
|
+
TEST_ASSERT(sc1, "Failed to create share consumer: %s", errstr);
|
|
640
|
+
|
|
641
|
+
subs = rd_kafka_topic_partition_list_new(1);
|
|
642
|
+
rd_kafka_topic_partition_list_add(subs, "oidc-share-should-fail-topic",
|
|
643
|
+
RD_KAFKA_PARTITION_UA);
|
|
644
|
+
rd_kafka_share_subscribe(sc1, subs);
|
|
645
|
+
rd_kafka_topic_partition_list_destroy(subs);
|
|
646
|
+
|
|
647
|
+
attempts = 10;
|
|
648
|
+
while (!error_seen && attempts-- > 0) {
|
|
649
|
+
err = rd_kafka_share_poll(sc1, 3000, &batch);
|
|
650
|
+
if (err)
|
|
651
|
+
rd_kafka_error_destroy(err);
|
|
652
|
+
rcvd = rd_kafka_messages_count(batch);
|
|
653
|
+
TEST_ASSERT(rcvd == 0,
|
|
654
|
+
"Expected no messages on auth failure, got %zu",
|
|
655
|
+
rcvd);
|
|
656
|
+
rd_kafka_messages_destroy(batch);
|
|
657
|
+
batch = NULL;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
TEST_ASSERT(error_seen,
|
|
661
|
+
"Expected authentication error for share consumer");
|
|
662
|
+
|
|
663
|
+
rd_kafka_share_consumer_close(sc1);
|
|
664
|
+
rd_kafka_share_destroy(sc1);
|
|
665
|
+
SUB_TEST_PASS();
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
void do_test_produce_consumer_with_OIDC_jwt_bearer(rd_kafka_conf_t *conf) {
|
|
670
|
+
rd_kafka_conf_t *jwt_bearer_conf;
|
|
671
|
+
oidc_configuration_jwt_bearer_variation_t variation;
|
|
672
|
+
for (variation =
|
|
673
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_FILE;
|
|
674
|
+
variation < OIDC_CONFIGURATION_JWT_BEARER_VARIATION__CNT;
|
|
675
|
+
variation++) {
|
|
676
|
+
const char *test_name;
|
|
677
|
+
jwt_bearer_conf =
|
|
678
|
+
oidc_configuration_jwt_bearer(conf, variation);
|
|
679
|
+
if (!jwt_bearer_conf)
|
|
680
|
+
continue;
|
|
681
|
+
|
|
682
|
+
test_name = tsprintf(
|
|
683
|
+
"JWT bearer: %s\n",
|
|
684
|
+
oidc_configuration_jwt_bearer_variation_name(variation));
|
|
685
|
+
|
|
686
|
+
if (variation <
|
|
687
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION__FIRST_FAILING)
|
|
688
|
+
do_test_produce_consumer_with_OIDC(test_name,
|
|
689
|
+
jwt_bearer_conf);
|
|
690
|
+
else
|
|
691
|
+
do_test_produce_consumer_with_OIDC_should_fail(
|
|
692
|
+
test_name, jwt_bearer_conf);
|
|
693
|
+
rd_kafka_conf_destroy(jwt_bearer_conf);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
void do_test_produce_share_consumer_with_OIDC_jwt_bearer(
|
|
698
|
+
rd_kafka_conf_t *conf) {
|
|
699
|
+
rd_kafka_conf_t *jwt_bearer_conf;
|
|
700
|
+
oidc_configuration_jwt_bearer_variation_t variation;
|
|
701
|
+
for (variation =
|
|
702
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION_PRIVATE_KEY_FILE;
|
|
703
|
+
variation < OIDC_CONFIGURATION_JWT_BEARER_VARIATION__CNT;
|
|
704
|
+
variation++) {
|
|
705
|
+
const char *test_name;
|
|
706
|
+
jwt_bearer_conf =
|
|
707
|
+
oidc_configuration_jwt_bearer(conf, variation);
|
|
708
|
+
if (!jwt_bearer_conf)
|
|
709
|
+
continue;
|
|
710
|
+
|
|
711
|
+
test_name = tsprintf(
|
|
712
|
+
"JWT bearer: %s\n",
|
|
713
|
+
oidc_configuration_jwt_bearer_variation_name(variation));
|
|
714
|
+
|
|
715
|
+
if (variation <
|
|
716
|
+
OIDC_CONFIGURATION_JWT_BEARER_VARIATION__FIRST_FAILING)
|
|
717
|
+
do_test_produce_share_consumer_with_OIDC(
|
|
718
|
+
test_name, jwt_bearer_conf);
|
|
719
|
+
else
|
|
720
|
+
do_test_produce_share_consumer_with_OIDC_should_fail(
|
|
721
|
+
test_name, jwt_bearer_conf);
|
|
722
|
+
rd_kafka_conf_destroy(jwt_bearer_conf);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
typedef enum oidc_configuration_metadata_authentication_variation_t {
|
|
728
|
+
/** Azure IMDS. Successful case. */
|
|
729
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_SUCCESS,
|
|
730
|
+
/** Azure IMDS. Missing client ID. */
|
|
731
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_MISSING_CLIENT_ID,
|
|
732
|
+
/** Azure IMDS. Missing resource parameter. */
|
|
733
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_MISSING_RESOURCE,
|
|
734
|
+
/** Azure IMDS. Missing API version. */
|
|
735
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_MISSING_API_VERSION,
|
|
736
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION__CNT
|
|
737
|
+
} oidc_configuration_metadata_authentication_variation_t;
|
|
738
|
+
|
|
739
|
+
#define OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION__FIRST_FAILING \
|
|
740
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_MISSING_CLIENT_ID
|
|
741
|
+
|
|
742
|
+
static const char *oidc_configuration_metadata_authentication_variation_name(
|
|
743
|
+
oidc_configuration_metadata_authentication_variation_t variation) {
|
|
744
|
+
rd_assert(
|
|
745
|
+
variation >=
|
|
746
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_SUCCESS &&
|
|
747
|
+
variation <
|
|
748
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION__CNT);
|
|
749
|
+
static const char *names[] = {
|
|
750
|
+
"Azure IMDS: success", "Azure IMDS: missing client ID",
|
|
751
|
+
"Azure IMDS: missing resource", "Azure IMDS: missing API version"};
|
|
752
|
+
return names[variation];
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
static rd_kafka_conf_t *oidc_configuration_metadata_authentication(
|
|
756
|
+
rd_kafka_conf_t *conf,
|
|
757
|
+
oidc_configuration_metadata_authentication_variation_t variation) {
|
|
758
|
+
conf = rd_kafka_conf_dup(conf);
|
|
759
|
+
switch (variation) {
|
|
760
|
+
case OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_SUCCESS:
|
|
761
|
+
test_conf_set(conf,
|
|
762
|
+
"sasl.oauthbearer.metadata.authentication.type",
|
|
763
|
+
"azure_imds");
|
|
764
|
+
test_conf_set(conf, "sasl.oauthbearer.config",
|
|
765
|
+
"query=__metadata_authentication_type=azure_imds&"
|
|
766
|
+
"api-version=2025-04-07&resource="
|
|
767
|
+
"api://external_resource_id&client_id=client_id");
|
|
768
|
+
break;
|
|
769
|
+
case OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_MISSING_CLIENT_ID:
|
|
770
|
+
test_conf_set(conf,
|
|
771
|
+
"sasl.oauthbearer.metadata.authentication.type",
|
|
772
|
+
"azure_imds");
|
|
773
|
+
test_conf_set(conf, "sasl.oauthbearer.config",
|
|
774
|
+
"query=__metadata_authentication_type=azure_imds&"
|
|
775
|
+
"api-version=2025-04-07&resource="
|
|
776
|
+
"api://external_resource_id");
|
|
777
|
+
break;
|
|
778
|
+
case OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_MISSING_RESOURCE:
|
|
779
|
+
test_conf_set(conf,
|
|
780
|
+
"sasl.oauthbearer.metadata.authentication.type",
|
|
781
|
+
"azure_imds");
|
|
782
|
+
test_conf_set(conf, "sasl.oauthbearer.config",
|
|
783
|
+
"query=__metadata_authentication_type=azure_imds&"
|
|
784
|
+
"api-version=2025-04-07&"
|
|
785
|
+
"client_id=client_id");
|
|
786
|
+
break;
|
|
787
|
+
case OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_MISSING_API_VERSION:
|
|
788
|
+
test_conf_set(conf,
|
|
789
|
+
"sasl.oauthbearer.metadata.authentication.type",
|
|
790
|
+
"azure_imds");
|
|
791
|
+
test_conf_set(conf, "sasl.oauthbearer.config",
|
|
792
|
+
"query=__metadata_authentication_type=azure_imds&"
|
|
793
|
+
"resource="
|
|
794
|
+
"api://external_resource_id&client_id=client_id");
|
|
795
|
+
break;
|
|
796
|
+
default:
|
|
797
|
+
TEST_ASSERT(rd_false,
|
|
798
|
+
"Unknown OIDC metadata authentication type");
|
|
799
|
+
}
|
|
800
|
+
return conf;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/* Test metadata-based authentication cases against Trivup. */
|
|
804
|
+
void do_test_produce_consumer_with_OIDC_metadata_authentication(
|
|
805
|
+
rd_kafka_conf_t *conf) {
|
|
806
|
+
rd_kafka_conf_t *metadata_authentication_conf;
|
|
807
|
+
oidc_configuration_metadata_authentication_variation_t variation;
|
|
808
|
+
for (
|
|
809
|
+
variation =
|
|
810
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_SUCCESS;
|
|
811
|
+
variation <
|
|
812
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION__CNT;
|
|
813
|
+
variation++) {
|
|
814
|
+
const char *test_name;
|
|
815
|
+
metadata_authentication_conf =
|
|
816
|
+
oidc_configuration_metadata_authentication(conf, variation);
|
|
817
|
+
|
|
818
|
+
test_name = tsprintf(
|
|
819
|
+
"Metadata authentication variation: %s\n",
|
|
820
|
+
oidc_configuration_metadata_authentication_variation_name(
|
|
821
|
+
variation));
|
|
822
|
+
|
|
823
|
+
if (variation <
|
|
824
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION__FIRST_FAILING)
|
|
825
|
+
do_test_produce_consumer_with_OIDC(
|
|
826
|
+
test_name, metadata_authentication_conf);
|
|
827
|
+
else
|
|
828
|
+
do_test_produce_consumer_with_OIDC_should_fail(
|
|
829
|
+
test_name, metadata_authentication_conf);
|
|
830
|
+
rd_kafka_conf_destroy(metadata_authentication_conf);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
void do_test_produce_share_consumer_with_OIDC_metadata_authentication(
|
|
835
|
+
rd_kafka_conf_t *conf) {
|
|
836
|
+
rd_kafka_conf_t *metadata_authentication_conf;
|
|
837
|
+
oidc_configuration_metadata_authentication_variation_t variation;
|
|
838
|
+
for (
|
|
839
|
+
variation =
|
|
840
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION_AZURE_IMDS_SUCCESS;
|
|
841
|
+
variation <
|
|
842
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION__CNT;
|
|
843
|
+
variation++) {
|
|
844
|
+
const char *test_name;
|
|
845
|
+
metadata_authentication_conf =
|
|
846
|
+
oidc_configuration_metadata_authentication(conf, variation);
|
|
847
|
+
|
|
848
|
+
test_name = tsprintf(
|
|
849
|
+
"Metadata authentication variation: %s\n",
|
|
850
|
+
oidc_configuration_metadata_authentication_variation_name(
|
|
851
|
+
variation));
|
|
852
|
+
|
|
853
|
+
if (variation <
|
|
854
|
+
OIDC_CONFIGURATION_METADATA_AUTHENTICATION_VARIATION__FIRST_FAILING)
|
|
855
|
+
do_test_produce_share_consumer_with_OIDC(
|
|
856
|
+
test_name, metadata_authentication_conf);
|
|
857
|
+
else
|
|
858
|
+
do_test_produce_share_consumer_with_OIDC_should_fail(
|
|
859
|
+
test_name, metadata_authentication_conf);
|
|
860
|
+
rd_kafka_conf_destroy(metadata_authentication_conf);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
typedef enum oidc_configuration_sub_claim_variation_t {
|
|
865
|
+
/** Use default "sub" claim (backward compatibility). */
|
|
866
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_DEFAULT_SUB,
|
|
867
|
+
/** Explicitly set "sub" as the claim name. */
|
|
868
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_EXPLICIT_SUB,
|
|
869
|
+
/** Use custom claim name "client_id". */
|
|
870
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_CUSTOM_CLIENT_ID,
|
|
871
|
+
/** Set empty string "" — resets to default "sub" per librdkafka string
|
|
872
|
+
semantics. */
|
|
873
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_EMPTY_STRING,
|
|
874
|
+
/** Use a claim name that doesn't exist in the token (should fail). */
|
|
875
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_MISSING_CLAIM,
|
|
876
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION__CNT
|
|
877
|
+
} oidc_configuration_sub_claim_variation_t;
|
|
878
|
+
|
|
879
|
+
#define OIDC_CONFIGURATION_SUB_CLAIM_VARIATION__FIRST_FAILING \
|
|
880
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_MISSING_CLAIM
|
|
881
|
+
|
|
882
|
+
static const char *oidc_configuration_sub_claim_variation_name(
|
|
883
|
+
oidc_configuration_sub_claim_variation_t variation) {
|
|
884
|
+
rd_assert(variation >=
|
|
885
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_DEFAULT_SUB &&
|
|
886
|
+
variation < OIDC_CONFIGURATION_SUB_CLAIM_VARIATION__CNT);
|
|
887
|
+
static const char *names[] = {
|
|
888
|
+
"default sub claim", "explicit sub claim", "custom client_id claim",
|
|
889
|
+
"empty string (defaults to sub)", "missing claim (should fail)"};
|
|
890
|
+
return names[variation];
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* @brief Configure OIDC with different subject claim name variations.
|
|
895
|
+
*
|
|
896
|
+
* Note: This test assumes the OIDC token provider returns tokens with
|
|
897
|
+
* standard claims including "sub" and "client_id".
|
|
898
|
+
* The test validates that librdkafka can extract the subject from
|
|
899
|
+
* different claims based on configuration.
|
|
900
|
+
*/
|
|
901
|
+
static rd_kafka_conf_t *oidc_configuration_sub_claim(
|
|
902
|
+
rd_kafka_conf_t *conf,
|
|
903
|
+
oidc_configuration_sub_claim_variation_t variation) {
|
|
904
|
+
conf = rd_kafka_conf_dup(conf);
|
|
905
|
+
|
|
906
|
+
switch (variation) {
|
|
907
|
+
case OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_DEFAULT_SUB:
|
|
908
|
+
break;
|
|
909
|
+
case OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_EXPLICIT_SUB:
|
|
910
|
+
test_conf_set(conf, "sasl.oauthbearer.sub.claim.name", "sub");
|
|
911
|
+
break;
|
|
912
|
+
case OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_CUSTOM_CLIENT_ID:
|
|
913
|
+
test_conf_set(conf, "sasl.oauthbearer.sub.claim.name",
|
|
914
|
+
"client_id");
|
|
915
|
+
break;
|
|
916
|
+
case OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_EMPTY_STRING:
|
|
917
|
+
test_conf_set(conf, "sasl.oauthbearer.sub.claim.name", "");
|
|
918
|
+
break;
|
|
919
|
+
case OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_MISSING_CLAIM:
|
|
920
|
+
test_conf_set(conf, "sasl.oauthbearer.sub.claim.name",
|
|
921
|
+
"nonexistent_claim");
|
|
922
|
+
break;
|
|
923
|
+
default:
|
|
924
|
+
rd_assert(!*"Unknown OIDC sub claim test variation");
|
|
925
|
+
}
|
|
926
|
+
return conf;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* @brief Test producer and consumer with different subject claim name
|
|
931
|
+
* configurations.
|
|
932
|
+
*
|
|
933
|
+
* This test validates KIP-768 parity for sasl.oauthbearer.sub.claim.name:
|
|
934
|
+
* - Default behavior uses "sub" claim
|
|
935
|
+
* - Custom claim names can be configured
|
|
936
|
+
* - Missing configured claim causes validation failure
|
|
937
|
+
* - Non-empty claim value is enforced
|
|
938
|
+
*/
|
|
939
|
+
void do_test_produce_consumer_with_OIDC_sub_claim(rd_kafka_conf_t *conf) {
|
|
940
|
+
rd_kafka_conf_t *sub_claim_conf;
|
|
941
|
+
oidc_configuration_sub_claim_variation_t variation;
|
|
942
|
+
|
|
943
|
+
const char *url = test_getenv("VALID_OIDC_URL", NULL);
|
|
944
|
+
|
|
945
|
+
/* Check if we should skip sub claim tests based on environment */
|
|
946
|
+
if (!url) {
|
|
947
|
+
SUB_TEST_SKIP(
|
|
948
|
+
"VALID_OIDC_URL environment variable is not set, "
|
|
949
|
+
"skipping sub claim tests\n");
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
for (variation = OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_DEFAULT_SUB;
|
|
954
|
+
variation < OIDC_CONFIGURATION_SUB_CLAIM_VARIATION__CNT;
|
|
955
|
+
variation++) {
|
|
956
|
+
const char *test_name;
|
|
957
|
+
sub_claim_conf = oidc_configuration_sub_claim(conf, variation);
|
|
958
|
+
|
|
959
|
+
test_name = tsprintf(
|
|
960
|
+
"Sub claim variation: %s\n",
|
|
961
|
+
oidc_configuration_sub_claim_variation_name(variation));
|
|
962
|
+
|
|
963
|
+
if (variation <
|
|
964
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION__FIRST_FAILING) {
|
|
965
|
+
/* These variations should succeed */
|
|
966
|
+
do_test_produce_consumer_with_OIDC(test_name,
|
|
967
|
+
sub_claim_conf);
|
|
968
|
+
} else {
|
|
969
|
+
/* These variations should fail */
|
|
970
|
+
do_test_produce_consumer_with_OIDC_should_fail(
|
|
971
|
+
test_name, sub_claim_conf);
|
|
972
|
+
}
|
|
973
|
+
rd_kafka_conf_destroy(sub_claim_conf);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
void do_test_produce_share_consumer_with_OIDC_sub_claim(rd_kafka_conf_t *conf) {
|
|
978
|
+
rd_kafka_conf_t *sub_claim_conf;
|
|
979
|
+
oidc_configuration_sub_claim_variation_t variation;
|
|
980
|
+
|
|
981
|
+
const char *url = test_getenv("VALID_OIDC_URL", NULL);
|
|
982
|
+
|
|
983
|
+
if (!url) {
|
|
984
|
+
SUB_TEST_SKIP(
|
|
985
|
+
"VALID_OIDC_URL environment variable is not set, "
|
|
986
|
+
"skipping share consumer sub claim tests\n");
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
for (variation = OIDC_CONFIGURATION_SUB_CLAIM_VARIATION_DEFAULT_SUB;
|
|
991
|
+
variation < OIDC_CONFIGURATION_SUB_CLAIM_VARIATION__CNT;
|
|
992
|
+
variation++) {
|
|
993
|
+
const char *test_name;
|
|
994
|
+
sub_claim_conf = oidc_configuration_sub_claim(conf, variation);
|
|
995
|
+
|
|
996
|
+
test_name = tsprintf(
|
|
997
|
+
"Sub claim variation: %s\n",
|
|
998
|
+
oidc_configuration_sub_claim_variation_name(variation));
|
|
999
|
+
|
|
1000
|
+
if (variation <
|
|
1001
|
+
OIDC_CONFIGURATION_SUB_CLAIM_VARIATION__FIRST_FAILING) {
|
|
1002
|
+
do_test_produce_share_consumer_with_OIDC(
|
|
1003
|
+
test_name, sub_claim_conf);
|
|
1004
|
+
} else {
|
|
1005
|
+
do_test_produce_share_consumer_with_OIDC_should_fail(
|
|
1006
|
+
test_name, sub_claim_conf);
|
|
1007
|
+
}
|
|
1008
|
+
rd_kafka_conf_destroy(sub_claim_conf);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* @brief aws_iam round-trips through rd_kafka_conf_set/get, confirming
|
|
1014
|
+
* the s2i wiring for the new enum value.
|
|
1015
|
+
*/
|
|
1016
|
+
static void do_test_OIDC_aws_iam_conf_roundtrip(void) {
|
|
1017
|
+
rd_kafka_conf_t *conf;
|
|
1018
|
+
char errstr[512];
|
|
1019
|
+
char value[64];
|
|
1020
|
+
size_t value_size = sizeof(value);
|
|
1021
|
+
|
|
1022
|
+
SUB_TEST("aws_iam round-trips through rd_kafka_conf_set/get");
|
|
1023
|
+
|
|
1024
|
+
conf = rd_kafka_conf_new();
|
|
1025
|
+
|
|
1026
|
+
TEST_ASSERT(rd_kafka_conf_set(
|
|
1027
|
+
conf, "sasl.oauthbearer.metadata.authentication.type",
|
|
1028
|
+
"aws_iam", errstr, sizeof(errstr)) == RD_KAFKA_CONF_OK,
|
|
1029
|
+
"Failed to set aws_iam: %s", errstr);
|
|
1030
|
+
|
|
1031
|
+
TEST_ASSERT(rd_kafka_conf_get(
|
|
1032
|
+
conf, "sasl.oauthbearer.metadata.authentication.type",
|
|
1033
|
+
value, &value_size) == RD_KAFKA_CONF_OK,
|
|
1034
|
+
"Failed to read aws_iam back from conf");
|
|
1035
|
+
TEST_ASSERT(strcmp(value, "aws_iam") == 0,
|
|
1036
|
+
"Expected 'aws_iam', got '%s'", value);
|
|
1037
|
+
|
|
1038
|
+
rd_kafka_conf_destroy(conf);
|
|
1039
|
+
SUB_TEST_PASS();
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* @brief When method=oidc and metadata.authentication.type=aws_iam
|
|
1044
|
+
* but no token-refresh callback is registered, the built-in
|
|
1045
|
+
* stub installed by librdkafka surfaces a token-refresh
|
|
1046
|
+
* failure rather than silently falling back to a different
|
|
1047
|
+
* OIDC flow.
|
|
1048
|
+
*/
|
|
1049
|
+
static void do_test_OIDC_aws_iam_stub_fires_without_callback(
|
|
1050
|
+
const rd_kafka_conf_t *base_conf) {
|
|
1051
|
+
rd_kafka_t *c1;
|
|
1052
|
+
uint64_t testid;
|
|
1053
|
+
rd_kafka_conf_t *conf;
|
|
1054
|
+
|
|
1055
|
+
SUB_TEST("aws_iam stub fails token refresh when no callback is set");
|
|
1056
|
+
|
|
1057
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
1058
|
+
test_conf_set(conf, "sasl.oauthbearer.metadata.authentication.type",
|
|
1059
|
+
"aws_iam");
|
|
1060
|
+
|
|
1061
|
+
error_seen = rd_false;
|
|
1062
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
1063
|
+
|
|
1064
|
+
testid = test_id_generate();
|
|
1065
|
+
|
|
1066
|
+
c1 = test_create_consumer("aws_iam.stub.C1", NULL, conf, NULL);
|
|
1067
|
+
|
|
1068
|
+
test_consumer_poll_no_msgs("aws_iam.stub.C1", c1, testid, 5 * 1000);
|
|
1069
|
+
TEST_ASSERT(error_seen,
|
|
1070
|
+
"Expected aws_iam stub to surface a token refresh "
|
|
1071
|
+
"failure");
|
|
1072
|
+
|
|
1073
|
+
test_consumer_close(c1);
|
|
1074
|
+
rd_kafka_destroy(c1);
|
|
1075
|
+
SUB_TEST_PASS();
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* @brief User-registered token refresh callback takes precedence over
|
|
1080
|
+
* the aws_iam stub.
|
|
1081
|
+
*/
|
|
1082
|
+
static void
|
|
1083
|
+
do_test_OIDC_aws_iam_user_callback_wins(const rd_kafka_conf_t *base_conf) {
|
|
1084
|
+
rd_kafka_t *c1;
|
|
1085
|
+
uint64_t testid;
|
|
1086
|
+
rd_kafka_conf_t *conf;
|
|
1087
|
+
|
|
1088
|
+
SUB_TEST(
|
|
1089
|
+
"aws_iam: user-registered token refresh callback wins over stub");
|
|
1090
|
+
|
|
1091
|
+
conf = rd_kafka_conf_dup(base_conf);
|
|
1092
|
+
test_conf_set(conf, "sasl.oauthbearer.metadata.authentication.type",
|
|
1093
|
+
"aws_iam");
|
|
1094
|
+
|
|
1095
|
+
rd_kafka_conf_set_oauthbearer_token_refresh_cb(conf,
|
|
1096
|
+
user_token_refresh_cb);
|
|
1097
|
+
|
|
1098
|
+
user_token_cb_called = rd_false;
|
|
1099
|
+
error_seen = rd_false;
|
|
1100
|
+
rd_kafka_conf_set_error_cb(conf, auth_error_cb);
|
|
1101
|
+
|
|
1102
|
+
testid = test_id_generate();
|
|
1103
|
+
|
|
1104
|
+
c1 = test_create_consumer("aws_iam.user_cb.C1", NULL, conf, NULL);
|
|
1105
|
+
|
|
1106
|
+
test_consumer_poll_no_msgs("aws_iam.user_cb.C1", c1, testid, 5 * 1000);
|
|
1107
|
+
TEST_ASSERT(user_token_cb_called,
|
|
1108
|
+
"Expected user-registered token refresh callback to "
|
|
1109
|
+
"fire instead of the aws_iam stub");
|
|
1110
|
+
TEST_ASSERT(error_seen,
|
|
1111
|
+
"Expected user-callback's set_token_failure to surface "
|
|
1112
|
+
"as an authentication error");
|
|
1113
|
+
|
|
1114
|
+
test_consumer_close(c1);
|
|
1115
|
+
rd_kafka_destroy(c1);
|
|
1116
|
+
SUB_TEST_PASS();
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
int main_0126_oauthbearer_oidc(int argc, char **argv) {
|
|
1120
|
+
rd_kafka_conf_t *conf;
|
|
1121
|
+
const char *sec;
|
|
1122
|
+
const char *oidc;
|
|
1123
|
+
|
|
1124
|
+
test_conf_init(&conf, NULL, 60);
|
|
1125
|
+
|
|
1126
|
+
sec = test_conf_get(conf, "security.protocol");
|
|
1127
|
+
if (!strstr(sec, "sasl")) {
|
|
1128
|
+
TEST_SKIP("Apache Kafka cluster not configured for SASL\n");
|
|
1129
|
+
rd_kafka_conf_destroy(conf);
|
|
1130
|
+
return 0;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
oidc = test_conf_get(conf, "sasl.oauthbearer.method");
|
|
1134
|
+
if (rd_strcasecmp(oidc, "OIDC")) {
|
|
1135
|
+
TEST_SKIP("`sasl.oauthbearer.method=OIDC` is required\n");
|
|
1136
|
+
rd_kafka_conf_destroy(conf);
|
|
1137
|
+
return 0;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
test_timeout_set(300);
|
|
1141
|
+
do_test_produce_consumer_with_OIDC("client_credentials", conf);
|
|
1142
|
+
do_test_produce_share_consumer_with_OIDC("client_credentials", conf);
|
|
1143
|
+
do_test_produce_consumer_with_OIDC_should_fail_invalid_token_endpoint(
|
|
1144
|
+
conf);
|
|
1145
|
+
do_test_produce_share_consumer_with_OIDC_should_fail_invalid_token_endpoint(
|
|
1146
|
+
conf);
|
|
1147
|
+
do_test_produce_consumer_with_OIDC_expired_token_should_fail(conf);
|
|
1148
|
+
do_test_produce_share_consumer_with_OIDC_expired_token_should_fail(
|
|
1149
|
+
conf);
|
|
1150
|
+
do_test_produce_consumer_with_OIDC_jwt_bearer(conf);
|
|
1151
|
+
do_test_produce_share_consumer_with_OIDC_jwt_bearer(conf);
|
|
1152
|
+
do_test_produce_consumer_with_OIDC_metadata_authentication(conf);
|
|
1153
|
+
do_test_produce_share_consumer_with_OIDC_metadata_authentication(conf);
|
|
1154
|
+
do_test_produce_consumer_with_OIDC_sub_claim(conf);
|
|
1155
|
+
do_test_produce_share_consumer_with_OIDC_sub_claim(conf);
|
|
1156
|
+
|
|
1157
|
+
do_test_OIDC_aws_iam_conf_roundtrip();
|
|
1158
|
+
do_test_OIDC_aws_iam_stub_fires_without_callback(conf);
|
|
1159
|
+
do_test_OIDC_aws_iam_user_callback_wins(conf);
|
|
1160
|
+
|
|
1161
|
+
rd_kafka_conf_destroy(conf);
|
|
1162
|
+
|
|
1163
|
+
return 0;
|
|
1164
|
+
}
|