From 63a5001837f094e8768ed27c1ba46dcf547b2ef8 Mon Sep 17 00:00:00 2001 From: javanna Date: Tue, 19 Jul 2016 16:51:07 +0200 Subject: [PATCH] [TEST] restore throws IOException clause on all sync performRequest callers Original commit: elastic/x-pack-elasticsearch@d114419752c0cdc5e8a7784125f8c2bf0b2b54e8 --- .../GraphWithSecurityInsufficientRoleIT.java | 4 +++- .../MonitoringWithSecurityInsufficientRoleIT.java | 2 +- .../integration/AbstractPrivilegeTestCase.java | 13 +++++++------ .../elasticsearch/integration/BulkUpdateTests.java | 4 ++-- .../xpack/security/SecurityPluginTests.java | 4 +++- .../security/transport/ssl/SslClientAuthTests.java | 7 ++++--- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/elasticsearch/qa/smoke-test-graph-with-security/src/test/java/org/elasticsearch/smoketest/GraphWithSecurityInsufficientRoleIT.java b/elasticsearch/qa/smoke-test-graph-with-security/src/test/java/org/elasticsearch/smoketest/GraphWithSecurityInsufficientRoleIT.java index 54b9cf28c8c..3bb10b64e23 100644 --- a/elasticsearch/qa/smoke-test-graph-with-security/src/test/java/org/elasticsearch/smoketest/GraphWithSecurityInsufficientRoleIT.java +++ b/elasticsearch/qa/smoke-test-graph-with-security/src/test/java/org/elasticsearch/smoketest/GraphWithSecurityInsufficientRoleIT.java @@ -8,6 +8,8 @@ package org.elasticsearch.smoketest; import com.carrotsearch.randomizedtesting.annotations.Name; import org.elasticsearch.test.rest.RestTestCandidate; +import java.io.IOException; + import static org.hamcrest.Matchers.containsString; public class GraphWithSecurityInsufficientRoleIT extends GraphWithSecurityIT { @@ -16,7 +18,7 @@ public class GraphWithSecurityInsufficientRoleIT extends GraphWithSecurityIT { super(testCandidate); } - public void test() throws Exception { + public void test() throws IOException { try { super.test(); fail("should have failed because of missing role"); diff --git a/elasticsearch/qa/smoke-test-monitoring-with-security/insufficient-rights/src/test/java/org/elasticsearch/smoketest/MonitoringWithSecurityInsufficientRoleIT.java b/elasticsearch/qa/smoke-test-monitoring-with-security/insufficient-rights/src/test/java/org/elasticsearch/smoketest/MonitoringWithSecurityInsufficientRoleIT.java index 1334c2b4de7..037941611bf 100644 --- a/elasticsearch/qa/smoke-test-monitoring-with-security/insufficient-rights/src/test/java/org/elasticsearch/smoketest/MonitoringWithSecurityInsufficientRoleIT.java +++ b/elasticsearch/qa/smoke-test-monitoring-with-security/insufficient-rights/src/test/java/org/elasticsearch/smoketest/MonitoringWithSecurityInsufficientRoleIT.java @@ -47,7 +47,7 @@ public class MonitoringWithSecurityInsufficientRoleIT extends ESRestTestCase { } @Override - public void test() throws Exception { + public void test() throws IOException { try { super.test(); fail("should have failed because of missing role"); diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java index c8b660c3b20..559bc72c3c4 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java @@ -18,6 +18,7 @@ import org.elasticsearch.xpack.security.authc.support.Hasher; import org.elasticsearch.xpack.security.authc.support.SecuredString; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; +import java.io.IOException; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -34,7 +35,7 @@ public abstract class AbstractPrivilegeTestCase extends SecurityIntegTestCase { protected static final String USERS_PASSWD_HASHED = new String(Hasher.BCRYPT.hash(new SecuredString("passwd".toCharArray()))); protected void assertAccessIsAllowed(String user, String method, String uri, String body, - Map params) throws Exception { + Map params) throws IOException { Response response = getRestClient().performRequest(method, uri, params, entityOrNull(body), new BasicHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, UsernamePasswordToken.basicAuthHeaderValue(user, new SecuredString("passwd".toCharArray())))); @@ -44,24 +45,24 @@ public abstract class AbstractPrivilegeTestCase extends SecurityIntegTestCase { assertThat(message, statusLine.getStatusCode(), is(not(greaterThanOrEqualTo(400)))); } - protected void assertAccessIsAllowed(String user, String method, String uri, String body) throws Exception { + protected void assertAccessIsAllowed(String user, String method, String uri, String body) throws IOException { assertAccessIsAllowed(user, method, uri, body, new HashMap<>()); } - protected void assertAccessIsAllowed(String user, String method, String uri) throws Exception { + protected void assertAccessIsAllowed(String user, String method, String uri) throws IOException { assertAccessIsAllowed(user, method, uri, null, new HashMap<>()); } - protected void assertAccessIsDenied(String user, String method, String uri, String body) throws Exception { + protected void assertAccessIsDenied(String user, String method, String uri, String body) throws IOException { assertAccessIsDenied(user, method, uri, body, new HashMap<>()); } - protected void assertAccessIsDenied(String user, String method, String uri) throws Exception { + protected void assertAccessIsDenied(String user, String method, String uri) throws IOException { assertAccessIsDenied(user, method, uri, null, new HashMap<>()); } protected void assertAccessIsDenied(String user, String method, String uri, String body, - Map params) throws Exception { + Map params) throws IOException { try { getRestClient().performRequest(method, uri, params, entityOrNull(body), new BasicHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index 67b885d4e84..201850afa2c 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.Response; -import org.elasticsearch.client.RestClient; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.SecurityIntegTestCase; @@ -24,6 +23,7 @@ import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.security.authc.support.SecuredString; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; +import java.io.IOException; import java.util.Collections; import static org.hamcrest.Matchers.containsString; @@ -73,7 +73,7 @@ public class BulkUpdateTests extends SecurityIntegTestCase { assertThat(getResponse.getField("bulk updated").getValue(), equalTo("bulk updated")); } - public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws Exception { + public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws IOException { final String path = "/index1/type/1"; final Header basicAuthHeader = new BasicHeader("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.DEFAULT_USER_NAME, diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java index 3dfd85b6388..cdbfc30f236 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java @@ -14,6 +14,8 @@ import org.elasticsearch.test.SecuritySettingsSource; import org.elasticsearch.xpack.security.authc.support.SecuredString; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; +import java.io.IOException; + import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.RestStatus.UNAUTHORIZED; import static org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue; @@ -29,7 +31,7 @@ public class SecurityPluginTests extends SecurityIntegTestCase { .build(); } - public void testThatPluginIsLoaded() throws Exception { + public void testThatPluginIsLoaded() throws IOException { try { logger.info("executing unauthorized request to /_xpack info"); getRestClient().performRequest("GET", "/_xpack"); diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslClientAuthTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslClientAuthTests.java index 7e901bceccb..5c5a42c36a6 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslClientAuthTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslClientAuthTests.java @@ -28,6 +28,7 @@ import org.elasticsearch.xpack.security.transport.netty3.SecurityNetty3HttpServe import org.elasticsearch.xpack.security.transport.netty3.SecurityNetty3Transport; import javax.net.ssl.SSLHandshakeException; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.security.cert.CertPathBuilderException; @@ -57,7 +58,7 @@ public class SslClientAuthTests extends SecurityIntegTestCase { return true; } - public void testThatHttpFailsWithoutSslClientAuth() throws Exception { + public void testThatHttpFailsWithoutSslClientAuth() throws IOException { SSLIOSessionStrategy sessionStrategy = new SSLIOSessionStrategy(SSLContexts.createDefault(), NoopHostnameVerifier.INSTANCE); try (RestClient restClient = createRestClient(httpClientBuilder -> httpClientBuilder.setSSLStrategy(sessionStrategy), "https")) { restClient.performRequest("GET", "/"); @@ -69,7 +70,7 @@ public class SslClientAuthTests extends SecurityIntegTestCase { } } - public void testThatHttpWorksWithSslClientAuth() throws Exception { + public void testThatHttpWorksWithSslClientAuth() throws IOException { Settings settings = Settings.builder() .put(getSSLSettingsForStore("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks", "testclient")) .build(); @@ -83,7 +84,7 @@ public class SslClientAuthTests extends SecurityIntegTestCase { } } - public void testThatTransportWorksWithoutSslClientAuth() throws Exception { + public void testThatTransportWorksWithoutSslClientAuth() throws IOException { // specify an arbitrary keystore, that does not include the certs needed to connect to the transport protocol Path store = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks");