|
From: Dave H. <hel...@us...> - 2012-08-27 21:52:23
|
Update of /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/http
In directory vz-cvs-3.sog:/tmp/cvs-serv23875/utst/org/sblim/cimclient/unittest/http
Modified Files:
Tag: Experimental
SSLConfigurationTest.java
Log Message:
3536399 - fix SSLConfigurationTest bugs
Index: SSLConfigurationTest.java
===================================================================
RCS file: /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/http/SSLConfigurationTest.java,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -u -d -r1.1.2.11 -r1.1.2.12
--- SSLConfigurationTest.java 26 Aug 2012 02:27:29 -0000 1.1.2.11
+++ SSLConfigurationTest.java 27 Aug 2012 21:52:21 -0000 1.1.2.12
@@ -25,6 +25,7 @@
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketException;
import java.net.URL;
import java.util.Locale;
import java.util.Properties;
@@ -430,13 +431,9 @@
CIMObjectPath dummyCop = new CIMObjectPath(null, null, null, "root/interop",
"CIM_Namespace", null);
- int port = listener.addListener(ilsBrief, 0, "https");
- listener.removeListener(port);
- WBEMClientSBLIM client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port),
- null, null);
-
// PEER VERIFICATION disabled at domain-level (should PASS)
- port = listener.addListener(ilsBrief, port, "https");
+ WBEMClientSBLIM client;
+ int port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, "");
@@ -452,7 +449,7 @@
}
// PEER VERIFICATION disabled but truststore configured (should PASS and
// give WARNING)
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -469,7 +466,7 @@
}
// CLIENT_PEER_VERIFICATION enabled at domain-level but no truststore
// configured (should FAIL)
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "true");
@@ -486,7 +483,7 @@
}
// CLIENT_PEER_VERIFICATION enabled at domain-level but truststore
// misconfigured (should FAIL)
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "true");
@@ -503,7 +500,7 @@
}
// CLIENT_PEER_VERIFICATION enabled at domain-level with valid
// truststore (should PASS)
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "true");
@@ -520,7 +517,7 @@
}
// CLIENT_PEER_VERIFICATION enabled at domain-level with notrust
// truststore (should FAIL)
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "true");
@@ -540,7 +537,7 @@
// server keystore (should FAIL)
listener.setProperty(WBEMConfigurationProperties.KEYSTORE_PATH, stranger.getFile());
listener.setProperty(WBEMConfigurationProperties.KEYSTORE_PASSWORD, "password");
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "true");
@@ -598,13 +595,9 @@
CIMObjectPath dummyCop = new CIMObjectPath(null, null, null, "root/interop",
"CIM_Namespace", null);
- int port = listener.addListener(ilsBrief, 0, "https");
- listener.removeListener(port);
- WBEMClientSBLIM client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port),
- null, null);
-
// PEER VERIFICATION disabled at domain-level (should PASS)
- port = listener.addListener(ilsBrief, port, "https");
+ WBEMClientSBLIM client;
+ int port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, "");
@@ -625,7 +618,7 @@
listener.setProperty(WBEMConfigurationProperties.SSL_LISTENER_PEER_VERIFICATION, "ignore");
listener.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH,
"/any/path/even/if/not/validated");
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -643,7 +636,7 @@
// configured (should FAIL)
listener.setProperty(WBEMConfigurationProperties.SSL_LISTENER_PEER_VERIFICATION, "require");
listener.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, "");
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -661,7 +654,7 @@
// LISTENER_PEER_VERIFICATION enabled at domain-level but truststore
// misconfigured (should FAIL)
listener.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, "somebadpath");
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -679,7 +672,7 @@
// LISTENER_PEER_VERIFICATION enabled at domain-level with valid
// truststore (should PASS)
listener.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, truststore.getFile());
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -698,7 +691,7 @@
// LISTENER_PEER_VERIFICATION enabled at domain-level with notrust
// truststore (should FAIL)
listener.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, notrust.getFile());
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -708,9 +701,10 @@
client.enumerateInstanceNames(dummyCop);
} catch (WBEMException e) {
if (e.getCause() != null
- && (e.getCause().getClass().equals(SSLException.class) || e.getCause()
- .getClass().equals(SSLHandshakeException.class))) {
- // expected SSLException
+ && (e.getCause().getClass().equals(SSLException.class)
+ || e.getCause().getClass().equals(SSLHandshakeException.class) || e
+ .getCause().getClass().equals(SocketException.class))) {
+ // expected SSLException or SocketException
} else fail("Connection established with listener peer verification enabled with notrust truststore");
} finally {
listener.removeListener(port);
@@ -718,7 +712,7 @@
// LISTENER_PEER_VERIFICATION enabled at domain-level with untrusted
// client keystore (should FAIL)
listener.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, truststore.getFile());
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -728,9 +722,10 @@
client.enumerateInstanceNames(dummyCop);
} catch (WBEMException e) {
if (e.getCause() != null
- && (e.getCause().getClass().equals(SSLException.class) || e.getCause()
- .getClass().equals(SSLHandshakeException.class))) {
- // expected SSLException
+ && (e.getCause().getClass().equals(SSLException.class)
+ || e.getCause().getClass().equals(SSLHandshakeException.class) || e
+ .getCause().getClass().equals(SocketException.class))) {
+ // expected SSLException or SocketException
} else fail("Connection established with listener peer verification enabled with untrusted client keystore");
} finally {
listener.removeListener(port);
@@ -738,7 +733,7 @@
// LISTENER_PEER_VERIFICATION enabled at domain-level but no client
// keystore (should FAIL)
listener.setProperty(WBEMConfigurationProperties.TRUSTSTORE_PATH, truststore.getFile());
- port = listener.addListener(ilsBrief, port, "https");
+ port = listener.addListener(ilsBrief, 0, "https");
try {
client = (WBEMClientSBLIM) initClient(new URL("https://localhost:" + port), null, null);
client.setProperty(WBEMConfigurationProperties.SSL_CLIENT_PEER_VERIFICATION, "false");
@@ -748,9 +743,10 @@
client.enumerateInstanceNames(dummyCop);
} catch (WBEMException e) {
if (e.getCause() != null
- && (e.getCause().getClass().equals(SSLException.class) || e.getCause()
- .getClass().equals(SSLHandshakeException.class))) {
- // expected SSLException
+ && (e.getCause().getClass().equals(SSLException.class)
+ || e.getCause().getClass().equals(SSLHandshakeException.class) || e
+ .getCause().getClass().equals(SocketException.class))) {
+ // expected SSLException or SocketException
} else fail("Connection established with listener peer verification enabled but no client keystore");
} finally {
listener.removeListener(port);
|