This is an automated email from the ASF dual-hosted git repository.
malliaridis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 66a16805be3 SOLR-17567: Fix auth issue in stream tests (#2877)
66a16805be3 is described below
commit 66a16805be3142705bcfdf22806d4c2b4720b1a1
Author: Christos Malliaridis <[email protected]>
AuthorDate: Wed Nov 20 13:26:01 2024 +0200
SOLR-17567: Fix auth issue in stream tests (#2877)
* Fix auth issue in stream tests
* Add negative test for missing auth
---
solr/core/src/java/org/apache/solr/cli/StreamTool.java | 2 +-
solr/packaging/test/test_stream.bats | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cli/StreamTool.java
b/solr/core/src/java/org/apache/solr/cli/StreamTool.java
index 512b678da0f..fba6c91809d 100644
--- a/solr/core/src/java/org/apache/solr/cli/StreamTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/StreamTool.java
@@ -256,9 +256,9 @@ public class StreamTool extends ToolBase {
String zkHost = CLIUtils.getZkHost(cli);
echoIfVerbose("Connecting to ZooKeeper at " + zkHost);
- solrClientCache.getCloudSolrClient(zkHost);
solrClientCache.setBasicAuthCredentials(
cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION));
+ solrClientCache.getCloudSolrClient(zkHost);
TupleStream stream;
PushBackStream pushBackStream;
diff --git a/solr/packaging/test/test_stream.bats
b/solr/packaging/test/test_stream.bats
index 63145522c79..b2f5072a3d8 100644
--- a/solr/packaging/test/test_stream.bats
+++ b/solr/packaging/test/test_stream.bats
@@ -20,7 +20,7 @@ load bats_helper
setup_file() {
common_clean_setup
solr start -e techproducts
- solr auth enable --type basicAuth --credentials name:password
+ solr auth enable --type basicAuth --credentials name:password
--solr-include-file /force/credentials/to/be/supplied
}
teardown_file() {
@@ -84,3 +84,17 @@ teardown() {
assert_output --partial 'Apple 60 GB iPod'
refute_output --partial 'ERROR'
}
+
+@test "searching solr without credentials fails with error" {
+
+ local solr_stream_file="${BATS_TEST_TMPDIR}/search.expr"
+ echo 'search(techproducts,' > "${solr_stream_file}"
+ echo 'q="name:memory",' >> "${solr_stream_file}"
+ echo 'fl="name,price",' >> "${solr_stream_file}"
+ echo 'sort="price desc"' >> "${solr_stream_file}"
+ echo ')' >> "${solr_stream_file}"
+
+ run ! solr stream --execution local --header ${solr_stream_file}
+
+ assert_output --partial 'ERROR'
+}