From dc33dc7d3a2571404e983488dd1b91d82d0b3822 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 2 Apr 2024 23:52:12 +0000 Subject: [PATCH] Remove and refactor console statements Signed-off-by: Peter Nied --- .../dlic/auth/ldap/LdapBackendIntegTest.java | 9 +- .../dlic/auth/ldap/LdapBackendTest.java | 3 +- .../auth/ldap2/LdapBackendIntegTest2.java | 9 +- .../opensearch/security/AggregationTests.java | 9 +- .../org/opensearch/security/ConfigTests.java | 28 +- .../org/opensearch/security/HealthTests.java | 12 +- .../security/HttpIntegrationTests.java | 58 ++-- .../security/IndexIntegrationTests.java | 45 +-- .../InitializationIntegrationTests.java | 6 +- .../opensearch/security/IntegrationTests.java | 159 ++++------ .../security/SecurityAdminTests.java | 17 +- .../security/SnapshotRestoreTests.java | 3 +- .../org/opensearch/security/TaskTests.java | 3 +- .../org/opensearch/security/TracingTests.java | 211 +++++-------- .../TransportClientIntegrationTests.java | 150 +++------ .../auditlog/AbstractAuditlogiUnitTest.java | 6 +- .../compliance/ComplianceAuditlogTest.java | 2 +- .../RestApiComplianceAuditlogTest.java | 24 +- .../security/auditlog/impl/AuditlogTest.java | 3 +- .../auditlog/impl/DisabledCategoriesTest.java | 6 +- .../security/auditlog/impl/TracingTests.java | 168 ++++------- .../integration/BasicAuditlogTest.java | 57 ++-- .../auditlog/integration/SSLAuditlogTest.java | 9 +- .../auditlog/sink/SinkProviderTLSTest.java | 3 +- .../auditlog/sink/WebhookAuditLogTest.java | 9 +- .../security/cache/CachingTest.java | 30 +- .../ccstest/CrossClusterSearchTests.java | 285 ++++++------------ .../security/ccstest/RemoteReindexTests.java | 9 +- .../CustomFieldMaskedComplexMappingTest.java | 9 +- .../dlic/dlsfls/CustomFieldMaskedTest.java | 12 +- .../security/dlic/dlsfls/DateMathTest.java | 24 +- .../security/dlic/dlsfls/DlsDateMathTest.java | 12 +- .../dlsfls/DlsFlsCrossClusterSearchTest.java | 27 +- .../security/dlic/dlsfls/DlsNestedTest.java | 6 +- .../dlic/dlsfls/DlsPropsReplaceTest.java | 6 +- .../security/dlic/dlsfls/DlsTest.java | 3 +- .../security/dlic/dlsfls/Fls983Test.java | 3 +- .../security/dlic/dlsfls/FlsDlsTestAB.java | 12 +- .../dlic/dlsfls/FlsDlsTestForbiddenField.java | 3 +- .../dlic/dlsfls/FlsExistsFieldsTest.java | 6 +- .../security/dlic/dlsfls/FlsPerfTest.java | 12 +- .../security/dlic/dlsfls/FlsTest.java | 6 +- .../dlic/dlsfls/IndexPatternTest.java | 24 +- .../security/dlic/dlsfls/MFlsTest.java | 9 +- .../rest/api/AbstractRestApiUnitTest.java | 3 +- .../dlic/rest/api/AccountApiTest.java | 3 +- .../dlic/rest/api/IndexMissingTest.java | 3 +- .../dlic/rest/api/NodesDnApiTest.java | 3 +- .../security/dlic/rest/api/RolesApiTest.java | 12 +- .../security/dlic/rest/api/UserApiTest.java | 3 +- .../multitenancy/test/MultitenancyTests.java | 99 ++---- .../opensearch/security/ssl/OpenSSLTest.java | 6 +- .../org/opensearch/security/ssl/SSLTest.java | 32 +- .../security/test/helper/rest/RestHelper.java | 10 - .../helper/rules/SecurityTestWatcher.java | 6 +- 55 files changed, 579 insertions(+), 1108 deletions(-) diff --git a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java index 719ffb1214..5aebaa56e6 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java @@ -56,8 +56,7 @@ protected String getResourceFolder() { public void testIntegLdapAuthenticationSSL() throws Exception { String securityConfigAsYamlString = FileHelper.loadFile("ldap/config.yml"); securityConfigAsYamlString = securityConfigAsYamlString.replace("${ldapsPort}", String.valueOf(ldapsPort)); - System.out.println(securityConfigAsYamlString); - setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); + setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); final RestHelper rh = nonSslRestHelper(); Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("", encodeBasicHeader("jacksonm", "secret")).getStatusCode()); } @@ -66,8 +65,7 @@ public void testIntegLdapAuthenticationSSL() throws Exception { public void testIntegLdapAuthenticationSSLFail() throws Exception { String securityConfigAsYamlString = FileHelper.loadFile("ldap/config.yml"); securityConfigAsYamlString = securityConfigAsYamlString.replace("${ldapsPort}", String.valueOf(ldapsPort)); - System.out.println(securityConfigAsYamlString); - setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); + setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); final RestHelper rh = nonSslRestHelper(); final HttpResponse response = rh.executeGetRequest("", encodeBasicHeader("wrong", "wrong")); Assert.assertEquals(response.getBody(), HttpStatus.SC_UNAUTHORIZED, response.getStatusCode()); @@ -85,8 +83,7 @@ public void testAttributesWithImpersonation() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executeGetRequest("_opendistro/_security/authinfo", new BasicHeader("opendistro_security_impersonate_as", "jacksonm") ,encodeBasicHeader("spock", "spocksecret"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("ldap.dn")); + Assert.assertTrue(res.getBody().contains("ldap.dn")); Assert.assertTrue(res.getBody().contains("attr.ldap.entryDN")); Assert.assertTrue(res.getBody().contains("attr.ldap.subschemaSubentry")); diff --git a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java index 71c6a188ec..0fe6426a6f 100755 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java @@ -990,8 +990,7 @@ public void testMultiCn() throws Exception { .getBytes(StandardCharsets.UTF_8))); Assert.assertNotNull(user); Assert.assertEquals("cn=cabc,ou=people,o=TEST", user.getName()); - System.out.println(user.getUserEntry().getAttribute("cn")); - } + } @AfterClass diff --git a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java index 827aeb4d87..b3fed4da22 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java @@ -56,8 +56,7 @@ protected String getResourceFolder() { public void testIntegLdapAuthenticationSSL() throws Exception { String securityConfigAsYamlString = FileHelper.loadFile("ldap/config_ldap2.yml"); securityConfigAsYamlString = securityConfigAsYamlString.replace("${ldapsPort}", String.valueOf(ldapsPort)); - System.out.println(securityConfigAsYamlString); - setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); + setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); final RestHelper rh = nonSslRestHelper(); Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("", encodeBasicHeader("jacksonm", "secret")).getStatusCode()); } @@ -66,8 +65,7 @@ public void testIntegLdapAuthenticationSSL() throws Exception { public void testIntegLdapAuthenticationSSLFail() throws Exception { String securityConfigAsYamlString = FileHelper.loadFile("ldap/config_ldap2.yml"); securityConfigAsYamlString = securityConfigAsYamlString.replace("${ldapsPort}", String.valueOf(ldapsPort)); - System.out.println(securityConfigAsYamlString); - setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); + setup(Settings.EMPTY, new DynamicSecurityConfig().setConfigAsYamlString(securityConfigAsYamlString), Settings.EMPTY); final RestHelper rh = nonSslRestHelper(); Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, rh.executeGetRequest("", encodeBasicHeader("wrong", "wrong")).getStatusCode()); } @@ -84,8 +82,7 @@ public void testAttributesWithImpersonation() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executeGetRequest("_opendistro/_security/authinfo", new BasicHeader("opendistro_security_impersonate_as", "jacksonm") ,encodeBasicHeader("spock", "spocksecret"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("ldap.dn")); + Assert.assertTrue(res.getBody().contains("ldap.dn")); Assert.assertTrue(res.getBody().contains("attr.ldap.entryDN")); Assert.assertTrue(res.getBody().contains("attr.ldap.subschemaSubentry")); diff --git a/src/test/java/org/opensearch/security/AggregationTests.java b/src/test/java/org/opensearch/security/AggregationTests.java index 0a913ad3e0..859e4487dc 100644 --- a/src/test/java/org/opensearch/security/AggregationTests.java +++ b/src/test/java/org/opensearch/security/AggregationTests.java @@ -81,8 +81,7 @@ public void testBasicAggregations() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_search?pretty", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(res.getBody()); - assertNotContains(res, "*xception*"); + assertNotContains(res, "*xception*"); assertNotContains(res, "*erial*"); assertNotContains(res, "*mpty*"); assertNotContains(res, "*pendistro_security*"); @@ -94,8 +93,7 @@ public void testBasicAggregations() throws Exception { assertContains(res, "*\"failed\" : 0*"); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("*/_search?pretty", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(res.getBody()); - assertNotContains(res, "*xception*"); + assertNotContains(res, "*xception*"); assertNotContains(res, "*erial*"); assertNotContains(res, "*mpty*"); assertNotContains(res, "*pendistro_security*"); @@ -107,8 +105,7 @@ public void testBasicAggregations() throws Exception { assertContains(res, "*\"failed\" : 0*"); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_search?pretty", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("worf", "worf"))).getStatusCode()); - System.out.println(res.getBody()); - assertNotContains(res, "*xception*"); + assertNotContains(res, "*xception*"); assertNotContains(res, "*erial*"); assertNotContains(res, "*mpty*"); assertNotContains(res, "*pendistro_security*"); diff --git a/src/test/java/org/opensearch/security/ConfigTests.java b/src/test/java/org/opensearch/security/ConfigTests.java index 46a36454b5..9f253a5f87 100644 --- a/src/test/java/org/opensearch/security/ConfigTests.java +++ b/src/test/java/org/opensearch/security/ConfigTests.java @@ -58,19 +58,13 @@ public void testMigrate() throws Exception { Tuple, SecurityDynamicConfiguration> rolesResult = Migration.migrateRoles((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/roles.yml", CType.ROLES), (SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/roles_mapping.yml", CType.ROLESMAPPING)); - System.out.println(Strings.toString(rolesResult.v2(), true, false)); - System.out.println(Strings.toString(rolesResult.v1(), true, false)); - + SecurityDynamicConfiguration actionGroupsResult = Migration.migrateActionGroups((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/action_groups.yml", CType.ACTIONGROUPS)); - System.out.println(Strings.toString(actionGroupsResult, true, false)); - SecurityDynamicConfiguration configResult =Migration.migrateConfig((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/config.yml", CType.CONFIG)); - System.out.println(Strings.toString(configResult, true, false)); - SecurityDynamicConfiguration internalUsersResult = Migration.migrateInternalUsers((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/internal_users.yml", CType.INTERNALUSERS)); - System.out.println(Strings.toString(internalUsersResult, true, false)); - SecurityDynamicConfiguration rolemappingsResult = Migration.migrateRoleMappings((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/roles_mapping.yml", CType.ROLESMAPPING)); - System.out.println(Strings.toString(rolemappingsResult, true, false)); - } + SecurityDynamicConfiguration configResult =Migration.migrateConfig((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/config.yml", CType.CONFIG)); + SecurityDynamicConfiguration internalUsersResult = Migration.migrateInternalUsers((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/internal_users.yml", CType.INTERNALUSERS)); + SecurityDynamicConfiguration rolemappingsResult = Migration.migrateRoleMappings((SecurityDynamicConfiguration)load("./legacy/securityconfig_v6/roles_mapping.yml", CType.ROLESMAPPING)); + } @Test public void testParseSg67Config() throws Exception { @@ -97,15 +91,13 @@ public void testParseSg67Config() throws Exception { private void check(String file, CType cType) throws Exception { JsonNode jsonNode = YAML.readTree(FileUtils.readFileToString(new File(file), "UTF-8")); int configVersion = 1; - System.out.println("%%%%%%%% THIS IS A LINE OF INTEREST %%%%%%%"); - if(jsonNode.get("_meta") != null) { + if(jsonNode.get("_meta") != null) { Assert.assertEquals(jsonNode.get("_meta").get("type").asText(), cType.toLCString()); configVersion = jsonNode.get("_meta").get("config_version").asInt(); } - System.out.println("%%%%%%%% THIS IS A LINE OF INTEREST: CONFIG VERSION: "+ configVersion + "%%%%%%%"); - + SecurityDynamicConfiguration dc = load(file, cType); Assert.assertNotNull(dc); //Assert.assertTrue(dc.getCEntries().size() > 0); @@ -119,12 +111,10 @@ private SecurityDynamicConfiguration load(String file, CType cType) throws Ex JsonNode jsonNode = YAML.readTree(FileUtils.readFileToString(new File(file), "UTF-8")); int configVersion = 1; - System.out.println("%%%%%%%% THIS IS A LINE OF INTEREST LOAD: CONFIG VERSION: %%%%%%%"); - if(jsonNode.get("_meta") != null) { + if(jsonNode.get("_meta") != null) { Assert.assertEquals(jsonNode.get("_meta").get("type").asText(), cType.toLCString()); configVersion = jsonNode.get("_meta").get("config_version").asInt(); } - System.out.println("%%%%%%%% THIS IS A LINE OF INTEREST: CONFIG VERSION: "+ configVersion + "%%%%%%%"); - return SecurityDynamicConfiguration.fromNode(jsonNode, cType, configVersion, 0, 0); + return SecurityDynamicConfiguration.fromNode(jsonNode, cType, configVersion, 0, 0); } } diff --git a/src/test/java/org/opensearch/security/HealthTests.java b/src/test/java/org/opensearch/security/HealthTests.java index 624e17f0a6..553de63a3a 100644 --- a/src/test/java/org/opensearch/security/HealthTests.java +++ b/src/test/java/org/opensearch/security/HealthTests.java @@ -49,14 +49,12 @@ public void testHealth() throws Exception { RestHelper rh = nonSslRestHelper(); HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/health?pretty&mode=lenient")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*UP*"); + assertContains(res, "*UP*"); assertNotContains(res, "*DOWN*"); assertNotContains(res, "*strict*"); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/health?pretty")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*UP*"); + assertContains(res, "*UP*"); assertContains(res, "*strict*"); assertNotContains(res, "*DOWN*"); } @@ -68,14 +66,12 @@ public void testHealthUnitialized() throws Exception { RestHelper rh = nonSslRestHelper(); HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/health?pretty&mode=lenient")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*UP*"); + assertContains(res, "*UP*"); assertNotContains(res, "*DOWN*"); assertNotContains(res, "*strict*"); Assert.assertEquals(HttpStatus.SC_SERVICE_UNAVAILABLE, (res = rh.executeGetRequest("_opendistro/_security/health?pretty")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*DOWN*"); + assertContains(res, "*DOWN*"); assertContains(res, "*strict*"); assertNotContains(res, "*UP*"); } diff --git a/src/test/java/org/opensearch/security/HttpIntegrationTests.java b/src/test/java/org/opensearch/security/HttpIntegrationTests.java index 8740824309..1c18d7e6bc 100644 --- a/src/test/java/org/opensearch/security/HttpIntegrationTests.java +++ b/src/test/java/org/opensearch/security/HttpIntegrationTests.java @@ -183,9 +183,7 @@ public void testHTTPBasic() throws Exception { Assert.assertFalse(res.getBody().contains("\"nodes\" : { }")); res = rh.executePostRequest("*/_upgrade", "", encodeBasicHeader("nagilum", "nagilum")); - System.out.println(res.getBody()); - System.out.println(res.getStatusReason()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); String bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ @@ -194,8 +192,7 @@ public void testHTTPBasic() throws Exception { "{ \"field2\" : \"value2\" }"+System.lineSeparator(); res = rh.executePostRequest("_bulk", bulkBody, encodeBasicHeader("writer", "writer")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(res.getBody().contains("\"errors\":false")); Assert.assertTrue(res.getBody().contains("\"status\":201")); @@ -272,12 +269,10 @@ public void testHTTPSCompressionEnabled() throws Exception { HttpResponse res = rh.executeGetRequest("_opendistro/_security/sslinfo", encodeBasicHeader("nagilum", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println(res); - assertContains(res, "*ssl_protocol\":\"TLSv1.2*"); + assertContains(res, "*ssl_protocol\":\"TLSv1.2*"); res = rh.executeGetRequest("_nodes", encodeBasicHeader("nagilum", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println(res); - assertNotContains(res, "*\"compression\":\"false\"*"); + assertNotContains(res, "*\"compression\":\"false\"*"); assertContains(res, "*\"compression\":\"true\"*"); } @@ -293,12 +288,10 @@ public void testHTTPSCompression() throws Exception { HttpResponse res = rh.executeGetRequest("_opendistro/_security/sslinfo", encodeBasicHeader("nagilum", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println(res); - assertContains(res, "*ssl_protocol\":\"TLSv1.2*"); + assertContains(res, "*ssl_protocol\":\"TLSv1.2*"); res = rh.executeGetRequest("_nodes", encodeBasicHeader("nagilum", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println(res); - assertContains(res, "*\"compression\":\"false\"*"); + assertContains(res, "*\"compression\":\"false\"*"); assertNotContains(res, "*\"compression\":\"true\"*"); } @@ -318,13 +311,11 @@ public void testHTTPAnon() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); resc = rh.executeGetRequest("_opendistro/_security/authinfo?pretty=true"); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody().contains("\"remote_address\" : \"")); //check pretty print + Assert.assertTrue(resc.getBody().contains("\"remote_address\" : \"")); //check pretty print Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); resc = rh.executeGetRequest("_opendistro/_security/authinfo", encodeBasicHeader("nagilum", "nagilum")); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody().contains("nagilum")); + Assert.assertTrue(resc.getBody().contains("nagilum")); Assert.assertFalse(resc.getBody().contains("opendistro_security_anonymous")); Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); @@ -380,8 +371,7 @@ public void testHTTPClientCert() throws Exception { Assert.assertEquals(HttpStatus.SC_CREATED, rh.executePutRequest(".opendistro_security/"+getType()+"/y", "{}").getStatusCode()); HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/authinfo")).getStatusCode()); - System.out.println(res.getBody()); - } + } @Test @Ignore @@ -512,8 +502,7 @@ public void testHTTPBasic2() throws Exception { Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePutRequest(".opendistro_security/config/0","{}",encodeBasicHeader("worf", "worf")).getStatusCode()); HttpResponse resc = rh.executeGetRequest("_cat/indices/public",encodeBasicHeader("bug108", "nagilum")); - System.out.println(resc.getBody()); - //Assert.assertTrue(resc.getBody().contains("green")); + //Assert.assertTrue(resc.getBody().contains("green")); Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("role01_role02/type01/_search?pretty",encodeBasicHeader("user_role01_role02_role03", "user_role01_role02_role03")).getStatusCode()); @@ -523,8 +512,7 @@ public void testHTTPBasic2() throws Exception { Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executeGetRequest("spock/type01/_search?pretty",encodeBasicHeader("kirk", "kirk")).getStatusCode()); Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("kirk/type01/_search?pretty",encodeBasicHeader("kirk", "kirk")).getStatusCode()); - System.out.println("ok"); - //all + //all } @@ -544,8 +532,7 @@ public void testBulk() throws Exception { "{ \"field2\" : \"value2\" }"+System.lineSeparator(); HttpResponse res = rh.executePostRequest("_bulk", bulkBody, encodeBasicHeader("bulk", "nagilum")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(res.getBody().contains("\"errors\":false")); Assert.assertTrue(res.getBody().contains("\"status\":201")); } @@ -565,8 +552,7 @@ public void testBulkWithOneIndexFailure() throws Exception { "{ \"a\" : \"b\" }"+System.lineSeparator(); HttpResponse res = rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("bulk_test_user", "nagilum")); - System.out.println(res.getBody()); - JsonNode jsonNode = readTree(res.getBody()); + JsonNode jsonNode = readTree(res.getBody()); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(jsonNode.get("errors").booleanValue()); Assert.assertEquals(201, jsonNode.get("items").get(0).get("index").get("status").intValue()); @@ -595,12 +581,10 @@ public void test557() throws Exception { final RestHelper rh = nonSslRestHelper(); HttpResponse res = rh.executePostRequest("/*/_search", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":10}}}}", encodeBasicHeader("nagilum", "nagilum")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(res.getBody().contains("starfleet_academy")); res = rh.executePostRequest("/*/_search", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":10}}}}", encodeBasicHeader("557", "nagilum")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(res.getBody().contains("starfleet_academy")); } @@ -630,14 +614,11 @@ public void testITT1635() throws Exception { final RestHelper rh = nonSslRestHelper(); - System.out.println("###1"); - HttpResponse res = rh.executeGetRequest("/esb-prod-*/_search?pretty", encodeBasicHeader("itt1635", "nagilum")); + HttpResponse res = rh.executeGetRequest("/esb-prod-*/_search?pretty", encodeBasicHeader("itt1635", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println("###2"); - res = rh.executeGetRequest("/esb-alias-*/_search?pretty", encodeBasicHeader("itt1635", "nagilum")); + res = rh.executeGetRequest("/esb-alias-*/_search?pretty", encodeBasicHeader("itt1635", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println("###3"); - res = rh.executeGetRequest("/esb-prod-all/_search?pretty", encodeBasicHeader("itt1635", "nagilum")); + res = rh.executeGetRequest("/esb-prod-all/_search?pretty", encodeBasicHeader("itt1635", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); } @@ -685,8 +666,7 @@ public void testTenantInfo() throws Exception { Assert.assertEquals(HttpStatus.SC_FORBIDDEN, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/tenantinfo?pretty", encodeBasicHeader("kibanaserver", "kibanaserver")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(res.getBody().contains("\".kibana_-1139640511_admin1\" : \"admin_1\"")); Assert.assertTrue(res.getBody().contains("\".kibana_-1386441176_praxisrw\" : \"praxisrw\"")); Assert.assertTrue(res.getBody().contains(".kibana_-2014056163_kltentrw\" : \"kltentrw\"")); diff --git a/src/test/java/org/opensearch/security/IndexIntegrationTests.java b/src/test/java/org/opensearch/security/IndexIntegrationTests.java index afdf8e5ad4..62ef05f3aa 100644 --- a/src/test/java/org/opensearch/security/IndexIntegrationTests.java +++ b/src/test/java/org/opensearch/security/IndexIntegrationTests.java @@ -126,16 +126,13 @@ public void testBulkShards() throws Exception { "{ \"field2\" : \"value2\" }"+System.lineSeparator()+ "{ \"delete\" : { \"_index\" : \"lorem\", \"_type\" : \"type1\", \"_id\" : \"5\" } }"+System.lineSeparator(); - System.out.println("############ _bulk"); - HttpResponse res = rh.executePostRequest("_bulk?refresh=true&pretty=true", bulkBody, encodeBasicHeader("worf", "worf")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + HttpResponse res = rh.executePostRequest("_bulk?refresh=true&pretty=true", bulkBody, encodeBasicHeader("worf", "worf")); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(res.getBody().contains("\"errors\" : true")); Assert.assertTrue(res.getBody().contains("\"status\" : 201")); Assert.assertTrue(res.getBody().contains("no permissions for")); - System.out.println("############ check shards"); - System.out.println(rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("nagilum", "nagilum"))); + rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("nagilum", "nagilum")); } @@ -344,8 +341,7 @@ public void testIndices() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/_cat/indices?v" ,encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("logstash-b")); + Assert.assertTrue(res.getBody().contains("logstash-b")); Assert.assertTrue(res.getBody().contains("logstash-new-20")); Assert.assertTrue(res.getBody().contains("logstash-cnew-20")); Assert.assertFalse(res.getBody().contains("<")); @@ -386,17 +382,13 @@ public void testAliases() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/mysgi/_search?pretty", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); assertContains(res, "*\"hits\" : {*\"value\" : 0,*\"hits\" : [ ]*"); - System.out.println("#### add alias to allowed index"); - Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePutRequest("/logstash-1/_alias/alog1", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePutRequest("/logstash-1/_alias/alog1", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); - System.out.println("#### add alias to not existing (no perm)"); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/nonexitent/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/nonexitent/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); - System.out.println("#### add alias to not existing (with perm)"); - Assert.assertEquals(HttpStatus.SC_NOT_FOUND, (res = rh.executePutRequest("/logstash-nonex/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_NOT_FOUND, (res = rh.executePutRequest("/logstash-nonex/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); - System.out.println("#### add alias to not allowed index"); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/nopermindex/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/nopermindex/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); String aliasRemoveIndex = "{"+ "\"actions\" : ["+ @@ -405,20 +397,16 @@ public void testAliases() throws Exception { "]"+ "}"; - System.out.println("#### remove_index"); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePostRequest("/_aliases", aliasRemoveIndex,encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePostRequest("/_aliases", aliasRemoveIndex,encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); - System.out.println("#### get alias for permitted index"); - Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-1/_alias/alog1", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-1/_alias/alog1", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); - System.out.println("#### get alias for all indices"); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executeGetRequest("/_alias/alog1", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executeGetRequest("/_alias/alog1", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); - System.out.println("#### get alias no perm"); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executeGetRequest("/_alias/nopermalias", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executeGetRequest("/_alias/nopermalias", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); String alias = "{"+ @@ -428,8 +416,7 @@ public void testAliases() throws Exception { "}"; - System.out.println("#### create alias along with index"); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/beats-withalias", alias,encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/beats-withalias", alias,encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode()); } @Test @@ -519,11 +506,9 @@ public void testCCSIndexResolve2() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("/*:noperm/_search", encodeBasicHeader("ccsresolv", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println(res.getBody()); - res = rh.executeGetRequest("/*:noexists/_search", encodeBasicHeader("ccsresolv", "nagilum")); + res = rh.executeGetRequest("/*:noexists/_search", encodeBasicHeader("ccsresolv", "nagilum")); Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); - System.out.println(res.getBody()); - } + } @Test public void testIndexResolveIgnoreUnavailable() throws Exception { diff --git a/src/test/java/org/opensearch/security/InitializationIntegrationTests.java b/src/test/java/org/opensearch/security/InitializationIntegrationTests.java index 72a35e55c9..53319c4bef 100644 --- a/src/test/java/org/opensearch/security/InitializationIntegrationTests.java +++ b/src/test/java/org/opensearch/security/InitializationIntegrationTests.java @@ -116,8 +116,7 @@ public void testWhoAmI() throws Exception { try (TransportClient tc = getUserTransportClient(clusterInfo, "spock-keystore.jks", Settings.EMPTY)) { WhoAmIResponse wres = tc.execute(WhoAmIAction.INSTANCE, new WhoAmIRequest()).actionGet(); - System.out.println(wres); - Assert.assertEquals(wres.toString(), "CN=spock,OU=client,O=client,L=Test,C=DE", wres.getDn()); + Assert.assertEquals(wres.toString(), "CN=spock,OU=client,O=client,L=Test,C=DE", wres.getDn()); Assert.assertFalse(wres.toString(), wres.isAdmin()); Assert.assertFalse(wres.toString(), wres.isAuthenticated()); Assert.assertFalse(wres.toString(), wres.isNodeCertificateRequest()); @@ -126,8 +125,7 @@ public void testWhoAmI() throws Exception { try (TransportClient tc = getUserTransportClient(clusterInfo, "node-0-keystore.jks", Settings.EMPTY)) { WhoAmIResponse wres = tc.execute(WhoAmIAction.INSTANCE, new WhoAmIRequest()).actionGet(); - System.out.println(wres); - Assert.assertEquals(wres.toString(), "CN=node-0.example.com,OU=SSL,O=Test,L=Test,C=DE", wres.getDn()); + Assert.assertEquals(wres.toString(), "CN=node-0.example.com,OU=SSL,O=Test,L=Test,C=DE", wres.getDn()); Assert.assertFalse(wres.toString(), wres.isAdmin()); Assert.assertFalse(wres.toString(), wres.isAuthenticated()); Assert.assertTrue(wres.toString(), wres.isNodeCertificateRequest()); diff --git a/src/test/java/org/opensearch/security/IntegrationTests.java b/src/test/java/org/opensearch/security/IntegrationTests.java index 85fc622ce6..a88f45da9d 100644 --- a/src/test/java/org/opensearch/security/IntegrationTests.java +++ b/src/test/java/org/opensearch/security/IntegrationTests.java @@ -97,20 +97,15 @@ public void uncaughtException(Thread t, Throwable e) { } - System.out.println("########search"); - HttpResponse res; + HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executeGetRequest("vulcangov/_search?scroll=1m&pretty=true", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(res.getBody()); - int start = res.getBody().indexOf("_scroll_id") + 15; + int start = res.getBody().indexOf("_scroll_id") + 15; String scrollid = res.getBody().substring(start, res.getBody().indexOf("\"", start+1)); - System.out.println(scrollid); - System.out.println("########search scroll"); - Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println("########search done"); - + } @@ -125,8 +120,7 @@ public void testNotInsecure() throws Exception { tc.index(new IndexRequest("lorem").type("type1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"field2\":\"init\"}", XContentType.JSON)).actionGet(); WhoAmIResponse wres = tc.execute(WhoAmIAction.INSTANCE, new WhoAmIRequest()).actionGet(); - System.out.println(wres); - Assert.assertEquals("CN=kirk,OU=client,O=client,L=Test,C=DE", wres.getDn()); + Assert.assertEquals("CN=kirk,OU=client,O=client,L=Test,C=DE", wres.getDn()); Assert.assertTrue(wres.isAdmin()); Assert.assertTrue(wres.toString(), wres.isAuthenticated()); Assert.assertFalse(wres.toString(), wres.isNodeCertificateRequest()); @@ -280,8 +274,7 @@ public void testMultiget() throws Exception { RestHelper rh = nonSslRestHelper(); HttpResponse resc = rh.executePostRequest("_mget?refresh=true", mgetBody, encodeBasicHeader("picard", "picard")); - System.out.println(resc.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); Assert.assertFalse(resc.getBody().contains("type2")); } @@ -309,8 +302,7 @@ public void testRestImpersonation() throws Exception { Assert.assertFalse(resp.getBody().contains("spock")); resp = rh.executeGetRequest("/_opendistro/_security/authinfo", new BasicHeader("opendistro_security_impersonate_as", "userwhonotexists"), encodeBasicHeader("spock", "spock")); - System.out.println(resp.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, resp.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, resp.getStatusCode()); resp = rh.executeGetRequest("/_opendistro/_security/authinfo", new BasicHeader("opendistro_security_impersonate_as", "invalid"), encodeBasicHeader("spock", "spock")); Assert.assertEquals(HttpStatus.SC_FORBIDDEN, resp.getStatusCode()); @@ -332,8 +324,7 @@ public void testSingle() throws Exception { //opendistro_security_shakespeare -> picard HttpResponse resc = rh.executeGetRequest("shakespeare/_search", encodeBasicHeader("picard", "picard")); - System.out.println(resc.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode()); Assert.assertTrue(resc.getBody().contains("\"content\":1")); resc = rh.executeHeadRequest("shakespeare", encodeBasicHeader("picard", "picard")); @@ -397,8 +388,7 @@ public void testMultiRoleSpan() throws Exception { } HttpResponse res = rh.executeGetRequest("/mindex_1,mindex_2/_search", encodeBasicHeader("mindex12", "nagilum")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, res.getStatusCode()); Assert.assertFalse(res.getBody().contains("\"content\":1")); Assert.assertFalse(res.getBody().contains("\"content\":2")); @@ -410,8 +400,7 @@ public void testMultiRoleSpan() throws Exception { } res = rh.executeGetRequest("/mindex_1,mindex_2/_search", encodeBasicHeader("mindex12", "nagilum")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertTrue(res.getBody().contains("\"content\":1")); Assert.assertTrue(res.getBody().contains("\"content\":2")); @@ -492,8 +481,7 @@ public void testUpdate() throws Exception { HttpResponse res = rh.executePostRequest("indexc/typec/0/_update?pretty=true&refresh=true", "{\"doc\" : {\"content\":2}}", encodeBasicHeader("user_c", "user_c")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); } @@ -533,15 +521,13 @@ public void testDnfof() throws Exception { HttpResponse resc; Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("indexa,indexb/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("exception")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("permission")); Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("indexa,indexb/_search?pretty", encodeBasicHeader("user_b", "user_b"))).getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("exception")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("permission")); @@ -553,11 +539,9 @@ public void testDnfof() throws Exception { "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+ "{\"index\":\"index*\", \"type\":\"doc\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println("#### msearch"); - resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_a", "user_a")); + resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_a", "user_a")); Assert.assertEquals(200, resc.getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("permission")); @@ -566,8 +550,7 @@ public void testDnfof() throws Exception { resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); Assert.assertEquals(200, resc.getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("permission")); @@ -598,8 +581,7 @@ public void testDnfof() throws Exception { "]"+ "}"; - System.out.println("#### mget"); - resc = rh.executePostRequest("_mget?pretty", mgetBody, encodeBasicHeader("user_b", "user_b")); + resc = rh.executePostRequest("_mget?pretty", mgetBody, encodeBasicHeader("user_b", "user_b")); Assert.assertEquals(200, resc.getStatusCode()); Assert.assertFalse(resc.getBody(), resc.getBody().contains("\"content\" : \"indexa\"")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("\"content\" : \"indexb\"")); @@ -625,51 +607,37 @@ public void testDnfof() throws Exception { Assert.assertEquals(403, resc.getStatusCode()); Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("index*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("exception")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("permission")); Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("indexa/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("indexb/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_all/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("notexists/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("notexists/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_NOT_FOUND, (resc=rh.executeGetRequest("permitnotexistentindex/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("permitnotexistentindex*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_NOT_FOUND, (resc=rh.executeGetRequest("indexanbh,indexabb*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("starfleet/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("starfleet/_search?pretty", encodeBasicHeader("worf", "worf"))).getStatusCode()); - System.out.println(resc.getBody()); - - System.out.println("#### _all/_mapping/field/*"); - Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_all/_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(resc.getBody()); - } + + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_all/_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); + } @Test @@ -708,30 +676,24 @@ public void testNoDnfof() throws Exception { HttpResponse resc; Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("indexa,indexb/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("indexa,indexb/_search?pretty", encodeBasicHeader("user_b", "user_b"))).getStatusCode()); - System.out.println(resc.getBody()); - + String msearchBody = "{\"index\":\"indexa\", \"type\":\"doc\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+ "{\"index\":\"indexb\", \"type\":\"doc\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println("#### msearch a"); - resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_a", "user_a")); + resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_a", "user_a")); Assert.assertEquals(200, resc.getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("permission")); - System.out.println("#### msearch b"); - resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); + resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); Assert.assertEquals(200, resc.getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("permission")); @@ -742,10 +704,8 @@ public void testNoDnfof() throws Exception { "{\"index\":\"indexd\", \"type\":\"doc\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println("#### msearch b2"); - resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); - System.out.println(resc.getBody()); - Assert.assertEquals(200, resc.getStatusCode()); + resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); + Assert.assertEquals(200, resc.getStatusCode()); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexc")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexd")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); @@ -802,39 +762,25 @@ public void testNoDnfof() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("indexa/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("indexb/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("_all/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("notexists/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_NOT_FOUND, (resc=rh.executeGetRequest("indexanbh,indexabb*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("starfleet/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("starfleet/_search?pretty", encodeBasicHeader("worf", "worf"))).getStatusCode()); - System.out.println(resc.getBody()); - - System.out.println("#### _all/_mapping/field/*"); - Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_all/_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(resc.getBody()); - System.out.println("#### _mapping/field/*"); - Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(resc.getBody()); - System.out.println("#### */_mapping/field/*"); - Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("*/_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(resc.getBody()); - } + + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_all/_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("*/_mapping/field/*", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); + } @Test public void testSecurityIndexSecurity() throws Exception { @@ -880,8 +826,7 @@ public void testSecurityIndexSecurity() throws Exception { + "{ \"delete\" : { \"_index\" : \".opendistro_security\", \"_id\" : \"config\" } }\n"; res = rh.executePostRequest("_bulk?refresh=true&pretty", bulkBody, encodeBasicHeader("nagilum", "nagilum")); JsonNode jsonNode = readTree(res.getBody()); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertEquals(403, jsonNode.get("items").get(0).get("index").get("status").intValue()); Assert.assertEquals(403, jsonNode.get("items").get(1).get("index").get("status").intValue()); Assert.assertEquals(201, jsonNode.get("items").get(2).get("index").get("status").intValue()); diff --git a/src/test/java/org/opensearch/security/SecurityAdminTests.java b/src/test/java/org/opensearch/security/SecurityAdminTests.java index 062c927771..6160887534 100644 --- a/src/test/java/org/opensearch/security/SecurityAdminTests.java +++ b/src/test/java/org/opensearch/security/SecurityAdminTests.java @@ -92,8 +92,7 @@ public void testSecurityAdminV6Update() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_SERVICE_UNAVAILABLE, (res = rh.executeGetRequest("_opendistro/_security/health?pretty")).getStatusCode()); - //System.out.println(res.getBody()); - //assertContains(res, "*UP*"); + // //assertContains(res, "*UP*"); //assertContains(res, "*strict*"); //assertNotContains(res, "*DOWN*"); } @@ -125,8 +124,7 @@ public void testSecurityAdminRegularUpdate() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/health?pretty")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*UP*"); + assertContains(res, "*UP*"); assertContains(res, "*strict*"); assertNotContains(res, "*DOWN*"); } @@ -198,8 +196,7 @@ public void testSecurityAdminSingularV7Updates() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/health?pretty")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*UP*"); + assertContains(res, "*UP*"); assertContains(res, "*strict*"); assertNotContains(res, "*DOWN*"); } @@ -233,8 +230,7 @@ public void testSecurityAdminSingularV6Updates() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/health?pretty")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*UP*"); + assertContains(res, "*UP*"); assertContains(res, "*strict*"); assertNotContains(res, "*DOWN*"); } @@ -268,8 +264,7 @@ public void testSecurityAdminInvalidYml() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_opendistro/_security/health?pretty")).getStatusCode()); - System.out.println(res.getBody()); - assertContains(res, "*UP*"); + assertContains(res, "*UP*"); assertContains(res, "*strict*"); assertNotContains(res, "*DOWN*"); } @@ -289,7 +284,7 @@ public void testSecurityAdminReloadInvalidConfig() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; rh.keystore = "kirk-keystore.jks"; - System.out.println(rh.executePutRequest(".opendistro_security/"+getType()+"/roles", FileHelper.loadFile("roles_invalidxcontent.yml")).getBody());; + rh.executePutRequest(".opendistro_security/"+getType()+"/roles", FileHelper.loadFile("roles_invalidxcontent.yml")).getBody();; Assert.assertEquals(HttpStatus.SC_OK, rh.executePutRequest(".opendistro_security/"+getType()+"/roles", "{\"roles\":\"dummy\"}").getStatusCode()); diff --git a/src/test/java/org/opensearch/security/SnapshotRestoreTests.java b/src/test/java/org/opensearch/security/SnapshotRestoreTests.java index 380d15a4a2..b4e3a00fe6 100644 --- a/src/test/java/org/opensearch/security/SnapshotRestoreTests.java +++ b/src/test/java/org/opensearch/security/SnapshotRestoreTests.java @@ -208,8 +208,7 @@ public void testSnapshotCheckWritePrivileges() throws Exception { ConfigUpdateResponse cur = tc.execute(ConfigUpdateAction.INSTANCE, new ConfigUpdateRequest(new String[]{"config","roles","rolesmapping","internalusers","actiongroups"})).actionGet(); Assert.assertFalse(cur.hasFailures()); Assert.assertEquals(currentClusterConfig.getNodes(), cur.getNodes().size()); - System.out.println(cur.getNodesMap()); - } + } RestHelper rh = nonSslRestHelper(); Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/vulcangov", encodeBasicHeader("nagilum", "nagilum")).getStatusCode()); diff --git a/src/test/java/org/opensearch/security/TaskTests.java b/src/test/java/org/opensearch/security/TaskTests.java index 7c77417477..c3cdc0257f 100644 --- a/src/test/java/org/opensearch/security/TaskTests.java +++ b/src/test/java/org/opensearch/security/TaskTests.java @@ -39,8 +39,7 @@ public void testXOpaqueIdHeader() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_tasks?group_by=parents&pretty" , encodeBasicHeader("nagilum", "nagilum") , new BasicHeader(Task.X_OPAQUE_ID, "myOpaqueId12"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().split("X-Opaque-Id").length > 2); + Assert.assertTrue(res.getBody().split("X-Opaque-Id").length > 2); Assert.assertTrue(!res.getBody().contains("failures")); } } diff --git a/src/test/java/org/opensearch/security/TracingTests.java b/src/test/java/org/opensearch/security/TracingTests.java index ffdb72eb73..fc8472b2a3 100644 --- a/src/test/java/org/opensearch/security/TracingTests.java +++ b/src/test/java/org/opensearch/security/TracingTests.java @@ -73,24 +73,20 @@ public void testAdvancedMapping() throws Exception { } RestHelper rh = nonSslRestHelper(); - System.out.println("############ write into mapping 1"); - String data1 = FileHelper.loadFile("data1.json"); - System.out.println(rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("nagilum", "nagilum"))); - System.out.println(rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("nagilum", "nagilum"))); + String data1 = FileHelper.loadFile("data1.json"); + rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("nagilum", "nagilum")); + rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ write into mapping 2"); - System.out.println(rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("nagilum", "nagilum"))); - System.out.println(rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("nagilum", "nagilum")); + rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ write into mapping 3"); - String parent = FileHelper.loadFile("data2.json"); + String parent = FileHelper.loadFile("data2.json"); String child = FileHelper.loadFile("data3.json"); - System.out.println(rh.executePutRequest("myindex3/mytype3/1?refresh", parent, encodeBasicHeader("nagilum", "nagilum"))); - System.out.println(rh.executePutRequest("myindex3/mytype3/2?routing=1&refresh", child, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePutRequest("myindex3/mytype3/1?refresh", parent, encodeBasicHeader("nagilum", "nagilum")); + rh.executePutRequest("myindex3/mytype3/2?routing=1&refresh", child, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ write into mapping 4"); - System.out.println(rh.executePutRequest("myindex4/mytype4/1?refresh", parent, encodeBasicHeader("nagilum", "nagilum"))); - System.out.println(rh.executePutRequest("myindex4/mytype4/2?routing=1&refresh", child, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePutRequest("myindex4/mytype4/1?refresh", parent, encodeBasicHeader("nagilum", "nagilum")); + rh.executePutRequest("myindex4/mytype4/2?routing=1&refresh", child, encodeBasicHeader("nagilum", "nagilum")); } @Test @@ -130,73 +126,61 @@ public void testHTTPTraceNoSource() throws Exception { RestHelper rh = nonSslRestHelper(); - System.out.println("############ check shards"); - System.out.println(rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("nagilum", "nagilum"))); + rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ _bulk"); - String bulkBody = + String bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ "{ \"field2\" : \"value2\" }"+System.lineSeparator()+ "{ \"delete\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ _bulk"); - bulkBody = + bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ "{ \"field2\" : \"value2\" }"+System.lineSeparator()+ "{ \"delete\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ cat indices"); - //cluster:monitor/state + //cluster:monitor/state //cluster:monitor/health //indices:monitor/stats - System.out.println(rh.executeGetRequest("_cat/indices", encodeBasicHeader("nagilum", "nagilum"))); + rh.executeGetRequest("_cat/indices", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ _search"); - //indices:data/read/search - System.out.println(rh.executeGetRequest("_search", encodeBasicHeader("nagilum", "nagilum"))); + //indices:data/read/search + rh.executeGetRequest("_search", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ get 1"); - //indices:data/read/get - System.out.println(rh.executeGetRequest("a/b/1", encodeBasicHeader("nagilum", "nagilum"))); - System.out.println("############ get 5"); - System.out.println(rh.executeGetRequest("a/b/5", encodeBasicHeader("nagilum", "nagilum"))); - System.out.println("############ get 17"); - System.out.println(rh.executeGetRequest("a/b/17", encodeBasicHeader("nagilum", "nagilum"))); + //indices:data/read/get + rh.executeGetRequest("a/b/1", encodeBasicHeader("nagilum", "nagilum")); + rh.executeGetRequest("a/b/5", encodeBasicHeader("nagilum", "nagilum")); + rh.executeGetRequest("a/b/17", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ index (+create index)"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/1?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("u/b/1?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ index only"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("u/b/2?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ delete"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executeDeleteRequest("u/b/2?refresh=true",encodeBasicHeader("nagilum", "nagilum"))); + rh.executeDeleteRequest("u/b/2?refresh=true",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ msearch"); - String msearchBody = + String msearchBody = "{\"index\":\"a\", \"type\":\"b\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+ "{\"index\":\"a\", \"type\":\"b\", \"ignore_unavailable\": true}"+System.lineSeparator()+ @@ -205,10 +189,9 @@ public void testHTTPTraceNoSource() throws Exception { "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_msearch", msearchBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_msearch", msearchBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ mget"); - String mgetBody = "{"+ + String mgetBody = "{"+ "\"docs\" : ["+ "{"+ "\"_index\" : \"a\","+ @@ -232,10 +215,9 @@ public void testHTTPTraceNoSource() throws Exception { "]"+ "}"; - System.out.println(rh.executePostRequest("_mget?refresh=true", mgetBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_mget?refresh=true", mgetBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ delete by query"); - String dbqBody = "{"+ + String dbqBody = "{"+ ""+ " \"query\": { "+ " \"match\": {"+ @@ -244,7 +226,7 @@ public void testHTTPTraceNoSource() throws Exception { " }"+ "}"; - System.out.println(rh.executePostRequest("a/b/_delete_by_query", dbqBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("a/b/_delete_by_query", dbqBody, encodeBasicHeader("nagilum", "nagilum")); Thread.sleep(5000); } @@ -286,20 +268,13 @@ public void uncaughtException(Thread t, Throwable e) { } - System.out.println("########pause1"); - Thread.sleep(5000); - System.out.println("########end pause1"); - - System.out.println("########search"); - Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_search", encodeBasicHeader("nagilum", "nagilum")).getStatusCode()); - System.out.println("########search done"); - - System.out.println("########pause2"); - Thread.sleep(5000); - System.out.println("########end pause2"); - - System.out.println("############ _bulk"); - String bulkBody = + Thread.sleep(5000); + + Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_search", encodeBasicHeader("nagilum", "nagilum")).getStatusCode()); + + Thread.sleep(5000); + + String bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ @@ -310,9 +285,8 @@ public void uncaughtException(Thread t, Throwable e) { "{ \"index\" : { \"_index\" : \"myindex\", \"_type\" : \"myindex\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum")).getBody()); - System.out.println("############ _end"); - Thread.sleep(5000); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum")).getBody(); + Thread.sleep(5000); } @Test @@ -339,20 +313,15 @@ public void uncaughtException(Thread t, Throwable e) { } - System.out.println("########search"); - HttpResponse res; + HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executeGetRequest("vulcangov/_search?scroll=1m&pretty=true", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println(res.getBody()); - int start = res.getBody().indexOf("_scroll_id") + 15; + int start = res.getBody().indexOf("_scroll_id") + 15; String scrollid = res.getBody().substring(start, res.getBody().indexOf("\"", start+1)); - System.out.println(scrollid); - System.out.println("########search scroll"); - Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - + Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode()); - System.out.println("########search done"); + } @@ -373,94 +342,79 @@ public void testHTTPTrace() throws Exception { RestHelper rh = nonSslRestHelper(); - System.out.println("############ check shards"); - System.out.println(rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("nagilum", "nagilum"))); + rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ _bulk"); - String bulkBody = + String bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ "{ \"field2\" : \"value2\" }"+System.lineSeparator()+ "{ \"delete\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ _bulk"); - bulkBody = + bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ "{ \"field2\" : \"value2\" }"+System.lineSeparator()+ "{ \"delete\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ cat indices"); - //cluster:monitor/state + //cluster:monitor/state //cluster:monitor/health //indices:monitor/stats - System.out.println(rh.executeGetRequest("_cat/indices", encodeBasicHeader("nagilum", "nagilum"))); + rh.executeGetRequest("_cat/indices", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ _search"); - //indices:data/read/search - System.out.println(rh.executeGetRequest("_search", encodeBasicHeader("nagilum", "nagilum"))); + //indices:data/read/search + rh.executeGetRequest("_search", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ get 1"); - //indices:data/read/get - System.out.println(rh.executeGetRequest("a/b/1", encodeBasicHeader("nagilum", "nagilum"))); - System.out.println("############ get 5"); - System.out.println(rh.executeGetRequest("a/b/5", encodeBasicHeader("nagilum", "nagilum"))); - System.out.println("############ get 17"); - System.out.println(rh.executeGetRequest("a/b/17", encodeBasicHeader("nagilum", "nagilum"))); + //indices:data/read/get + rh.executeGetRequest("a/b/1", encodeBasicHeader("nagilum", "nagilum")); + rh.executeGetRequest("a/b/5", encodeBasicHeader("nagilum", "nagilum")); + rh.executeGetRequest("a/b/17", encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ index (+create index)"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/1?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("u/b/1?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ index only"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("u/b/2?refresh=true", "{}",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ update"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"a\":1}}",encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"a\":1}}",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ update2"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"a\":44, \"b\":55}}",encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"a\":44, \"b\":55}}",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ update3"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"b\":66}}",encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"b\":66}}",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ delete"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executeDeleteRequest("u/b/2?refresh=true",encodeBasicHeader("nagilum", "nagilum"))); + rh.executeDeleteRequest("u/b/2?refresh=true",encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ reindex"); - String reindex = + String reindex = "{"+ " \"source\": {"+ " \"index\": \"a\""+ @@ -470,11 +424,10 @@ public void testHTTPTrace() throws Exception { " }"+ "}"; - System.out.println(rh.executePostRequest("_reindex", reindex, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_reindex", reindex, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ msearch"); - String msearchBody = + String msearchBody = "{\"index\":\"a\", \"type\":\"b\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+ "{\"index\":\"a\", \"type\":\"b\", \"ignore_unavailable\": true}"+System.lineSeparator()+ @@ -483,10 +436,9 @@ public void testHTTPTrace() throws Exception { "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_msearch", msearchBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_msearch", msearchBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ mget"); - String mgetBody = "{"+ + String mgetBody = "{"+ "\"docs\" : ["+ "{"+ "\"_index\" : \"a\","+ @@ -510,10 +462,9 @@ public void testHTTPTrace() throws Exception { "]"+ "}"; - System.out.println(rh.executePostRequest("_mget?refresh=true", mgetBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("_mget?refresh=true", mgetBody, encodeBasicHeader("nagilum", "nagilum")); - System.out.println("############ delete by query"); - String dbqBody = "{"+ + String dbqBody = "{"+ ""+ " \"query\": { "+ " \"match\": {"+ @@ -522,7 +473,7 @@ public void testHTTPTrace() throws Exception { " }"+ "}"; - System.out.println(rh.executePostRequest("a/b/_delete_by_query", dbqBody, encodeBasicHeader("nagilum", "nagilum"))); + rh.executePostRequest("a/b/_delete_by_query", dbqBody, encodeBasicHeader("nagilum", "nagilum")); Thread.sleep(5000); } diff --git a/src/test/java/org/opensearch/security/TransportClientIntegrationTests.java b/src/test/java/org/opensearch/security/TransportClientIntegrationTests.java index 986cfc8c77..21f3390464 100644 --- a/src/test/java/org/opensearch/security/TransportClientIntegrationTests.java +++ b/src/test/java/org/opensearch/security/TransportClientIntegrationTests.java @@ -82,62 +82,50 @@ public void testTransportClient() throws Exception { .put(SSLConfigConstants.SECURITY_SSL_TRANSPORT_KEYSTORE_ALIAS,"spock") .build(); - System.out.println("------- 0 ---------"); - + try (TransportClient tc = getInternalTransportClient(clusterInfo, tcSettings)) { Assert.assertEquals(clusterInfo.numNodes, tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet().getNodes().size()); - System.out.println("------- 1 ---------"); - + CreateIndexResponse cir = tc.admin().indices().create(new CreateIndexRequest("vulcan")).actionGet(); Assert.assertTrue(cir.isAcknowledged()); - System.out.println("------- 2 ---------"); - + IndexResponse ir = tc.index(new IndexRequest("vulcan").type("secrets").id("s1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"secret\":true}", XContentType.JSON)).actionGet(); Assert.assertTrue(ir.getResult() == Result.CREATED); - System.out.println("------- 3 ---------"); - + GetResponse gr =tc.prepareGet("vulcan", "secrets", "s1").setRealtime(true).get(); Assert.assertTrue(gr.isExists()); - System.out.println("------- 4 ---------"); - + gr =tc.prepareGet("vulcan", "secrets", "s1").setRealtime(false).get(); Assert.assertTrue(gr.isExists()); - System.out.println("------- 5 ---------"); - + SearchResponse actionGet = tc.search(new SearchRequest("vulcan").types("secrets")).actionGet(); Assert.assertEquals(1, actionGet.getHits().getHits().length); - System.out.println("------- 6 ---------"); - + gr =tc.prepareGet(".opendistro_security", "security", "config").setRealtime(false).get(); Assert.assertFalse(gr.isExists()); - System.out.println("------- 7 ---------"); - + gr =tc.prepareGet(".opendistro_security", "security", "config").setRealtime(true).get(); Assert.assertFalse(gr.isExists()); - System.out.println("------- 8 ---------"); - + actionGet = tc.search(new SearchRequest(".opendistro_security")).actionGet(); Assert.assertEquals(0, actionGet.getHits().getHits().length); - System.out.println("------- 9 ---------"); - + try { tc.index(new IndexRequest(".opendistro_security").type(getType()).id("config").source("config", FileHelper.readYamlContent("config.yml"))).actionGet(); Assert.fail(); } catch (Exception e) { - System.out.println(e.getMessage()); - } - - System.out.println("------- 10 ---------"); + } + //impersonation try { @@ -153,8 +141,7 @@ public void testTransportClient() throws Exception { Assert.assertTrue(e.getMessage(), e.getMessage().startsWith("no permissions for [indices:data/read/get]")); } - System.out.println("------- 11 ---------"); - + StoredContext ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("worf", "worf"); @@ -167,8 +154,7 @@ public void testTransportClient() throws Exception { ctx.close(); } - System.out.println("------- 12 ---------"); - ctx = tc.threadPool().getThreadContext().stashContext(); + ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("worf", "worf111"); tc.threadPool().getThreadContext().putHeader(header.getName(), header.getValue()); @@ -198,8 +184,7 @@ public void testTransportClient() throws Exception { Assert.assertEquals("'CN=spock,OU=client,O=client,L=Test,C=DE' is not allowed to impersonate as 'gkar'", e.getMessage()); } - System.out.println("------- 12 ---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); @@ -210,8 +195,7 @@ public void testTransportClient() throws Exception { ctx.close(); } - System.out.println("------- 13 ---------"); - ctx = tc.threadPool().getThreadContext().stashContext(); + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); gr = tc.prepareGet(".opendistro_security", "config", "0").setRealtime(Boolean.FALSE).get(); @@ -220,8 +204,7 @@ public void testTransportClient() throws Exception { } finally { ctx.close(); } - System.out.println("------- 13.1 ---------"); - + String scrollId = null; ctx = tc.threadPool().getThreadContext().stashContext(); try { @@ -232,8 +215,7 @@ public void testTransportClient() throws Exception { ctx.close(); } - System.out.println("------- 13.2 ---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); @@ -243,8 +225,7 @@ public void testTransportClient() throws Exception { } - System.out.println("------- 14 ---------"); - + boolean ok=false; ctx = tc.threadPool().getThreadContext().stashContext(); try { @@ -265,8 +246,7 @@ public void testTransportClient() throws Exception { ctx.close(); } - System.out.println("------- 15 ---------"); - ctx = tc.threadPool().getThreadContext().stashContext(); + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); gr = tc.prepareGet(".opendistro_security", "security", "config").setRealtime(Boolean.TRUE).get(); @@ -276,8 +256,7 @@ public void testTransportClient() throws Exception { ctx.close(); } - System.out.println("------- 15 0---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("worf", "worf"); @@ -292,8 +271,7 @@ public void testTransportClient() throws Exception { } - System.out.println("------- 15 1---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("nagilum", "nagilum"); @@ -305,8 +283,7 @@ public void testTransportClient() throws Exception { ctx.close(); } - System.out.println("------- 16---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); @@ -354,11 +331,9 @@ public void testTransportClient() throws Exception { ctx.close(); } - System.out.println("------- TRC end ---------"); - } + } - System.out.println("------- CTC end ---------"); - } + } @Test public void testTransportClientImpersonation() throws Exception { @@ -440,62 +415,50 @@ public void testTransportClientUsernameAttribute() throws Exception { .put(SSLConfigConstants.SECURITY_SSL_TRANSPORT_KEYSTORE_ALIAS,"spock") .build(); - System.out.println("------- 0 ---------"); - + try (TransportClient tc = getInternalTransportClient(clusterInfo, tcSettings)) { Assert.assertEquals(clusterInfo.numNodes, tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet().getNodes().size()); - System.out.println("------- 1 ---------"); - + CreateIndexResponse cir = tc.admin().indices().create(new CreateIndexRequest("vulcan")).actionGet(); Assert.assertTrue(cir.isAcknowledged()); - System.out.println("------- 2 ---------"); - + IndexResponse ir = tc.index(new IndexRequest("vulcan").type("secrets").id("s1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"secret\":true}", XContentType.JSON)).actionGet(); Assert.assertTrue(ir.getResult() == Result.CREATED); - System.out.println("------- 3 ---------"); - + GetResponse gr =tc.prepareGet("vulcan", "secrets", "s1").setRealtime(true).get(); Assert.assertTrue(gr.isExists()); - System.out.println("------- 4 ---------"); - + gr =tc.prepareGet("vulcan", "secrets", "s1").setRealtime(false).get(); Assert.assertTrue(gr.isExists()); - System.out.println("------- 5 ---------"); - + SearchResponse actionGet = tc.search(new SearchRequest("vulcan").types("secrets")).actionGet(); Assert.assertEquals(1, actionGet.getHits().getHits().length); - System.out.println("------- 6 ---------"); - + gr =tc.prepareGet(".opendistro_security", "security", "config").setRealtime(false).get(); Assert.assertFalse(gr.isExists()); - System.out.println("------- 7 ---------"); - + gr =tc.prepareGet(".opendistro_security", "security", "config").setRealtime(true).get(); Assert.assertFalse(gr.isExists()); - System.out.println("------- 8 ---------"); - + actionGet = tc.search(new SearchRequest(".opendistro_security")).actionGet(); Assert.assertEquals(0, actionGet.getHits().getHits().length); - System.out.println("------- 9 ---------"); - + try { tc.index(new IndexRequest(".opendistro_security").type(getType()).id("config").source("config", FileHelper.readYamlContent("config.yml"))).actionGet(); Assert.fail(); } catch (Exception e) { - System.out.println(e.getMessage()); - } - - System.out.println("------- 10 ---------"); + } + //impersonation try { @@ -511,8 +474,7 @@ public void testTransportClientUsernameAttribute() throws Exception { Assert.assertTrue(e.getMessage(), e.getMessage().startsWith("no permissions for [indices:data/read/get]")); } - System.out.println("------- 11 ---------"); - + StoredContext ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("worf", "worf"); @@ -525,8 +487,7 @@ public void testTransportClientUsernameAttribute() throws Exception { ctx.close(); } - System.out.println("------- 12 ---------"); - ctx = tc.threadPool().getThreadContext().stashContext(); + ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("worf", "worf111"); tc.threadPool().getThreadContext().putHeader(header.getName(), header.getValue()); @@ -556,8 +517,7 @@ public void testTransportClientUsernameAttribute() throws Exception { Assert.assertEquals("'CN=spock,OU=client,O=client,L=Test,C=DE' is not allowed to impersonate as 'gkar'", e.getMessage()); } - System.out.println("------- 12 ---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); @@ -568,8 +528,7 @@ public void testTransportClientUsernameAttribute() throws Exception { ctx.close(); } - System.out.println("------- 13 ---------"); - ctx = tc.threadPool().getThreadContext().stashContext(); + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); gr = tc.prepareGet(".opendistro_security", "config", "0").setRealtime(Boolean.FALSE).get(); @@ -578,8 +537,7 @@ public void testTransportClientUsernameAttribute() throws Exception { } finally { ctx.close(); } - System.out.println("------- 13.1 ---------"); - + String scrollId = null; ctx = tc.threadPool().getThreadContext().stashContext(); try { @@ -590,8 +548,7 @@ public void testTransportClientUsernameAttribute() throws Exception { ctx.close(); } - System.out.println("------- 13.2 ---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); @@ -601,8 +558,7 @@ public void testTransportClientUsernameAttribute() throws Exception { } - System.out.println("------- 14 ---------"); - + boolean ok=false; ctx = tc.threadPool().getThreadContext().stashContext(); try { @@ -623,8 +579,7 @@ public void testTransportClientUsernameAttribute() throws Exception { ctx.close(); } - System.out.println("------- 15 ---------"); - ctx = tc.threadPool().getThreadContext().stashContext(); + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); gr = tc.prepareGet(".opendistro_security", "security", "config").setRealtime(Boolean.TRUE).get(); @@ -634,8 +589,7 @@ public void testTransportClientUsernameAttribute() throws Exception { ctx.close(); } - System.out.println("------- 15 0---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("worf", "worf"); @@ -650,8 +604,7 @@ public void testTransportClientUsernameAttribute() throws Exception { } - System.out.println("------- 15 1---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("nagilum", "nagilum"); @@ -663,8 +616,7 @@ public void testTransportClientUsernameAttribute() throws Exception { ctx.close(); } - System.out.println("------- 16---------"); - + ctx = tc.threadPool().getThreadContext().stashContext(); try { tc.threadPool().getThreadContext().putHeader("opendistro_security_impersonate_as", "nagilum"); @@ -712,11 +664,9 @@ public void testTransportClientUsernameAttribute() throws Exception { ctx.close(); } - System.out.println("------- TRC end ---------"); - } + } - System.out.println("------- CTC end ---------"); - } + } @Test public void testTransportClientImpersonationUsernameAttribute() throws Exception { diff --git a/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java b/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java index 0d1490997b..466867e38a 100644 --- a/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java +++ b/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java @@ -103,8 +103,7 @@ protected boolean validateJson(final String json) { JsonNode node = DefaultObjectMapper.objectMapper.readTree(json); if(node.get("audit_request_body") != null) { - System.out.println(" Check audit_request_body for validity: "+node.get("audit_request_body").asText()); - DefaultObjectMapper.objectMapper.readTree(node.get("audit_request_body").asText()); + DefaultObjectMapper.objectMapper.readTree(node.get("audit_request_body").asText()); } return true; @@ -130,8 +129,7 @@ protected void updateAuditConfig(final String payload) throws Exception { rh.sendAdminCertificate = true; rh.keystore = "auditlog/kirk-keystore.jks"; RestHelper.HttpResponse response = rh.executePutRequest("_opendistro/_security/api/audit/config", payload, new Header[0]); - System.out.println(response); - rh.sendAdminCertificate = sendAdminCertificate; + rh.sendAdminCertificate = sendAdminCertificate; rh.keystore = keystore; } } diff --git a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java index 5ae312f248..3090049281 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java @@ -117,7 +117,7 @@ public void testComplianceEnable() throws Exception { try { messages = TestAuditlogImpl.doThenWaitForMessages(() -> { rh.executePutRequest("emp/_doc/0?refresh", "{\"Designation\" : \"CEO\", \"Gender\" : \"female\", \"Salary\" : 100}"); - System.out.println(rh.executeGetRequest("_cat/shards?v")); + rh.executeGetRequest("_cat/shards?v"); }, 7); } catch (final MessagesNotFoundException ex) { // indices:admin/mapping/auto_put can be logged twice, this handles if they were not found diff --git a/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java index e5719c3210..7e6fdc9c41 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java @@ -49,8 +49,7 @@ public void testRestApiRolesEnabled() throws Exception { String body = "{ \"password\":\"test\",\"backend_roles\":[\"role1\",\"role2\"] }"; HttpResponse response = rh.executePutRequest("_opendistro/_security/api/internalusers/compuser?pretty", body, encodeBasicHeader("admin", "admin")); Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); Assert.assertTrue(TestAuditlogImpl.messages.size()+"",TestAuditlogImpl.messages.size() == 1); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("audit_request_effective_user")); Assert.assertFalse(TestAuditlogImpl.sb.toString().contains("COMPLIANCE_INTERNAL_CONFIG_READ")); @@ -84,8 +83,7 @@ public void testRestApiRolesDisabled() throws Exception { HttpResponse response = rh.executePutRequest("_opendistro/_security/api/internalusers/compuser?pretty", body); Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); Assert.assertTrue(TestAuditlogImpl.messages.size()+"",TestAuditlogImpl.messages.size() == 1); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("audit_request_effective_user")); Assert.assertFalse(TestAuditlogImpl.sb.toString().contains("COMPLIANCE_INTERNAL_CONFIG_READ")); @@ -116,11 +114,9 @@ public void testRestApiRolesDisabledGet() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; rh.keystore = "kirk-keystore.jks"; - System.out.println("----rest"); - HttpResponse response = rh.executeGetRequest("_opendistro/_security/api/rolesmapping/opendistro_security_all_access?pretty"); + HttpResponse response = rh.executeGetRequest("_opendistro/_security/api/rolesmapping/opendistro_security_all_access?pretty"); Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); Assert.assertTrue(TestAuditlogImpl.messages.size() > 2); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("audit_request_effective_user")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("COMPLIANCE_INTERNAL_CONFIG_READ")); @@ -146,11 +142,9 @@ public void testRestApiNewUser() throws Exception { setup(additionalSettings); TestAuditlogImpl.clear(); String body = "{ \"password\":\"test\",\"backend_roles\":[\"role1\",\"role2\"] }"; - System.out.println("exec"); - HttpResponse response = rh.executePutRequest("_opendistro/_security/api/internalusers/compuser?pretty", body, encodeBasicHeader("admin", "admin")); + HttpResponse response = rh.executePutRequest("_opendistro/_security/api/internalusers/compuser?pretty", body, encodeBasicHeader("admin", "admin")); Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); Assert.assertTrue(TestAuditlogImpl.messages.size()+"", TestAuditlogImpl.messages.isEmpty()); } @@ -176,11 +170,9 @@ public void testRestInternalConfigRead() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; rh.keystore = "kirk-keystore.jks"; - System.out.println("req"); - HttpResponse response = rh.executeGetRequest("_opendistro/_security/api/internalusers/admin?pretty"); + HttpResponse response = rh.executeGetRequest("_opendistro/_security/api/internalusers/admin?pretty"); Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); Assert.assertTrue(TestAuditlogImpl.messages.size()+"",TestAuditlogImpl.messages.size() == 1); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("audit_request_effective_user")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("COMPLIANCE_INTERNAL_CONFIG_READ")); diff --git a/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java index 1885beefcc..f0a8c32b33 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java @@ -94,8 +94,7 @@ public void testSslException() { TestAuditlogImpl.clear(); al.logSSLException((SecurityRequest)null, new Exception("test rest")); al.logSSLException(null, new Exception("test rest"), null, null); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(2, TestAuditlogImpl.messages.size()); + Assert.assertEquals(2, TestAuditlogImpl.messages.size()); } @Test diff --git a/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java b/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java index b3d161a77d..7a7671cf7a 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java @@ -176,8 +176,7 @@ protected void checkCategoriesDisabled(AuditCategory... disabledCategories) thro List allButDisablesCategories = new LinkedList<>(Arrays.asList(AuditCategory.values())); allButDisablesCategories.removeAll(Arrays.asList(disabledCategories)); - System.out.println(result+"###"+disabledCategoriesString); - Assert.assertFalse(categoriesPresentInLog(result, disabledCategories)); + Assert.assertFalse(categoriesPresentInLog(result, disabledCategories)); Assert.assertTrue(categoriesPresentInLog(result, filterComplianceCategories(allButDisablesCategories.toArray(new AuditCategory[] {})))); } @@ -187,8 +186,7 @@ protected boolean categoriesPresentInLog(String result, AuditCategory... categor result = result.replaceAll(" ", ""); for (AuditCategory category : categories) { if(!result.contains("\""+AuditMessage.CATEGORY+"\":\""+category.name()+"\"")) { - System.out.println("MISSING: "+category.name()); - return false; + return false; } } return true; diff --git a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java index 2e114c4b82..0029c3a3dd 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java @@ -72,92 +72,77 @@ public void testHTTPTrace() throws Exception { } - System.out.println("############ check shards"); - System.out.println(rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("admin", "admin"))); + rh.executeGetRequest("_cat/shards?v", encodeBasicHeader("admin", "admin")); - System.out.println("############ check shards"); - System.out.println(rh.executeGetRequest("_opendistro/_security/authinfo",encodeBasicHeader("admin", "admin"))); + rh.executeGetRequest("_opendistro/_security/authinfo",encodeBasicHeader("admin", "admin")); - System.out.println("############ _bulk"); - String bulkBody = + String bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ "{ \"field2\" : \"value2\" }"+System.lineSeparator()+ "{ \"delete\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("admin", "admin")); - System.out.println("############ _bulk"); - bulkBody = + bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ "{ \"field2\" : \"value2\" }"+System.lineSeparator()+ "{ \"delete\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("admin", "admin")); - System.out.println("############ cat indices"); - //cluster:monitor/state + //cluster:monitor/state //cluster:monitor/health //indices:monitor/stats - System.out.println(rh.executeGetRequest("_cat/indices", encodeBasicHeader("admin", "admin"))); + rh.executeGetRequest("_cat/indices", encodeBasicHeader("admin", "admin")); - System.out.println("############ _search"); - //indices:data/read/search - System.out.println(rh.executeGetRequest("_search", encodeBasicHeader("admin", "admin"))); + //indices:data/read/search + rh.executeGetRequest("_search", encodeBasicHeader("admin", "admin")); - System.out.println("############ get 1"); - //indices:data/read/get - System.out.println(rh.executeGetRequest("a/b/1", encodeBasicHeader("admin", "admin"))); - System.out.println("############ get 5"); - System.out.println(rh.executeGetRequest("a/b/5", encodeBasicHeader("admin", "admin"))); - System.out.println("############ get 17"); - System.out.println(rh.executeGetRequest("a/b/17", encodeBasicHeader("admin", "admin"))); + //indices:data/read/get + rh.executeGetRequest("a/b/1", encodeBasicHeader("admin", "admin")); + rh.executeGetRequest("a/b/5", encodeBasicHeader("admin", "admin")); + rh.executeGetRequest("a/b/17", encodeBasicHeader("admin", "admin")); - System.out.println("############ index (+create index)"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/1?refresh=true", "{}",encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("u/b/1?refresh=true", "{}",encodeBasicHeader("admin", "admin")); - System.out.println("############ index only"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{}",encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("u/b/2?refresh=true", "{}",encodeBasicHeader("admin", "admin")); - System.out.println("############ index updates"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{\"n\":1, \"m\":1}",encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{\"n\":2, \"m\":1, \"z\":1}",encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{\"n\":2, \"z\":4}",encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{\"n\":5, \"z\":5}",encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePostRequest("u/b/2?refresh=true", "{\"n\":5}",encodeBasicHeader("admin", "admin"))); - System.out.println("############ update"); - //indices:data/write/index + rh.executePostRequest("u/b/2?refresh=true", "{\"n\":1, \"m\":1}",encodeBasicHeader("admin", "admin")); + rh.executePostRequest("u/b/2?refresh=true", "{\"n\":2, \"m\":1, \"z\":1}",encodeBasicHeader("admin", "admin")); + rh.executePostRequest("u/b/2?refresh=true", "{\"n\":2, \"z\":4}",encodeBasicHeader("admin", "admin")); + rh.executePostRequest("u/b/2?refresh=true", "{\"n\":5, \"z\":5}",encodeBasicHeader("admin", "admin")); + rh.executePostRequest("u/b/2?refresh=true", "{\"n\":5}",encodeBasicHeader("admin", "admin")); + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"a\":1}}",encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("u/b/2/_update?refresh=true", "{\"doc\" : {\"a\":1}}",encodeBasicHeader("admin", "admin")); - System.out.println("############ delete"); - //indices:data/write/index + //indices:data/write/index //indices:data/write/bulk //indices:admin/create //indices:data/write/bulk[s] - System.out.println(rh.executeDeleteRequest("u/b/2?refresh=true",encodeBasicHeader("admin", "admin"))); + rh.executeDeleteRequest("u/b/2?refresh=true",encodeBasicHeader("admin", "admin")); - System.out.println("############ reindex"); - String reindex = + String reindex = "{"+ " \"source\": {"+ " \"index\": \"a\""+ @@ -167,11 +152,10 @@ public void testHTTPTrace() throws Exception { " }"+ "}"; - System.out.println(rh.executePostRequest("_reindex", reindex, encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("_reindex", reindex, encodeBasicHeader("admin", "admin")); - System.out.println("############ msearch"); - String msearchBody = + String msearchBody = "{\"index\":\"a\", \"type\":\"b\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+ "{\"index\":\"a\", \"type\":\"b\", \"ignore_unavailable\": true}"+System.lineSeparator()+ @@ -180,10 +164,9 @@ public void testHTTPTrace() throws Exception { "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println(rh.executePostRequest("_msearch", msearchBody, encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("_msearch", msearchBody, encodeBasicHeader("admin", "admin")); - System.out.println("############ mget"); - String mgetBody = "{"+ + String mgetBody = "{"+ "\"docs\" : ["+ "{"+ "\"_index\" : \"a\","+ @@ -207,10 +190,9 @@ public void testHTTPTrace() throws Exception { "]"+ "}"; - System.out.println(rh.executePostRequest("_mget?refresh=true", mgetBody, encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("_mget?refresh=true", mgetBody, encodeBasicHeader("admin", "admin")); - System.out.println("############ delete by query"); - String dbqBody = "{"+ + String dbqBody = "{"+ ""+ " \"query\": { "+ " \"match\": {"+ @@ -219,7 +201,7 @@ public void testHTTPTrace() throws Exception { " }"+ "}"; - System.out.println(rh.executePostRequest("a/b/_delete_by_query", dbqBody, encodeBasicHeader("admin", "admin"))); + rh.executePostRequest("a/b/_delete_by_query", dbqBody, encodeBasicHeader("admin", "admin")); Thread.sleep(5000); } @@ -260,20 +242,13 @@ public void uncaughtException(Thread t, Throwable e) { } - System.out.println("########pause1"); - Thread.sleep(5000); - System.out.println("########end pause1"); - - System.out.println("########search"); - Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_search", encodeBasicHeader("admin", "admin")).getStatusCode()); - System.out.println("########search done"); - - System.out.println("########pause2"); - Thread.sleep(5000); - System.out.println("########end pause2"); - - System.out.println("############ _bulk"); - String bulkBody = + Thread.sleep(5000); + + Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_search", encodeBasicHeader("admin", "admin")).getStatusCode()); + + Thread.sleep(5000); + + String bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+ @@ -284,9 +259,8 @@ public void uncaughtException(Thread t, Throwable e) { "{ \"index\" : { \"_index\" : \"myindex\", \"_type\" : \"myindex\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator(); - System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("admin", "admin")).getBody()); - System.out.println("############ _end"); - Thread.sleep(5000); + rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("admin", "admin")).getBody(); + Thread.sleep(5000); } @Test @@ -313,20 +287,15 @@ public void uncaughtException(Thread t, Throwable e) { } - System.out.println("########search"); - HttpResponse res; + HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executeGetRequest("vulcangov/_search?scroll=1m&pretty=true", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - int start = res.getBody().indexOf("_scroll_id") + 15; + int start = res.getBody().indexOf("_scroll_id") + 15; String scrollid = res.getBody().substring(start, res.getBody().indexOf("\"", start+1)); - System.out.println(scrollid); - System.out.println("########search scroll"); - Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("admin", "admin"))).getStatusCode()); - + Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println("########search done"); + } @@ -352,33 +321,26 @@ public void testAdvancedMapping() throws Exception { .mapping("mytype4", FileHelper.loadFile("mapping4.json"), XContentType.JSON)).actionGet(); } - System.out.println("############ write into mapping 1"); - String data1 = FileHelper.loadFile("auditlog/data1.json"); + String data1 = FileHelper.loadFile("auditlog/data1.json"); String data2 = FileHelper.loadFile("auditlog/data1mod.json"); - System.out.println(rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("admin", "admin"))); - System.out.println("############ write into mapping diffing"); - System.out.println(rh.executePutRequest("myindex1/mytype1/1?refresh", data2, encodeBasicHeader("admin", "admin"))); + rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("admin", "admin")); + rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("admin", "admin")); + rh.executePutRequest("myindex1/mytype1/1?refresh", data2, encodeBasicHeader("admin", "admin")); - System.out.println("############ write into mapping 2"); - System.out.println(rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePutRequest("myindex2/mytype2/2?refresh", data2, encodeBasicHeader("admin", "admin"))); + rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("admin", "admin")); + rh.executePutRequest("myindex2/mytype2/2?refresh", data2, encodeBasicHeader("admin", "admin")); - System.out.println("############ write into mapping 3"); - String parent = FileHelper.loadFile("auditlog/data2.json"); + String parent = FileHelper.loadFile("auditlog/data2.json"); String child = FileHelper.loadFile("auditlog/data3.json"); - System.out.println(rh.executePutRequest("myindex3/mytype3/1?refresh", parent, encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePutRequest("myindex3/mytype3/2?routing=1&refresh", child, encodeBasicHeader("admin", "admin"))); + rh.executePutRequest("myindex3/mytype3/1?refresh", parent, encodeBasicHeader("admin", "admin")); + rh.executePutRequest("myindex3/mytype3/2?routing=1&refresh", child, encodeBasicHeader("admin", "admin")); - System.out.println("############ write into mapping 4"); - System.out.println(rh.executePutRequest("myindex4/mytype4/1?refresh", parent, encodeBasicHeader("admin", "admin"))); - System.out.println(rh.executePutRequest("myindex4/mytype4/2?routing=1&refresh", child, encodeBasicHeader("admin", "admin"))); + rh.executePutRequest("myindex4/mytype4/1?refresh", parent, encodeBasicHeader("admin", "admin")); + rh.executePutRequest("myindex4/mytype4/2?routing=1&refresh", child, encodeBasicHeader("admin", "admin")); - System.out.println("############ get"); - System.out.println(rh.executeGetRequest("myindex1/mytype1/1?pretty=true&_source=true&_source_include=*.id&_source_exclude=entities&stored_fields=tags,counter", encodeBasicHeader("admin", "admin")).getBody()); + rh.executeGetRequest("myindex1/mytype1/1?pretty=true&_source=true&_source_include=*.id&_source_exclude=entities&stored_fields=tags,counter", encodeBasicHeader("admin", "admin")).getBody(); - System.out.println("############ search"); - System.out.println(rh.executeGetRequest("myindex1/_search", encodeBasicHeader("admin", "admin")).getStatusCode()); + rh.executeGetRequest("myindex1/_search", encodeBasicHeader("admin", "admin")).getStatusCode(); } @@ -401,8 +363,7 @@ public void testImmutableIndex() throws Exception { .mapping("mytype2", FileHelper.loadFile("mapping1.json"), XContentType.JSON)).actionGet(); } - System.out.println("############ immutable 1"); - String data1 = FileHelper.loadFile("auditlog/data1.json"); + String data1 = FileHelper.loadFile("auditlog/data1.json"); String data2 = FileHelper.loadFile("auditlog/data1mod.json"); HttpResponse res = rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("admin", "admin")); Assert.assertEquals(201, res.getStatusCode()); @@ -415,8 +376,7 @@ public void testImmutableIndex() throws Exception { Assert.assertFalse(res.getBody().contains("city")); Assert.assertTrue(res.getBody().contains("\"found\":true,")); - System.out.println("############ immutable 2"); - res = rh.executePutRequest("myindex2/mytype2/1?refresh", data1, encodeBasicHeader("admin", "admin")); + res = rh.executePutRequest("myindex2/mytype2/1?refresh", data1, encodeBasicHeader("admin", "admin")); Assert.assertEquals(201, res.getStatusCode()); res = rh.executePutRequest("myindex2/mytype2/1?refresh", data2, encodeBasicHeader("admin", "admin")); Assert.assertEquals(200, res.getStatusCode()); diff --git a/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java index 01be96dc12..2883f01317 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java @@ -153,22 +153,19 @@ public void testSimpleTransportAuthenticated() throws Exception { setupStarfleetIndex(); TestAuditlogImpl.clear(); - System.out.println("#### testSimpleAuthenticated"); - try (TransportClient tc = getUserTransportClient(clusterInfo, "spock-keystore.jks", Settings.EMPTY)) { + try (TransportClient tc = getUserTransportClient(clusterInfo, "spock-keystore.jks", Settings.EMPTY)) { StoredContext ctx = tc.threadPool().getThreadContext().stashContext(); try { Header header = encodeBasicHeader("admin", "admin"); tc.threadPool().getThreadContext().putHeader(header.getName(), header.getValue()); SearchResponse res = tc.search(new SearchRequest()).actionGet(); - System.out.println(res); - } finally { + } finally { ctx.close(); } } Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue("Was "+TestAuditlogImpl.messages.size(), TestAuditlogImpl.messages.size() >= 2); + Assert.assertTrue("Was "+TestAuditlogImpl.messages.size(), TestAuditlogImpl.messages.size() >= 2); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("GRANTED_PRIVILEGES")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("AUTHENTICATED")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices:data/read/search")); @@ -198,15 +195,13 @@ public void testTaskId() throws Exception { Header header = encodeBasicHeader("admin", "admin"); tc.threadPool().getThreadContext().putHeader(header.getName(), header.getValue()); SearchResponse res = tc.search(new SearchRequest()).actionGet(); - System.out.println(res); - } finally { + } finally { ctx.close(); } } Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue(String.valueOf(TestAuditlogImpl.messages.size()), TestAuditlogImpl.messages.size() >= 2); + Assert.assertTrue(String.valueOf(TestAuditlogImpl.messages.size()), TestAuditlogImpl.messages.size() >= 2); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("GRANTED_PRIVILEGES")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("AUTHENTICATED")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices:data/read/search")); @@ -236,8 +231,7 @@ public void testDefaultsRest() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); Thread.sleep(1500); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(2, TestAuditlogImpl.messages.size()); + Assert.assertEquals(2, TestAuditlogImpl.messages.size()); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("GRANTED_PRIVILEGES")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("AUTHENTICATED")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices:data/read/search")); @@ -372,13 +366,11 @@ public void testUnknownAuthorization() throws Exception { public void testUnauthenticated() throws Exception { - System.out.println("#### testUnauthenticated"); - HttpResponse response = rh.executeGetRequest("_search"); + HttpResponse response = rh.executeGetRequest("_search"); Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusCode()); Thread.sleep(1500); Assert.assertEquals(1, TestAuditlogImpl.messages.size()); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("FAILED_LOGIN")); + Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("FAILED_LOGIN")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("/_search")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains(AuditMessage.UTC_TIMESTAMP)); @@ -443,11 +435,9 @@ public void testMsearch() throws Exception { "{\"index\":\"sf\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":0,\"query\":{\"match_all\":{}}}"+System.lineSeparator(); - System.out.println("##### msaerch"); - HttpResponse response = rh.executePostRequest("_msearch?pretty", msearch, encodeBasicHeader("admin", "admin")); + HttpResponse response = rh.executePostRequest("_msearch?pretty", msearch, encodeBasicHeader("admin", "admin")); Assert.assertEquals(response.getStatusReason(), HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue(TestAuditlogImpl.sb.toString(), TestAuditlogImpl.sb.toString().contains("indices:data/read/msearch")); + Assert.assertTrue(TestAuditlogImpl.sb.toString(), TestAuditlogImpl.sb.toString().contains("indices:data/read/msearch")); Assert.assertTrue(TestAuditlogImpl.sb.toString(), TestAuditlogImpl.sb.toString().contains("indices:data/read/search")); Assert.assertTrue(TestAuditlogImpl.sb.toString(), TestAuditlogImpl.sb.toString().contains("match_all")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("audit_trace_task_id")); @@ -459,8 +449,7 @@ public void testMsearch() throws Exception { public void testBulkAuth() throws Exception { - System.out.println("#### testBulkAuth"); - String bulkBody = + String bulkBody = "{ \"index\" : { \"_index\" : \"test\", \"_id\" : \"1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \"worf\", \"_id\" : \"2\" } }"+System.lineSeparator()+ @@ -474,8 +463,7 @@ public void testBulkAuth() throws Exception { HttpResponse response = rh.executePostRequest("_bulk", bulkBody, encodeBasicHeader("admin", "admin")); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); Assert.assertTrue(response.getBody().contains("\"errors\":false")); Assert.assertTrue(response.getBody().contains("\"status\":201")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices:admin/auto_create")); @@ -503,10 +491,8 @@ public void testBulkNonAuth() throws Exception { "{ \"field1\" : \"value3x\" }"+System.lineSeparator(); HttpResponse response = rh.executePostRequest("_bulk", bulkBody, encodeBasicHeader("worf", "worf")); - System.out.println(response.getBody()); - - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); + + Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); Assert.assertTrue(response.getBody().contains("\"errors\":true")); Assert.assertTrue(response.getBody().contains("\"status\":200")); Assert.assertTrue(response.getBody().contains("\"status\":403")); @@ -606,8 +592,7 @@ public void testAliases() throws Exception { HttpResponse response = rh.executeGetRequest("sf/_search?pretty", encodeBasicHeader("admin", "admin")); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("starfleet_academy")); + Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("starfleet_academy")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("starfleet_library")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("starfleet")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("sf")); @@ -648,8 +633,7 @@ public void testScroll() throws Exception { TestAuditlogImpl.clear(); Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("admin2", "admin"))).getStatusCode()); Thread.sleep(1000); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("InternalScrollSearchRequest")); + Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("InternalScrollSearchRequest")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("MISSING_PRIVILEGES")); Assert.assertTrue(TestAuditlogImpl.messages.size() > 2); Assert.assertTrue(validateMsgs(TestAuditlogImpl.messages)); @@ -679,8 +663,7 @@ public void testAliasResolution() throws Exception { TestAuditlogImpl.clear(); HttpResponse response = rh.executeGetRequest("thealias/_search?pretty", encodeBasicHeader("admin", "admin")); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("thealias")); + Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("thealias")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("audit_trace_resolved_indices")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("vulcangov")); Assert.assertEquals(1, TestAuditlogImpl.messages.size()); @@ -704,8 +687,7 @@ public void testAliasBadHeaders() throws Exception { TestAuditlogImpl.clear(); HttpResponse response = rh.executeGetRequest("_search?pretty", new BasicHeader("_opendistro_security_user", "xxx"), encodeBasicHeader("admin", "admin")); Assert.assertEquals(HttpStatus.SC_FORBIDDEN, response.getStatusCode()); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertFalse(TestAuditlogImpl.sb.toString().contains("YWRtaW46YWRtaW4")); + Assert.assertFalse(TestAuditlogImpl.sb.toString().contains("YWRtaW46YWRtaW4")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("BAD_HEADERS")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("xxx")); Assert.assertEquals(1, TestAuditlogImpl.messages.size()); @@ -738,8 +720,7 @@ public void testIndexCloseDelete() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); response = rh.executePostRequest("index2/_close?pretty", "", encodeBasicHeader("admin", "admin")); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(TestAuditlogImpl.sb.toString()); - Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices:admin/close")); + Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices:admin/close")); Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices:admin/delete")); Assert.assertTrue(TestAuditlogImpl.sb.toString(), TestAuditlogImpl.messages.size() >= 2); Assert.assertTrue(validateMsgs(TestAuditlogImpl.messages)); diff --git a/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java index 910607af9a..36bb1a25dc 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java @@ -91,8 +91,7 @@ public void testExternalPemUserPass() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); response = rhMon.executeGetRequest("security-auditlog*/_search", encodeBasicHeader("admin", "admin")); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(response.getBody()); - assertNotContains(response, "*\"hits\":{\"total\":0,*"); + assertNotContains(response, "*\"hits\":{\"total\":0,*"); assertContains(response, "*\"failed\":0},\"hits\":*"); } @@ -126,8 +125,7 @@ public void testExternalPemClientAuth() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); response = rhMon.executeGetRequest("security-auditlog*/_search", encodeBasicHeader("admin", "admin")); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(response.getBody()); - assertNotContains(response, "*\"hits\":{\"total\":0,*"); + assertNotContains(response, "*\"hits\":{\"total\":0,*"); assertContains(response, "*\"failed\":0},\"hits\":*"); } @@ -159,8 +157,7 @@ public void testExternalPemUserPassTp() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); response = rhMon.executeGetRequest("security-auditlog-*/_search", encodeBasicHeader("admin", "admin")); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(response.getBody()); - assertNotContains(response, "*\"hits\":{\"total\":0,*"); + assertNotContains(response, "*\"hits\":{\"total\":0,*"); assertContains(response, "*\"failed\":0},\"hits\":*"); } } diff --git a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java index f59420fee4..6bbe09bc6a 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java @@ -131,8 +131,7 @@ private SSLContext createSSLContext() throws Exception { } private void assertStringContainsAllKeysAndValues(String in) { - System.out.println(in); - Assert.assertTrue(in, in.contains(AuditMessage.FORMAT_VERSION)); + Assert.assertTrue(in, in.contains(AuditMessage.FORMAT_VERSION)); Assert.assertTrue(in, in.contains(AuditMessage.CATEGORY)); Assert.assertTrue(in, in.contains(AuditMessage.FORMAT_VERSION)); Assert.assertTrue(in, in.contains(AuditMessage.REMOTE_ADDRESS)); diff --git a/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java b/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java index 2efe9ad40c..6c8bd16e7d 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java @@ -146,8 +146,7 @@ public void formatsTest() throws Exception { .build(); auditlog = new MockWebhookAuditLog(settings, ConfigConstants.SECURITY_AUDIT_CONFIG_DEFAULT, null); auditlog.store(msg); - System.out.println(auditlog.payload); - Assert.assertEquals(WebhookFormat.JSON, auditlog.webhookFormat); + Assert.assertEquals(WebhookFormat.JSON, auditlog.webhookFormat); Assert.assertEquals(ContentType.APPLICATION_JSON, auditlog.webhookFormat.getContentType()); Assert.assertTrue(auditlog.payload, !auditlog.payload.startsWith("{\"text\":")); Assert.assertTrue(auditlog.payload, auditlog.payload.contains(AuditMessage.UTC_TIMESTAMP)); @@ -269,8 +268,7 @@ public void postGetHttpTest() throws Exception { auditlog.store(msg); Assert.assertTrue(handler.method.equals("POST")); Assert.assertTrue(handler.body != null); - System.out.println(handler.body); - Assert.assertFalse(handler.body.contains("{")); + Assert.assertFalse(handler.body.contains("{")); assertStringContainsAllKeysAndValues(handler.body); handler.reset(); @@ -722,8 +720,7 @@ private SSLContext createSSLContext() throws Exception { } private void assertStringContainsAllKeysAndValues(String in) { - System.out.println(in); - Assert.assertTrue(in, in.contains(AuditMessage.FORMAT_VERSION)); + Assert.assertTrue(in, in.contains(AuditMessage.FORMAT_VERSION)); Assert.assertTrue(in, in.contains(AuditMessage.CATEGORY)); Assert.assertTrue(in, in.contains(AuditMessage.FORMAT_VERSION)); Assert.assertTrue(in, in.contains(AuditMessage.REMOTE_ADDRESS)); diff --git a/src/test/java/org/opensearch/security/cache/CachingTest.java b/src/test/java/org/opensearch/security/cache/CachingTest.java index 3627de1657..3e7a363456 100644 --- a/src/test/java/org/opensearch/security/cache/CachingTest.java +++ b/src/test/java/org/opensearch/security/cache/CachingTest.java @@ -47,14 +47,11 @@ public void testRestCaching() throws Exception { setup(Settings.EMPTY, new DynamicSecurityConfig(), Settings.EMPTY); final RestHelper rh = nonSslRestHelper(); HttpResponse res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty"); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty"); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty"); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertEquals(3, DummyHTTPAuthenticator.getCount()); Assert.assertEquals(1, DummyAuthorizer.getCount()); @@ -68,14 +65,11 @@ public void testRestNoCaching() throws Exception { setup(Settings.EMPTY, new DynamicSecurityConfig(), settings); final RestHelper rh = nonSslRestHelper(); HttpResponse res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty"); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty"); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty"); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertEquals(3, DummyHTTPAuthenticator.getCount()); Assert.assertEquals(3, DummyAuthorizer.getCount()); @@ -89,17 +83,13 @@ public void testRestCachingWithImpersonation() throws Exception { setup(Settings.EMPTY, new DynamicSecurityConfig(), settings); final RestHelper rh = nonSslRestHelper(); HttpResponse res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty", new BasicHeader("opendistro_security_impersonate_as", "impuser")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty", new BasicHeader("opendistro_security_impersonate_as", "impuser")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty", new BasicHeader("opendistro_security_impersonate_as", "impuser")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); res = rh.executeGetRequest("_opendistro/_security/authinfo?pretty", new BasicHeader("opendistro_security_impersonate_as", "impuser2")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertEquals(4, DummyHTTPAuthenticator.getCount()); Assert.assertEquals(3, DummyAuthorizer.getCount()); diff --git a/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java index 90e5010b4b..f95b35ce0b 100644 --- a/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java +++ b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java @@ -156,8 +156,7 @@ private Tuple setupCluster(ClusterHelper ch, ClusterTra RestHelper rh = new RestHelper(clusterInfo, httpsEnabled, httpsEnabled, getResourceFolder()); rh.sendAdminCertificate = httpsEnabled; rh.keystore = "restapi/kirk-keystore.jks"; - System.out.println("### " + ch.getClusterName() + " complete ###"); - return new Tuple<>(clusterInfo, rh); + return new Tuple<>(clusterInfo, rh); } @After @@ -192,32 +191,24 @@ public void testCcs() throws Exception { HttpResponse ccs = null; - System.out.println("###################### query 1"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("crl1")); Assert.assertTrue(ccs.getBody().contains("crl2")); Assert.assertTrue(ccs.getBody().contains("twitter")); - System.out.println("###################### query 4"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:xx,xx/xx/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); - System.out.println(ccs.getBody()); - //TODO fix exception nesting + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:xx,xx/xx/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); + //TODO fix exception nesting //Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, ccs.getStatusCode()); //Assert.assertTrue(ccs.getBody().contains("Can not filter indices; index cross_cluster_two:xx exists but there is also a remote cluster named: cross_cluster_two")); - System.out.println("###################### query 5"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:abcnonext/xx/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_NOT_FOUND, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:abcnonext/xx/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); + Assert.assertEquals(HttpStatus.SC_NOT_FOUND, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("index_not_found_exception")); - System.out.println("###################### query 6"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twutter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twutter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("security_exception")); Assert.assertTrue(ccs.getBody().contains("\"timed_out\" : false")); Assert.assertTrue(ccs.getBody().contains("crl1")); @@ -255,144 +246,107 @@ public void testCcsNonadmin() throws Exception { HttpResponse ccs = null; - System.out.println("###################### query 1"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); - System.out.println("###################### query 2"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twit*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twit*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); - System.out.println("###################### query 3"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter,twutter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter,twutter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); - System.out.println("###################### query 4"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("crl1_")); Assert.assertTrue(ccs.getBody().contains("crl2_")); - System.out.println("###################### query 5"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); - System.out.println("###################### query 6"); - String msearchBody = + String msearchBody = "{}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter,twitter/tweet/_msearch?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, msearchBody, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); - System.out.println("###################### query 7"); - msearchBody = + msearchBody = "{}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter/tweet/_msearch?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, msearchBody, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("_all/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("*:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("hfghgtdhfhuth/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("hfghgtdhfhuth*/_search", encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("\"hits\":[]")); //TODO: Change for 25.0 to be forbidden (Indices options) ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest(":*/_search", encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("\"hits\":[]")); //TODO: Change for 25.0 to be forbidden (Indices options) ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("*:/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:%3Clogstash-%7Bnow%2Fd%7D%3E,%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias,coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); - System.out.println("#### Alias both"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias,coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias,coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("notexist,coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); //TODO Fix for 25.0 to resolve coordalias (Indices options) ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("crusherw","crusherw")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); } @@ -426,152 +380,114 @@ public void testCcsNonadminDnfof() throws Exception { HttpResponse ccs = null; - System.out.println("###################### query 1"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("crl1_")); Assert.assertTrue(ccs.getBody().contains("crl2_")); - System.out.println("###################### query 2"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twit*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twit*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); - System.out.println("###################### query 3"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter,twutter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter,twutter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("twutter")); - System.out.println("###################### query 4"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("crl1_")); Assert.assertTrue(ccs.getBody().contains("crl2_")); - System.out.println("###################### query 5"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); - System.out.println("###################### query 6"); - String msearchBody = + String msearchBody = "{}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter,twitter/tweet/_msearch?pretty", msearchBody, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); - System.out.println("###################### query 7"); - msearchBody = + msearchBody = "{}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter/tweet/_msearch?pretty", msearchBody, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("_all/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); - System.out.println("#####*"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*,*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:*,*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("crl1_")); Assert.assertTrue(ccs.getBody().contains("crl2_")); //wildcard in remote cluster names ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("*cross*:*twit*,*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,t*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("*:*/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("hfghgtdhfhuth/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("hfghgtdhfhuth*/_search", encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("\"hits\":[]")); //TODO: Change for 25.0 to be forbidden (Indices options) ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest(":*/_search", encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("\"hits\":[]")); //TODO: Change for 25.0 to be forbidden (Indices options) ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("*:/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:%3Clogstash-%7Bnow%2Fd%7D%3E,%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias,coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("worf","worf")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:remotealias,coordalias/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("crusherw","crusherw")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); } @Test @@ -591,10 +507,8 @@ public void testCcsEmptyCoord() throws Exception { HttpResponse ccs = null; - System.out.println("###################### query 1"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("security_exception")); Assert.assertTrue(ccs.getBody().contains("\"timed_out\" : false")); Assert.assertFalse(ccs.getBody().contains("crl1")); @@ -627,8 +541,7 @@ public void testCcsDashboardsAggregations() throws Exception { HttpResponse ccs = null; - System.out.println("###################### kibana indices agg"); - String dashboardsIndicesAgg = "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":100}}}}"; + String dashboardsIndicesAgg = "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":100}}}}"; ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("*/_search?pretty", dashboardsIndicesAgg, encodeBasicHeader("nagilum","nagilum")); Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("security_exception")); @@ -712,8 +625,7 @@ public void testCcsDashboardsAggregationsNonAdminDnfof() throws Exception { HttpResponse ccs = null; - System.out.println("###################### kibana indices agg"); - String dashboardsIndicesAgg = "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":100}}}}"; + String dashboardsIndicesAgg = "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":100}}}}"; ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("*/_search?pretty", dashboardsIndicesAgg, encodeBasicHeader("twitter","nagilum")); Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("security_exception")); @@ -797,8 +709,7 @@ public void testCcsAggregations() throws Exception { HttpResponse ccs = null; - System.out.println("###################### aggs"); - final String agg = "{\"size\":0,\"aggs\":{\"clusteragg\":{\"terms\":{\"field\":\"cluster.keyword\",\"size\":100}}}}"; + final String agg = "{\"size\":0,\"aggs\":{\"clusteragg\":{\"terms\":{\"field\":\"cluster.keyword\",\"size\":100}}}}"; ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("*:*,*/_search?pretty", agg, encodeBasicHeader("nagilum","nagilum")); Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("security_exception")); @@ -867,8 +778,7 @@ public void testCcsAggregationsDnfof() throws Exception { HttpResponse ccs = null; - System.out.println("###################### aggs"); - final String agg = "{\"size\":0,\"aggs\":{\"clusteragg\":{\"terms\":{\"field\":\"cluster.keyword\",\"size\":100}}}}"; + final String agg = "{\"size\":0,\"aggs\":{\"clusteragg\":{\"terms\":{\"field\":\"cluster.keyword\",\"size\":100}}}}"; ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:notfound,*/_search?pretty", agg, encodeBasicHeader("twitter","nagilum")); Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode()); ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:notfound*,*/_search?pretty", agg, encodeBasicHeader("twitter","nagilum")); @@ -944,8 +854,7 @@ public void testCcsWithDiffCertsWithNoNodesDnUpdate() throws Exception { String uri = "cross_cluster_two:twitter/tweet/_search?pretty"; HttpResponse ccs = rh1.executeGetRequest(uri, encodeBasicHeader("twitter", "nagilum")); - System.out.println(ccs.getBody()); - assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_INTERNAL_SERVER_ERROR)); + assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_INTERNAL_SERVER_ERROR)); assertThat(ccs.getBody(), containsString("no OID or security.nodes_dn incorrect configured")); } @@ -966,8 +875,7 @@ public void testCcsWithDiffCertsWithNodesDnStaticallyAdded() throws Exception { String uri = "cross_cluster_two:twitter/tweet/_search?pretty"; HttpResponse ccs = rh1.executeGetRequest(uri, encodeBasicHeader("twitter", "nagilum")); - System.out.println(ccs.getBody()); - assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_OK)); + assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_OK)); assertThat(ccs.getBody(), not(containsString("security_exception"))); assertThat(ccs.getBody(), containsString("\"timed_out\" : false")); assertThat(ccs.getBody(), not(containsString("crl1"))); @@ -991,8 +899,7 @@ public void testCcsWithDiffCertsWithNodesDnDynamicallyAdded() throws Exception { String uri = "cross_cluster_two:twitter/tweet/_search?pretty"; HttpResponse ccs = rh1.executeGetRequest(uri, encodeBasicHeader("twitter", "nagilum")); - System.out.println(ccs.getBody()); - assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_OK)); + assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_OK)); assertThat(ccs.getBody(), not(containsString("security_exception"))); assertThat(ccs.getBody(), containsString("\"timed_out\" : false")); assertThat(ccs.getBody(), not(containsString("crl1"))); @@ -1054,8 +961,7 @@ public void testCcsWithRoleInjection() throws Exception { OpenSearchSecurityException exception = null; - System.out.println("###################### with invalid role injection"); - //1. With invalid roles injection + //1. With invalid roles injection RolesInjectorIntegTest.RolesInjectorPlugin.injectedRoles = "invalid_user|invalid_role"; try (Node node = new PluginAwareNode(false, tcSettings, Netty4Plugin.class, OpenSearchSecurityPlugin.class, RolesInjectorIntegTest.RolesInjectorPlugin.class).start()) { @@ -1074,8 +980,7 @@ public void testCcsWithRoleInjection() throws Exception { Assert.assertNotNull(exception); Assert.assertTrue(exception.getMessage().contains("no permissions for")); - System.out.println("###################### with valid role injection"); - //2. With valid roles injection + //2. With valid roles injection RolesInjectorIntegTest.RolesInjectorPlugin.injectedRoles = "valid_user|opendistro_security_all_access"; try (Node node = new PluginAwareNode(false, tcSettings, Netty4Plugin.class, OpenSearchSecurityPlugin.class, RolesInjectorIntegTest.RolesInjectorPlugin.class).start()) { diff --git a/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java b/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java index 049ae9924c..eb4a84e3a3 100644 --- a/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java +++ b/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java @@ -120,14 +120,11 @@ public void testNonSSLReindex() throws Exception { "}"+ "}"; - System.out.println(reindex); - + HttpResponse ccs = null; - System.out.println("###################### reindex"); - ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("_reindex?pretty", reindex, encodeBasicHeader("nagilum","nagilum")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("_reindex?pretty", reindex, encodeBasicHeader("nagilum","nagilum")); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("created\" : 1")); } } diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java index 5f60cfad92..e8edd03c6c 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java @@ -69,8 +69,7 @@ public void testComplexMappingAggregationsRace() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/logs/_search?pretty&size=0", query, encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - + Assert.assertTrue(res.getBody().contains("win 8")); Assert.assertTrue(res.getBody().contains("win xp")); Assert.assertTrue(res.getBody().contains("ios")); @@ -90,16 +89,14 @@ public void testComplexMappingAggregationsRace() throws Exception { for(int i=0;i<10;i++) { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/logs/_search?pretty&size=0", query, encodeBasicHeader("user_masked_nowc1", "password"))).getStatusCode()); - System.out.println(res.getBody()); - } + } for(int i=0;i<10;i++) { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/logs/_search?pretty&size=0", query, encodeBasicHeader("user_masked_nowc", "password"))).getStatusCode()); - System.out.println(res.getBody()); - + Assert.assertFalse(res.getBody().contains("\"aaa")); Assert.assertTrue(res.getBody().contains("047f2c11be727")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java index bc2551b15d..1c9741572a 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java @@ -67,8 +67,7 @@ public void testMaskedAggregations() throws Exception { "}"+ "}"; res = rh.executePostRequest("/deals/_search?pretty&size=0", query, encodeBasicHeader("user_masked_custom", "password")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertFalse(res.getBody().contains("100.100")); Assert.assertTrue(res.getBody().contains("***")); Assert.assertTrue(res.getBody().contains("XXX")); @@ -92,8 +91,7 @@ public void testMaskedAggregations() throws Exception { "}"; res = rh.executePostRequest("/deals/_search?pretty&size=0", query, encodeBasicHeader("user_masked_custom", "password")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertFalse(res.getBody().contains("100.100")); Assert.assertTrue(res.getBody().contains("***")); Assert.assertTrue(res.getBody().contains("XXX")); @@ -117,8 +115,7 @@ public void testMaskedAggregations() throws Exception { "}"; res = rh.executePostRequest("/deals/_search?pretty&size=0", query, encodeBasicHeader("user_masked_custom", "password")); - System.out.println(res.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode()); Assert.assertFalse(res.getBody().contains("100.100")); Assert.assertTrue(res.getBody().contains("***")); Assert.assertTrue(res.getBody().contains("XXX")); @@ -189,8 +186,7 @@ public void testCustomMaskedSearch() throws Exception { Assert.assertFalse(res.getBody().contains("XXX")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=100", encodeBasicHeader("user_masked_custom", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 32,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 32,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("cust1")); Assert.assertFalse(res.getBody().contains("cust2")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java index 88613bb050..0f219e1692 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java @@ -60,8 +60,7 @@ public void testSearch() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); @@ -69,8 +68,7 @@ public void testSearch() throws Exception { Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/logs/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); @@ -86,14 +84,12 @@ public void testFieldCaps() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/_field_caps?fields=*&pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("ipaddr")); + Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/_field_caps?fields=*&pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("ipaddr")); + Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); Assert.assertTrue(res.getBody().contains("msgid")); } @@ -106,8 +102,7 @@ public void testSearchWc() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-*/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); @@ -115,8 +110,7 @@ public void testSearchWc() throws Exception { Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-*/logs/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); @@ -132,8 +126,7 @@ public void testSearchWc2() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-1-*,logstash-20*/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); @@ -141,8 +134,7 @@ public void testSearchWc2() throws Exception { Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-1-*,logstash-20*/logs/_search?pretty", encodeBasicHeader("regex", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java index 2b85828141..b625f41980 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java @@ -61,13 +61,11 @@ public void testDlsDateMathQuery() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash/_search?pretty", encodeBasicHeader("date_math", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 3,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 3,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); } @@ -78,13 +76,11 @@ public void testDlsDateMathQueryNotAllowed() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, (res = rh.executeGetRequest("/logstash/_search?pretty", encodeBasicHeader("date_math", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("'now' is not allowed in DLS queries")); + Assert.assertTrue(res.getBody().contains("'now' is not allowed in DLS queries")); Assert.assertTrue(res.getBody().contains("error")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 3,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 3,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); } } diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java index aee4a9dd87..25ced7c198 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java @@ -65,14 +65,11 @@ private void setupCcs(String remoteRoles) throws Exception { cl2Info = cl2.startCluster(minimumSecuritySettings(Settings.EMPTY), ClusterConfiguration.DEFAULT); initialize(cl2Info, Settings.EMPTY, new DynamicSecurityConfig().setSecurityRoles(remoteRoles)); - System.out.println("### cl2 complete ###"); - + //cl1 is coordinating cl1Info = cl1.startCluster(minimumSecuritySettings(crossClusterNodeSettings(cl2Info)), ClusterConfiguration.DEFAULT); - System.out.println("### cl1 start ###"); - initialize(cl1Info, Settings.EMPTY, new DynamicSecurityConfig().setSecurityRoles("roles_983.yml")); - System.out.println("### cl1 initialized ###"); - } + initialize(cl1Info, Settings.EMPTY, new DynamicSecurityConfig().setSecurityRoles("roles_983.yml")); + } @After public void tearDown() throws Exception { @@ -124,11 +121,9 @@ public void testCcs() throws Exception { HttpResponse ccs = null; - System.out.println("###################### query 1"); - //on coordinating cluster + //on coordinating cluster ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:humanresources/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("human_resources_trainee", "password")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("crl1")); Assert.assertTrue(ccs.getBody().contains("crl2")); Assert.assertTrue(ccs.getBody().contains("\"value\" : 1,\n \"relation")); @@ -181,11 +176,9 @@ public void testCcsDifferentConfig() throws Exception { HttpResponse ccs = null; - System.out.println("###################### query 1"); - //on coordinating cluster + //on coordinating cluster ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:humanresources/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("human_resources_trainee", "password")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertFalse(ccs.getBody().contains("crl1")); Assert.assertTrue(ccs.getBody().contains("crl2")); Assert.assertTrue(ccs.getBody().contains("\"value\" : 1,\n \"relation")); @@ -261,11 +254,9 @@ public void testCcsDifferentConfigBoth() throws Exception { HttpResponse ccs = null; - System.out.println("###################### query 1"); - //on coordinating cluster + //on coordinating cluster ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:humanresources,humanresources/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("human_resources_trainee", "password")); - System.out.println(ccs.getBody()); - Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode()); Assert.assertTrue(ccs.getBody().contains("crl1")); Assert.assertTrue(ccs.getBody().contains("crl2")); Assert.assertTrue(ccs.getBody().contains("\"value\" : 2,\n \"relation")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java index 721ac0e9f5..5dfc55cd96 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java @@ -78,15 +78,13 @@ public void testNestedQuery() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/deals/mytype/_search?pretty", query, encodeBasicHeader("dept_manager", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"my_nested_object\" : {")); Assert.assertTrue(res.getBody().contains("\"field\" : \"my_nested_object\",")); Assert.assertTrue(res.getBody().contains("\"offset\" : 0")); //Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/deals/mytype/_search?pretty", query, encodeBasicHeader("admin", "admin"))).getStatusCode()); - //System.out.println(res.getBody()); - //Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + // //Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); //Assert.assertTrue(res.getBody().contains("\"value\" : 1510.0")); //Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); } diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java index 87aa2ddb4d..1bd0c995fd 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java @@ -52,11 +52,9 @@ public void testDlsProps() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/prop1,prop2/_search?pretty&size=100", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 5,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 5,\n \"relation")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/prop1,prop2/_search?pretty&size=100", encodeBasicHeader("prop_replace", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 3,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 3,\n \"relation")); } } \ No newline at end of file diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java index cf1cb18eb2..68b7458be4 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java @@ -48,8 +48,7 @@ protected void populateData(TransportClient tc) { // TODO Auto-generated catch block e.printStackTrace(); } - System.out.println("q"); - System.out.println(Strings.toString(tc.search(new SearchRequest().indices(".opendistro_security")).actionGet())); + tc.search(new SearchRequest().indices(".opendistro_security")).actionGet(); tc.search(new SearchRequest().indices("deals")).actionGet(); } diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java b/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java index 0de5f1c101..ee374d2613 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java @@ -47,8 +47,7 @@ public void test() throws Exception { "}}"; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/.kibana/config/0/_update?pretty", doc, encodeBasicHeader("human_resources_trainee", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("updated")); + Assert.assertTrue(res.getBody().contains("updated")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); } } \ No newline at end of file diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java index e117ccbb7b..a0ce462450 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java @@ -60,8 +60,7 @@ public void testDlsFlsAB() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/aaa,bbb/_search?pretty", encodeBasicHeader("user_aaa", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("\"x\"")); Assert.assertTrue(res.getBody().contains("f1_a")); @@ -75,8 +74,7 @@ public void testDlsFlsAB() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/abalias/_search?pretty", encodeBasicHeader("user_aaa", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("\"x\"")); Assert.assertTrue(res.getBody().contains("f1_a")); @@ -89,8 +87,7 @@ public void testDlsFlsAB() throws Exception { Assert.assertFalse(res.getBody().contains("f1_b")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/aaa,bbb/_search?pretty", encodeBasicHeader("user_bbb", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("\"x\"")); Assert.assertFalse(res.getBody().contains("f1_a")); @@ -104,8 +101,7 @@ public void testDlsFlsAB() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/abalias/_search?pretty", encodeBasicHeader("user_bbb", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("\"x\"")); Assert.assertFalse(res.getBody().contains("f1_a")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java index ddf9c2f1bb..17f73a15fc 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java @@ -154,8 +154,7 @@ public void testCombined() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty", encodeBasicHeader("user_combined", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertTrue(res.getBody().contains("customer")); Assert.assertTrue(res.getBody().contains("industry")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java index 72305c19df..1e37058d62 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java @@ -100,8 +100,7 @@ public void testExistsField() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/data/_search?pretty", query, encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); Assert.assertTrue(res.getBody().contains("a-normal-0")); Assert.assertTrue(res.getBody().contains("response")); Assert.assertTrue(res.getBody().contains("404")); @@ -110,8 +109,7 @@ public void testExistsField() throws Exception { //therefore non-existing does not exist so we expect c-missing2-0 to be returned Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/data/_search?pretty", query, encodeBasicHeader("fls_exists", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); Assert.assertTrue(res.getBody().contains("a-normal-0")); Assert.assertTrue(res.getBody().contains("c-missing2-0")); Assert.assertFalse(res.getBody().contains("response")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java index 7ba807a5d2..d7d40b86fc 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java @@ -133,8 +133,7 @@ public void testFlsPerfNamed() throws Exception { Assert.assertTrue(res.getBody().contains("field50\"")); Assert.assertTrue(res.getBody().contains("field997\"")); - System.out.println(sw.prettyPrint()); - } + } @Test public void testFlsPerfWcEx() throws Exception { @@ -180,8 +179,7 @@ public void testFlsPerfWcEx() throws Exception { Assert.assertFalse(res.getBody().contains("field50\"")); Assert.assertFalse(res.getBody().contains("field997\"")); - System.out.println(sw.prettyPrint()); - } + } @Test public void testFlsPerfNamedEx() throws Exception { @@ -227,8 +225,7 @@ public void testFlsPerfNamedEx() throws Exception { Assert.assertFalse(res.getBody().contains("field50\"")); Assert.assertFalse(res.getBody().contains("field997\"")); - System.out.println(sw.prettyPrint()); - } + } @Test public void testFlsWcIn() throws Exception { @@ -271,6 +268,5 @@ public void testFlsWcIn() throws Exception { Assert.assertTrue(res.getBody().contains("field50\"")); Assert.assertTrue(res.getBody().contains("field997\"")); - System.out.println(sw.prettyPrint()); - } + } } \ No newline at end of file diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java index 37c7deca63..dee3a29cad 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java @@ -61,8 +61,7 @@ public void testFieldCapabilities() throws Exception { Assert.assertFalse(res.getBody().contains("secret")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_field_caps?fields=*&pretty", encodeBasicHeader("dept_manager_fls_reversed_fields", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("customer")); + Assert.assertFalse(res.getBody().contains("customer")); Assert.assertFalse(res.getBody().contains("customer.name")); Assert.assertFalse(res.getBody().contains("zip")); Assert.assertFalse(res.getBody().contains("ctype")); @@ -95,8 +94,7 @@ public void testMapping() throws Exception { Assert.assertFalse(res.getBody().contains("secret")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_mapping?pretty", encodeBasicHeader("dept_manager_fls_reversed_fields", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("customer")); + Assert.assertTrue(res.getBody().contains("customer")); Assert.assertFalse(res.getBody().contains("name")); Assert.assertFalse(res.getBody().contains("zip")); Assert.assertFalse(res.getBody().contains("ctype")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java index 0e5bdb0177..53d64d62dc 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java @@ -48,8 +48,7 @@ public void testSearch() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-2016/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); @@ -57,8 +56,7 @@ public void testSearch() throws Exception { Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-2016/logs/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); @@ -74,14 +72,12 @@ public void testFieldCaps() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-2016/_field_caps?fields=*&pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("ipaddr")); + Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-2016/_field_caps?fields=*&pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("ipaddr")); + Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); Assert.assertTrue(res.getBody().contains("msgid")); } @@ -94,8 +90,7 @@ public void testSearchWc() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-20*/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); @@ -103,8 +98,7 @@ public void testSearchWc() throws Exception { Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-20*/logs/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); @@ -120,8 +114,7 @@ public void testSearchWcRegex() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-20*/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertTrue(res.getBody().contains("ipaddr")); Assert.assertTrue(res.getBody().contains("message")); @@ -129,8 +122,7 @@ public void testSearchWcRegex() throws Exception { Assert.assertTrue(res.getBody().contains("msgid")); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-20*/logs/_search?pretty", encodeBasicHeader("regex", "password"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); + Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("ipaddr")); Assert.assertFalse(res.getBody().contains("message")); diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java index 9113922e0d..854ca6ffea 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java @@ -43,8 +43,7 @@ public void testFlsMGetSearch() throws Exception { HttpResponse res; - System.out.println("### normal search"); - Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("deals,finance/_search?pretty", encodeBasicHeader("dept_manager_fls", "password"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("deals,finance/_search?pretty", encodeBasicHeader("dept_manager_fls", "password"))).getStatusCode()); Assert.assertFalse(res.getBody().contains("_opendistro_security_")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("xception")); @@ -62,8 +61,7 @@ public void testFlsMGetSearch() throws Exception { "{\"index\":\"finance\", \"type\":\"finance\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println("### msearch"); - Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("dept_manager_fls", "password"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("dept_manager_fls", "password"))).getStatusCode()); Assert.assertFalse(res.getBody().contains("_opendistro_security_")); Assert.assertTrue(res.getBody().contains("\"failed\" : 0")); Assert.assertFalse(res.getBody().contains("xception")); @@ -89,8 +87,7 @@ public void testFlsMGetSearch() throws Exception { "]"+ "}"; - System.out.println("### mget"); - Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_mget?pretty", mgetBody, encodeBasicHeader("dept_manager_fls", "password"))).getStatusCode()); + Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_mget?pretty", mgetBody, encodeBasicHeader("dept_manager_fls", "password"))).getStatusCode()); Assert.assertFalse(res.getBody().contains("_opendistro_security_")); Assert.assertTrue(res.getBody().contains("\"found\" : true")); Assert.assertFalse(res.getBody().contains("\"found\" : false")); diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java index b9e62cd7cd..ccbfe3ffa7 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java @@ -75,8 +75,7 @@ protected final void setup(Settings nodeOverride) throws Exception { FileHelper.getAbsoluteFilePathFromClassPath("restapi/truststore.jks")) .put(nodeOverride); - System.out.println(builder.toString()); - + setup(Settings.EMPTY, new DynamicSecurityConfig(), builder.build(), init); rh = restHelper(); rh.keystore = "restapi/kirk-keystore.jks"; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java index 506a4f4413..42d06d982d 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java @@ -186,8 +186,7 @@ public void testPutAccount() throws Exception { body = Settings.builder().loadFromSource(response.getBody(), XContentType.JSON).build(); assertEquals("CN=kirk,OU=client,O=client,L=Test,C=DE", body.get("user_name")); assertEquals(HttpStatus.SC_OK, response.getStatusCode()); // check admin user exists - System.out.println(response.getBody()); - payload = "{\"password\":\"" + testPass + "\", \"current_password\":\"" + "admin" + "\"}"; + payload = "{\"password\":\"" + testPass + "\", \"current_password\":\"" + "admin" + "\"}"; response = rh.executePutRequest(ENDPOINT, payload, encodeBasicHeader("admin", "admin")); assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusCode()); } diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java index b978664618..7061366b2e 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java @@ -67,8 +67,7 @@ protected void testHttpOperations() throws Exception { HttpResponse response = rh.executeGetRequest(ENDPOINT + "/roles"); Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatusCode()); String errorString = response.getBody(); - System.out.println(errorString); - Assert.assertEquals("{\"status\":\"INTERNAL_SERVER_ERROR\",\"message\":\"Security index not initialized\"}", errorString); + Assert.assertEquals("{\"status\":\"INTERNAL_SERVER_ERROR\",\"message\":\"Security index not initialized\"}", errorString); // GET roles response = rh.executeGetRequest(ENDPOINT + "/roles/opendistro_security_role_starfleet", new Header[0]); diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java index fdaf27fc2d..5b35856379 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java @@ -222,8 +222,7 @@ public void testNodesDnApiAuditComplianceLogging() throws Exception { testCrudScenarios(HttpStatus.SC_OK, nonAdminCredsHeader); } - System.out.println(TestAuditlogImpl.sb.toString()); - + final Map expectedCategoryCounts = ImmutableMap.of( AuditCategory.COMPLIANCE_INTERNAL_CONFIG_READ, 4L, AuditCategory.COMPLIANCE_INTERNAL_CONFIG_WRITE, 4L); diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java index b731090ac1..6900293a08 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java @@ -64,16 +64,13 @@ public void testPutRole() throws Exception { rh.sendAdminCertificate = true; // check roles exists HttpResponse response = rh.executePutRequest(ENDPOINT + "/roles/admin", FileHelper.loadFile("restapi/simple_role.json")); - System.out.println(response.getBody()); - Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); response = rh.executePutRequest(ENDPOINT + "/roles/lala", "{ \"cluster_permissions\": [\"*\"] }"); - System.out.println(response.getBody()); - Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); response = rh.executePutRequest(ENDPOINT + "/roles/empty", "{ \"cluster_permissions\": [] }"); - System.out.println(response.getBody()); - Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); + Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatusCode()); } @Test @@ -318,8 +315,7 @@ public void testRolesApi() throws Exception { response = rh.executeGetRequest(ENDPOINT + "/roles/opendistro_security_role_starfleet_captains", new Header[0]); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(response.getBody()); - settings = DefaultObjectMapper.readTree(response.getBody()); + settings = DefaultObjectMapper.readTree(response.getBody()); Assert.assertEquals(1, settings.size()); Assert.assertEquals(new SecurityJsonNode(settings).getDotted("opendistro_security_role_starfleet_captains.tenant_permissions").get(1).get("tenant_patterns").get(0).asString(), "tenant1"); Assert.assertEquals(new SecurityJsonNode(settings).getDotted("opendistro_security_role_starfleet_captains.tenant_permissions").get(1).get("allowed_actions").get(0).asString(), "kibana_all_read"); diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java index 6a163399af..e2acc81c39 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java @@ -448,8 +448,7 @@ public void testPasswordRules() throws Exception { HttpResponse response = rh .executeGetRequest("_plugins/_security/api/" + CType.INTERNALUSERS.toLCString()); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); - System.out.println(response.getBody()); - Settings settings = Settings.builder().loadFromSource(response.getBody(), XContentType.JSON).build(); + Settings settings = Settings.builder().loadFromSource(response.getBody(), XContentType.JSON).build(); Assert.assertEquals(56, settings.size()); addUserWithPassword("tooshoort", "", HttpStatus.SC_BAD_REQUEST); diff --git a/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java b/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java index 563d4effd3..f0a74a152b 100644 --- a/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java +++ b/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java @@ -87,30 +87,24 @@ public void testNoDnfof() throws Exception { HttpResponse resc; Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("indexa,indexb/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("indexa,indexb/_search?pretty", encodeBasicHeader("user_b", "user_b"))).getStatusCode()); - System.out.println(resc.getBody()); - + String msearchBody = "{\"index\":\"indexa\", \"type\":\"doc\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+ "{\"index\":\"indexb\", \"type\":\"doc\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println("#### msearch a"); - resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_a", "user_a")); + resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_a", "user_a")); Assert.assertEquals(200, resc.getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("permission")); - System.out.println("#### msearch b"); - resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); + resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); Assert.assertEquals(200, resc.getStatusCode()); - System.out.println(resc.getBody()); - Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); + Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexa")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("indexb")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("permission")); @@ -121,10 +115,8 @@ public void testNoDnfof() throws Exception { "{\"index\":\"indexd\", \"type\":\"doc\", \"ignore_unavailable\": true}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); - System.out.println("#### msearch b2"); - resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); - System.out.println(resc.getBody()); - Assert.assertEquals(200, resc.getStatusCode()); + resc = rh.executePostRequest("_msearch?pretty", msearchBody, encodeBasicHeader("user_b", "user_b")); + Assert.assertEquals(200, resc.getStatusCode()); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexc")); Assert.assertFalse(resc.getBody(), resc.getBody().contains("indexd")); Assert.assertTrue(resc.getBody(), resc.getBody().contains("exception")); @@ -181,29 +173,21 @@ public void testNoDnfof() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("indexa/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("indexb/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("_all/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("notexists/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_NOT_FOUND, (resc=rh.executeGetRequest("indexanbh,indexabb*/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (resc=rh.executeGetRequest("starfleet/_search?pretty", encodeBasicHeader("user_a", "user_a"))).getStatusCode()); - System.out.println(resc.getBody()); - + Assert.assertEquals(HttpStatus.SC_OK, (resc=rh.executeGetRequest("starfleet/_search?pretty", encodeBasicHeader("worf", "worf"))).getStatusCode()); - System.out.println(resc.getBody()); - + } @Test @@ -222,16 +206,13 @@ public void testMt() throws Exception { body = "{\"buildNum\": 15460, \"defaultIndex\": \"humanresources\", \"tenant\": \"human_resources\"}"; Assert.assertEquals(HttpStatus.SC_CREATED, (res = rh.executePutRequest(".kibana/config/5.6.0?pretty",body, new BasicHeader("securitytenant", "human_resources"), encodeBasicHeader("hr_employee", "hr_employee"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertEquals(".kibana_1592542611_humanresources_1", DefaultObjectMapper.readTree(res.getBody()).get("_index").asText()); + Assert.assertEquals(".kibana_1592542611_humanresources_1", DefaultObjectMapper.readTree(res.getBody()).get("_index").asText()); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest(".kibana/config/5.6.0?pretty",new BasicHeader("securitytenant", "human_resources"), encodeBasicHeader("hr_employee", "hr_employee"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(WildcardMatcher.from("*human_resources*").test(res.getBody())); + Assert.assertTrue(WildcardMatcher.from("*human_resources*").test(res.getBody())); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest(".kibana_1592542611_humanresources_1/_alias", encodeBasicHeader("admin", "admin"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertNotNull(DefaultObjectMapper.readTree(res.getBody()).get(".kibana_1592542611_humanresources_1").get("aliases").get(".kibana_1592542611_humanresources")); + Assert.assertNotNull(DefaultObjectMapper.readTree(res.getBody()).get(".kibana_1592542611_humanresources_1").get("aliases").get(".kibana_1592542611_humanresources")); } @@ -266,67 +247,55 @@ public void testMtMulti() throws Exception { final RestHelper rh = nonSslRestHelper(); - System.out.println("#### search"); - HttpResponse res; + HttpResponse res; String body = "{\"query\" : {\"term\" : { \"_id\" : \"index-pattern:9fbbd1a0-c3c5-11e8-a13f-71b8ea5a4f7b\"}}}"; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest(".kibana/_search/?pretty",body, new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("admin", "admin"))).getStatusCode()); - //System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("exception")); + // Assert.assertFalse(res.getBody().contains("exception")); Assert.assertTrue(res.getBody().contains("humanresources")); Assert.assertTrue(res.getBody().contains("\"value\" : 1")); Assert.assertTrue(res.getBody().contains(dashboardsIndex)); - System.out.println("#### msearch"); - body = + body = "{\"index\":\".kibana\", \"type\":\"doc\", \"ignore_unavailable\": false}"+System.lineSeparator()+ "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator(); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_msearch/?pretty",body, new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("admin", "admin"))).getStatusCode()); - //System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("exception")); + // Assert.assertFalse(res.getBody().contains("exception")); Assert.assertTrue(res.getBody().contains("humanresources")); Assert.assertTrue(res.getBody().contains("\"value\" : 1")); Assert.assertTrue(res.getBody().contains(dashboardsIndex)); - System.out.println("#### get"); - Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest(".kibana/doc/index-pattern:9fbbd1a0-c3c5-11e8-a13f-71b8ea5a4f7b?pretty", new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("admin", "admin"))).getStatusCode()); - //System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("exception")); + Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest(".kibana/doc/index-pattern:9fbbd1a0-c3c5-11e8-a13f-71b8ea5a4f7b?pretty", new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("admin", "admin"))).getStatusCode()); + // Assert.assertFalse(res.getBody().contains("exception")); Assert.assertTrue(res.getBody().contains("humanresources")); Assert.assertTrue(res.getBody().contains("\"found\" : true")); Assert.assertTrue(res.getBody().contains(dashboardsIndex)); - System.out.println("#### mget"); - body = "{\"docs\" : [{\"_index\" : \".kibana\",\"_type\" : \"doc\",\"_id\" : \"index-pattern:9fbbd1a0-c3c5-11e8-a13f-71b8ea5a4f7b\"}]}"; + body = "{\"docs\" : [{\"_index\" : \".kibana\",\"_type\" : \"doc\",\"_id\" : \"index-pattern:9fbbd1a0-c3c5-11e8-a13f-71b8ea5a4f7b\"}]}"; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_mget/?pretty",body, new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("admin", "admin"))).getStatusCode()); - //System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("exception")); + // Assert.assertFalse(res.getBody().contains("exception")); Assert.assertTrue(res.getBody().contains("humanresources")); Assert.assertTrue(res.getBody().contains(dashboardsIndex)); - System.out.println("#### index"); - body = "{"+ + body = "{"+ "\"type\" : \"index-pattern\","+ "\"updated_at\" : \"2017-09-29T08:56:59.066Z\","+ "\"index-pattern\" : {"+ "\"title\" : \"xyz\""+ "}}"; Assert.assertEquals(HttpStatus.SC_CREATED, (res = rh.executePutRequest(".kibana/doc/abc?pretty",body, new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("admin", "admin"))).getStatusCode()); - //System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("exception")); + // Assert.assertFalse(res.getBody().contains("exception")); Assert.assertTrue(res.getBody().contains("\"result\" : \"created\"")); Assert.assertTrue(res.getBody().contains(dashboardsIndex)); - System.out.println("#### bulk"); - body = + body = "{ \"index\" : { \"_index\" : \".kibana\", \"_type\" : \"doc\", \"_id\" : \"b1\" } }"+System.lineSeparator()+ "{ \"field1\" : \"value1\" }" +System.lineSeparator()+ "{ \"index\" : { \"_index\" : \".kibana\", \"_type\" : \"doc\", \"_id\" : \"b2\" } }"+System.lineSeparator()+ "{ \"field2\" : \"value2\" }"+System.lineSeparator(); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePutRequest("_bulk?pretty",body, new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("admin", "admin"))).getStatusCode()); - //System.out.println(res.getBody()); - Assert.assertFalse(res.getBody().contains("exception")); + // Assert.assertFalse(res.getBody().contains("exception")); Assert.assertTrue(res.getBody().contains(dashboardsIndex)); Assert.assertTrue(res.getBody().contains("\"errors\" : false")); Assert.assertTrue(res.getBody().contains("\"result\" : \"created\"")); @@ -362,8 +331,7 @@ public void testDashboardsAlias() throws Exception { Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest(".kibana-6/doc/6.2.2?pretty", encodeBasicHeader("kibanaro", "kibanaro"))).getStatusCode()); Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest(".kibana/doc/6.2.2?pretty", encodeBasicHeader("kibanaro", "kibanaro"))).getStatusCode()); - System.out.println(res.getBody()); - + } @Test @@ -391,8 +359,7 @@ public void testDashboardsAlias65() throws Exception { HttpResponse res; Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest(".kibana/doc/6.2.2?pretty", new BasicHeader("securitytenant", "__user__"), encodeBasicHeader("kibanaro", "kibanaro"))).getStatusCode()); - System.out.println(res.getBody()); - Assert.assertTrue(res.getBody().contains(".kibana_-900636979_kibanaro")); + Assert.assertTrue(res.getBody().contains(".kibana_-900636979_kibanaro")); } @Test diff --git a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java index 0b74dfb5d2..817ad559ce 100644 --- a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java @@ -138,8 +138,7 @@ public void testAvailCiphersOpenSSL() throws Exception { // Set openSSLAvailCiphers = new // HashSet<>(OpenSsl.availableCipherSuites()); - // System.out.println("OpenSSL available ciphers: "+openSSLAvailCiphers); - // ECDHE-RSA-AES256-SHA, ECDH-ECDSA-AES256-SHA, DH-DSS-DES-CBC-SHA, + // // ECDHE-RSA-AES256-SHA, ECDH-ECDSA-AES256-SHA, DH-DSS-DES-CBC-SHA, // ADH-AES256-SHA256, ADH-CAMELLIA128-SHA final Set openSSLSecureCiphers = new HashSet<>(); @@ -149,8 +148,7 @@ public void testAvailCiphersOpenSSL() throws Exception { } } - System.out.println("OpenSSL secure ciphers: " + openSSLSecureCiphers); - Assert.assertTrue(openSSLSecureCiphers.size() > 0); + Assert.assertTrue(openSSLSecureCiphers.size() > 0); } @Test diff --git a/src/test/java/org/opensearch/security/ssl/SSLTest.java b/src/test/java/org/opensearch/security/ssl/SSLTest.java index eb3560cb2f..273adb52a9 100644 --- a/src/test/java/org/opensearch/security/ssl/SSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/SSLTest.java @@ -101,7 +101,7 @@ public void testHttps() throws Exception { rh.sendAdminCertificate = true; rh.keystore = "node-untspec5-keystore.p12"; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty&show_dn=true")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty&show_dn=true"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty&show_dn=true").contains("EMAILADDRESS=unt@tst.com")); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty&show_dn=true").contains("local_certificates_list")); Assert.assertFalse(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty&show_dn=false").contains("local_certificates_list")); @@ -117,9 +117,7 @@ public void testHttps() throws Exception { public void testCipherAndProtocols() throws Exception { Security.setProperty("jdk.tls.disabledAlgorithms",""); - System.out.println("Disabled algos: "+Security.getProperty("jdk.tls.disabledAlgorithms")); - System.out.println("allowOpenSSL: "+allowOpenSSL); - + Settings settings = Settings.builder().put("plugins.security.ssl.transport.enabled", false) .put(ConfigConstants.SECURITY_SSL_ONLY, true) .put(SSLConfigConstants.SECURITY_SSL_HTTP_KEYSTORE_ALIAS, "node-0").put("plugins.security.ssl.http.enabled", true) @@ -195,8 +193,7 @@ public void testCipherAndProtocols() throws Exception { Assert.assertEquals("SSL_RSA_EXPORT_WITH_RC4_40_MD5",enabledCiphers[0]); } } catch (OpenSearchSecurityException e) { - System.out.println("EXPECTED "+e.getClass().getSimpleName()+" for "+System.getProperty("java.specification.version")+": "+e.toString()); - e.printStackTrace(); + e.printStackTrace(); Assert.assertTrue("Check if error contains 'no valid cipher suites' -> "+e.toString(),e.toString().contains("no valid cipher suites") || e.toString().contains("failed to set cipher suite") || e.toString().contains("Unable to configure permitted SSL ciphers") @@ -224,7 +221,7 @@ public void testHttpsOptionalAuth() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").contains("TLS")); Assert.assertTrue(rh.executeSimpleRequest("_nodes/settings?pretty").contains(clusterInfo.clustername)); Assert.assertFalse(rh.executeSimpleRequest("_nodes/settings?pretty").contains("\"opendistro_security\"")); @@ -258,7 +255,7 @@ public void testHttpsAndNodeSSL() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").contains("TLS")); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").length() > 0); Assert.assertTrue(rh.executeSimpleRequest("_nodes/settings?pretty").contains(clusterInfo.clustername)); @@ -299,7 +296,7 @@ public void testHttpsAndNodeSSLPem() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").contains("TLS")); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").length() > 0); Assert.assertTrue(rh.executeSimpleRequest("_nodes/settings?pretty").contains(clusterInfo.clustername)); @@ -336,7 +333,7 @@ public void testHttpsAndNodeSSLPemEnc() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").contains("TLS")); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").length() > 0); Assert.assertTrue(rh.executeSimpleRequest("_nodes/settings?pretty").contains(clusterInfo.clustername)); @@ -372,8 +369,7 @@ public void testHttpsAndNodeSSLFailedCipher() throws Exception { Assert.fail(); } catch (Exception e1) { e1.printStackTrace(); - System.out.println("##1 "+e1.toString()); - Throwable e = ExceptionUtils.getRootCause(e1); + Throwable e = ExceptionUtils.getRootCause(e1); Assert.assertTrue(e.toString(), e.toString().contains("no valid cipher")); } } @@ -452,8 +448,7 @@ public void testHttpsEnforceFail() throws Exception { Assert.fail(); } catch (SocketException | SSLException e) { //expected - System.out.println("Expected SSLHandshakeException "+e.toString()); - } catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); Assert.fail("Unexpected exception "+e.toString()); } @@ -676,8 +671,7 @@ public void testAvailCiphers() throws Exception { // example // TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, // TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA - System.out.println("JDK enabled ciphers: " + jdkEnabledCiphers); - Assert.assertTrue(jdkEnabledCiphers.size() > 0); + Assert.assertTrue(jdkEnabledCiphers.size() > 0); } @Test @@ -913,7 +907,7 @@ public void testHttpsAndNodeSSLKeyPass() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").contains("TLS")); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").length() > 0); Assert.assertTrue(rh.executeSimpleRequest("_nodes/settings?pretty").contains(clusterInfo.clustername)); @@ -962,7 +956,7 @@ public void testHttpsAndNodeSSLKeyStoreExtendedUsageEnabled() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").contains("TLS")); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").length() > 0); Assert.assertTrue(rh.executeSimpleRequest("_nodes/settings?pretty").contains(clusterInfo.clustername)); @@ -1039,7 +1033,7 @@ public void testHttpsAndNodeSSLPemExtendedUsageEnabled() throws Exception { rh.trustHTTPServerCertificate = true; rh.sendAdminCertificate = true; - System.out.println(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty")); + rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty"); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").contains("TLS")); Assert.assertTrue(rh.executeSimpleRequest("_opendistro/_security/sslinfo?pretty").length() > 0); Assert.assertTrue(rh.executeSimpleRequest("_nodes/settings?pretty").contains(clusterInfo.clustername)); diff --git a/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java b/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java index 32e8d993f8..f0cbadda9f 100644 --- a/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java @@ -364,16 +364,6 @@ public String toString() { + ", statusReason=" + statusReason + "]"; } - private static void findArrayAccessor(String input) { - final Pattern r = Pattern.compile("(.+?)\\[(\\d+)\\]"); - final Matcher m = r.matcher(input); - if(m.find()) { - System.out.println("'" + input + "'\t Name was: " + m.group(1) + ",\t index position: " + m.group(2)); - } else { - System.out.println("'" + input + "'\t No Match"); - } - } - /** * Given a json path with dots delimiated returns the object at the leaf */ diff --git a/src/test/java/org/opensearch/security/test/helper/rules/SecurityTestWatcher.java b/src/test/java/org/opensearch/security/test/helper/rules/SecurityTestWatcher.java index 53ca93827f..621a5c8579 100644 --- a/src/test/java/org/opensearch/security/test/helper/rules/SecurityTestWatcher.java +++ b/src/test/java/org/opensearch/security/test/helper/rules/SecurityTestWatcher.java @@ -40,8 +40,7 @@ protected void starting(final Description description) { final String methodName = description.getMethodName(); String className = description.getClassName(); className = className.substring(className.lastIndexOf('.') + 1); - System.out.println("---------------- Starting JUnit-test: " + className + " " + methodName + " ----------------"); - } + } @Override protected void failed(final Throwable e, final Description description) { @@ -53,7 +52,6 @@ protected void failed(final Throwable e, final Description description) { @Override protected void finished(final Description description) { - // System.out.println("-----------------------------------------------------------------------------------------"); - } + // } }