From 73c67503cfc27c54816fe9f42cd10c49d50b1a84 Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Wed, 10 Apr 2024 09:52:17 -0700 Subject: [PATCH] download security keys only if -Dsecurity.enabled==true Signed-off-by: Varun Jain --- build.gradle | 15 +++++++++------ .../query/HybridQueryPhaseSearcherTests.java | 4 ---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 1bf27837c..8f5c67c63 100644 --- a/build.gradle +++ b/build.gradle @@ -76,12 +76,15 @@ ext { currentBundleVersion = opensearch_version.replace("-SNAPSHOT","") // Config below including files are copied from security demo configuration - ['esnode.pem', 'esnode-key.pem', 'root-ca.pem','kirk.pem','kirk-key.pem'].forEach { file -> - File local = Paths.get(opensearch_tmp_dir.absolutePath, file).toFile() - download.run { - src "https://raw.githubusercontent.com/opensearch-project/security/main/bwc-test/src/test/resources/security/" + file - dest local - overwrite false + runIntegTestWithSecurityPlugin= System.getProperty("security.enabled") + if (runIntegTestWithSecurityPlugin == "true"){ + ['esnode.pem', 'esnode-key.pem', 'root-ca.pem','kirk.pem','kirk-key.pem'].forEach { file -> + File local = Paths.get(opensearch_tmp_dir.absolutePath, file).toFile() + download.run { + src "https://raw.githubusercontent.com/opensearch-project/security/main/bwc-test/src/test/resources/security/" + file + dest local + overwrite false + } } } diff --git a/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java b/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java index e489b3c4a..6fbc86dea 100644 --- a/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java +++ b/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java @@ -462,7 +462,6 @@ public void testWrappedHybridQuery_whenHybridWrappedIntoBool_thenFail() { IndexMetadata indexMetadata = mock(IndexMetadata.class); when(indexMetadata.getIndex()).thenReturn(new Index(TEST_INDEX, INDEX_UUID.toString())); when(indexMetadata.getSettings()).thenReturn(Settings.EMPTY); - when(indexMetadata.getCustomData(eq(IndexMetadata.REMOTE_STORE_CUSTOM_KEY))).thenReturn(null); Settings settings = Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, Integer.toString(1)).build(); IndexSettings indexSettings = new IndexSettings(indexMetadata, settings); when(mockQueryShardContext.getIndexSettings()).thenReturn(indexSettings); @@ -570,7 +569,6 @@ public void testWrappedHybridQuery_whenHybridWrappedIntoBoolAndIncorrectStructur IndexMetadata indexMetadata = mock(IndexMetadata.class); when(indexMetadata.getIndex()).thenReturn(new Index(TEST_INDEX, INDEX_UUID.toString())); when(indexMetadata.getSettings()).thenReturn(Settings.EMPTY); - when(indexMetadata.getCustomData(eq(IndexMetadata.REMOTE_STORE_CUSTOM_KEY))).thenReturn(null); Settings settings = Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, Integer.toString(1)).build(); IndexSettings indexSettings = new IndexSettings(indexMetadata, settings); when(mockQueryShardContext.getIndexSettings()).thenReturn(indexSettings); @@ -638,7 +636,6 @@ public void testWrappedHybridQuery_whenHybridWrappedIntoBoolBecauseOfNested_then IndexMetadata indexMetadata = mock(IndexMetadata.class); when(indexMetadata.getIndex()).thenReturn(new Index(TEST_INDEX, INDEX_UUID.toString())); when(indexMetadata.getSettings()).thenReturn(Settings.EMPTY); - when(indexMetadata.getCustomData(eq(IndexMetadata.REMOTE_STORE_CUSTOM_KEY))).thenReturn(null); Settings settings = Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, Integer.toString(1)).build(); IndexSettings indexSettings = new IndexSettings(indexMetadata, settings); when(mockQueryShardContext.getIndexSettings()).thenReturn(indexSettings); @@ -781,7 +778,6 @@ public void testBoolQuery_whenTooManyNestedLevels_thenSuccess() { IndexMetadata indexMetadata = mock(IndexMetadata.class); when(indexMetadata.getIndex()).thenReturn(new Index(TEST_INDEX, INDEX_UUID.toString())); when(indexMetadata.getSettings()).thenReturn(Settings.EMPTY); - when(indexMetadata.getCustomData(eq(IndexMetadata.REMOTE_STORE_CUSTOM_KEY))).thenReturn(null); Settings settings = Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, Integer.toString(1)).build(); IndexSettings indexSettings = new IndexSettings(indexMetadata, settings); when(mockQueryShardContext.getIndexSettings()).thenReturn(indexSettings);