From f883a6a5d97c6d5aa4529a09c2202c3856e59d45 Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala <snistala@amazon.com> Date: Mon, 17 Jul 2023 15:44:09 -0700 Subject: [PATCH] fix password argument in SecureRestClientBuilder constructor for SecureWorkflowRestApiIT (#1041) * fix password argument in SecureRestClientBuilder constructor for SecureWorkflowRestApiIT Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * fix tests to account for AUDIT alerts Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> --------- Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> (cherry picked from commit e4fae0e9cbbd1c256e2a90dea908362378430520) --- .../resthandler/SecureWorkflowRestApiIT.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt index 7a07c5df4..8ac6513ac 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt @@ -82,7 +82,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { fun create() { if (userClient == null) { createUser(user, arrayOf()) - userClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), user, user).setSocketTimeout(60000).build() + userClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), user, password).setSocketTimeout(60000).build() } } @@ -369,7 +369,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { listOf("role2"), getClusterPermissionsFromCustomRole(ALERTING_GET_WORKFLOW_ACCESS) ) - val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, getUser) + val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, password) .setSocketTimeout(60000).build() val getWorkflowResponse = getUserClient?.makeRequest( @@ -430,7 +430,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { ) val userWithDifferentRoleClient = SecureRestClientBuilder( - clusterHosts.toTypedArray(), isHttps(), userWithDifferentRole, userWithDifferentRole + clusterHosts.toTypedArray(), isHttps(), userWithDifferentRole, password ) .setSocketTimeout(60000).build() @@ -625,7 +625,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { listOf("role2"), getClusterPermissionsFromCustomRole(ALERTING_GET_WORKFLOW_ACCESS) ) - val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, getUser) + val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, password) .setSocketTimeout(60000).build() val getWorkflowResponse = getUserClient?.makeRequest( @@ -786,7 +786,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { listOf("role2"), getClusterPermissionsFromCustomRole(ALERTING_GET_WORKFLOW_ACCESS) ) - val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, getUser) + val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, password) .setSocketTimeout(60000).build() val getWorkflowResponse = getUserClient?.makeRequest( @@ -846,7 +846,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { false ) - val updateUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), updateUser, updateUser) + val updateUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), updateUser, password) .setSocketTimeout(60000).build() val updatedWorkflow = updateWorkflowWithClient(updateUserClient, createdWorkflow, listOf("role5")) @@ -904,7 +904,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { listOf("role1", "role2"), getClusterPermissionsFromCustomRole(ALERTING_GET_WORKFLOW_ACCESS) ) - val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, getUser) + val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, password) .setSocketTimeout(60000).build() val getWorkflowResponse = getUserClient?.makeRequest( @@ -1074,7 +1074,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { getClusterPermissionsFromCustomRole(ALERTING_GET_WORKFLOW_ACCESS) ) ) - val deleteUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), deleteUser, deleteUser) + val deleteUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), deleteUser, password) .setSocketTimeout(60000).build() try { @@ -1407,10 +1407,10 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { try { executeWorkflow(workflowId = workflowResponse.id) val bucketAlerts = searchAlerts(bucketMonitor) - assertEquals("Incorrect number of alerts", 2, bucketAlerts.size) + assertEquals("Incorrect number of alerts", 0, bucketAlerts.size) val docAlerts = searchAlerts(docMonitor) - assertEquals("Incorrect number of alerts", 1, docAlerts.size) + assertEquals("Incorrect number of alerts", 0, docAlerts.size) } finally { deleteRoleAndRoleMapping(TEST_HR_ROLE) }