upgrades to spring security 3.2 - testing work as well
This commit is contained in:
parent
56240e0fce
commit
f58149a0cc
|
@ -139,7 +139,7 @@
|
|||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>3.2.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.0.Final</hibernate.version>
|
||||
|
|
|
@ -287,7 +287,7 @@
|
|||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>3.2.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.0.Final</hibernate.version>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||
http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.apache.http.conn.ssl.TrustStrategy;
|
|||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.baeldung.client.spring.ClientConfig;
|
||||
import org.baeldung.web.dto.Foo;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -54,6 +55,7 @@ public class ClientLiveTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Only to run against a Server with HTTPS enabled (on 8443)")
|
||||
public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws GeneralSecurityException {
|
||||
final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||
final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient();
|
||||
|
|
|
@ -13,18 +13,18 @@ import javax.net.ssl.SSLPeerUnverifiedException;
|
|||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.params.ClientPNames;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.conn.ssl.TrustStrategy;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import org.apache.http.params.HttpConnectionParams;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RawClientLiveTest {
|
||||
|
@ -33,14 +33,12 @@ public class RawClientLiveTest {
|
|||
|
||||
@Test
|
||||
public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException {
|
||||
final DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
final CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
final int timeout = 20; // seconds
|
||||
final HttpParams httpParams = httpClient.getParams();
|
||||
configureViaRawApi(timeout, httpParams);
|
||||
// configureViaHighLevelApi(timeout, httpParams);
|
||||
|
||||
final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).setSocketTimeout(timeout).build();
|
||||
final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/bars/1");
|
||||
getMethod.setConfig(requestConfig);
|
||||
|
||||
final int hardTimeout = 5; // seconds
|
||||
final TimerTask task = new TimerTask() {
|
||||
|
@ -58,8 +56,9 @@ public class RawClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(expected = SSLPeerUnverifiedException.class)
|
||||
@Ignore("Only for a server that has HTTPS enabled (on 8443)")
|
||||
public final void whenHttpsUrlIsConsumed_thenException() throws ClientProtocolException, IOException {
|
||||
final DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
final CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1";
|
||||
final HttpGet getMethod = new HttpGet(urlOverHttps);
|
||||
|
@ -80,7 +79,7 @@ public class RawClientLiveTest {
|
|||
registry.register(new Scheme("https", 8443, sf));
|
||||
final ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
|
||||
|
||||
final DefaultHttpClient httpClient = new DefaultHttpClient(ccm);
|
||||
final CloseableHttpClient httpClient = new DefaultHttpClient(ccm);
|
||||
|
||||
final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1";
|
||||
final HttpGet getMethod = new HttpGet(urlOverHttps);
|
||||
|
@ -88,17 +87,4 @@ public class RawClientLiveTest {
|
|||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
}
|
||||
|
||||
// util
|
||||
|
||||
final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) {
|
||||
HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout
|
||||
HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout
|
||||
httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000));
|
||||
}
|
||||
|
||||
final void configureViaRawApi(final int timeout, final HttpParams httpParams) {
|
||||
httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000);
|
||||
httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000);
|
||||
httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@
|
|||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>3.2.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.0.Final</hibernate.version>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||
http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@
|
|||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>3.2.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.0.Final</hibernate.version>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||
http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||
|
||||
|
|
|
@ -6,12 +6,10 @@ import java.util.TimerTask;
|
|||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.params.ClientPNames;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import org.apache.http.params.HttpConnectionParams;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.baeldung.client.spring.ClientConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -27,14 +25,12 @@ public class RawClientLiveTest {
|
|||
|
||||
@Test
|
||||
public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException {
|
||||
final DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
final CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
final int timeout = 20; // seconds
|
||||
final HttpParams httpParams = httpClient.getParams();
|
||||
configureViaRawApi(timeout, httpParams);
|
||||
// configureViaHighLevelApi(timeout, httpParams);
|
||||
|
||||
final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-digest-auth/api/bars/1");
|
||||
final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).setSocketTimeout(timeout).build();
|
||||
final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/bars/1");
|
||||
getMethod.setConfig(requestConfig);
|
||||
|
||||
final int hardTimeout = 5; // seconds
|
||||
final TimerTask task = new TimerTask() {
|
||||
|
@ -51,17 +47,4 @@ public class RawClientLiveTest {
|
|||
System.out.println("HTTP Status of response: " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
// util
|
||||
|
||||
final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) {
|
||||
HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout
|
||||
HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout
|
||||
httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000));
|
||||
}
|
||||
|
||||
final void configureViaRawApi(final int timeout, final HttpParams httpParams) {
|
||||
httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000);
|
||||
httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000);
|
||||
httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@
|
|||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>3.2.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.0.Final</hibernate.version>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||
http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@
|
|||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>3.2.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.0.Final</hibernate.version>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:sec="http://www.springframework.org/schema/security"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd
|
||||
http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||
|
||||
|
|
Loading…
Reference in New Issue