This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
forked from zendesk/ruby-kafka
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_spec.rb
60 lines (52 loc) · 1.7 KB
/
client_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
describe Kafka::Client do
let(:logger) { LOGGER }
let(:kafka_brokers) { KAFKA_BROKERS }
let(:client_opts) do
{
seed_brokers: KAFKA_BROKERS,
client_id: "test",
logger: logger
}
end
describe ".new" do
context "when SASL SCRAM has been configured without ssl" do
before do
client_opts.update({
sasl_scram_username: "spec_username",
sasl_scram_password: "spec_password",
sasl_scram_mechanism: "sha256"
})
end
context "when sasl_over_ssl is unspecified" do
it "raises ArgumentError due to missing SSL config" do
expect {
described_class.new(**client_opts)
}.to raise_error(ArgumentError, /SASL authentication requires that SSL is configured/)
end
end
context "when sasl_over_ssl is true" do
before { client_opts.update(sasl_over_ssl: true) }
it "raises ArgumentError due to missing SSL config" do
expect {
described_class.new(**client_opts)
}.to raise_error(ArgumentError, /SASL authentication requires that SSL is configured/)
end
end
context "when sasl_over_ssl is false" do
before { client_opts.update(sasl_over_ssl: false) }
it "creates a new Kafka::Client object" do
expect { described_class.new(**client_opts) }.to_not raise_exception
end
end
end
end
describe "#deliver_message" do
subject(:client) { described_class.new(**client_opts) }
it "requires `topic` to be a String" do
expect {
client.deliver_message("hello", topic: :topic)
}.to raise_exception(NoMethodError, /to_str/)
end
end
end