Skip to content

Commit

Permalink
Fixing search integ test
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Palis <[email protected]>
  • Loading branch information
joshpalis committed Feb 9, 2024
1 parent f79ee21 commit 699ae0a
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
package org.opensearch.flowframework.rest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
Expand All @@ -26,7 +28,6 @@
import org.junit.ComparisonFailure;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand All @@ -36,11 +37,11 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import static org.opensearch.flowframework.common.CommonValue.CREDENTIAL_FIELD;
import static org.opensearch.flowframework.common.CommonValue.PROVISION_WORKFLOW;
import static org.opensearch.flowframework.common.CommonValue.WORKFLOW_ID;

public class FlowFrameworkRestApiIT extends FlowFrameworkRestTestCase {
private static final Logger logger = LogManager.getLogger(FlowFrameworkRestApiIT.class);

private static AtomicBoolean waitToStart = new AtomicBoolean(true);

Expand Down Expand Up @@ -69,19 +70,6 @@ public void testSearchWorkflows() throws Exception {
String termIdQuery = "{\"query\":{\"ids\":{\"values\":[\"" + workflowId + "\"]}}}";
SearchResponse searchResponse = searchWorkflows(client(), termIdQuery);
assertEquals(1, searchResponse.getHits().getTotalHits().value);

String searchHitSource = searchResponse.getHits().getAt(0).getSourceAsString();
Template searchHitTemplate = Template.parse(searchHitSource);

// Confirm that credentials have been encrypted within the search response
List<WorkflowNode> provisionNodes = searchHitTemplate.workflows().get(PROVISION_WORKFLOW).nodes();
for (WorkflowNode node : provisionNodes) {
if (node.type().equals("create_connector")) {
@SuppressWarnings("unchecked")
Map<String, String> credentialMap = new HashMap<>((Map<String, String>) node.userInputs().get(CREDENTIAL_FIELD));
assertTrue(credentialMap.values().stream().allMatch(x -> x != "12345"));
}
}
}

public void testFailedUpdateWorkflow() throws Exception {
Expand Down

0 comments on commit 699ae0a

Please sign in to comment.