Skip to content

Commit a83b7a4

Browse files
authored
Add encoded/non-encoded auth method to x-pack unit tests (#18307)
1 parent 0b661d9 commit a83b7a4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

x-pack/spec/config_management/elasticsearch_source_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@
170170
expect { described_class.new(system_settings) }.to_not raise_error
171171
end
172172
end
173+
174+
context "when api_key is set (encoded or not)" do
175+
[
176+
{ desc: "non-encoded", value: "foo:bar" },
177+
{ desc: "encoded", value: Base64.strict_encode64("foo:bar") }
178+
].each do |api_key_case|
179+
context "with #{api_key_case[:desc]} api_key" do
180+
let(:settings) do
181+
{
182+
"xpack.management.enabled" => true,
183+
"xpack.management.pipeline.id" => "main",
184+
"xpack.management.elasticsearch.api_key" => api_key_case[:value],
185+
}
186+
end
187+
188+
it "will rely on #{api_key_case[:desc]} api_key for authentication" do
189+
# the http client used by xpack module is the same as the one used by the ES output plugin
190+
# and the HttpClientBuilder.setup_api_key method will handle both encoded and non-encoded api_key values.
191+
# These tests prevent future regressions if the plugin client is changed.
192+
expect { described_class.new(system_settings) }.to_not raise_error
193+
end
194+
end
195+
end
196+
end
173197
end
174198

175199
context "valid settings" do

0 commit comments

Comments
 (0)