Skip to content

Commit

Permalink
SOLR-17567: Fix auth issue in stream tests (#2877)
Browse files Browse the repository at this point in the history
* Fix auth issue in stream tests
* Add negative test for missing auth
  • Loading branch information
malliaridis authored Nov 20, 2024
1 parent 99ba2b9 commit 66a1680
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/cli/StreamTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ private PushBackStream doLocalMode(CommandLine cli, String expr) throws Exceptio
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;
Expand Down
16 changes: 15 additions & 1 deletion solr/packaging/test/test_stream.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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'
}

0 comments on commit 66a1680

Please sign in to comment.