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 9c0392ec71b..65832ce4b9d 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 @@ private PushBackStream doLocalMode(CommandLine cli, String expr) throws Exceptio String zkHost = SolrCLI.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' +}