hs.hsadmin/hsarback/test/de/hsadmin/remote/SSLCertDomainTest.java

104 lines
3.3 KiB
Java
Raw Normal View History

2012-01-04 13:27:05 +01:00
package de.hsadmin.remote;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import de.hsadmin.core.qserv.CommandShell;
import de.hsadmin.core.qserv.ShellException;
import de.hsadmin.core.util.Config;
public class SSLCertDomainTest {
2012-01-04 13:54:30 +01:00
private static final String MODULE = "pac";
2012-01-04 13:27:05 +01:00
private XmlRpcClient client;
private RemoteCASHelper cas;
private Config config;
@Before
public void setUp() throws Exception {
client = RemoteTestHelper.getClient();
cas = new RemoteCASHelper();
config = Config.getInstance();
}
@After
public void tearDown() throws Exception {
client = null;
cas = null;
config = null;
}
@Test
public void testSSLCertWithoutChain() {
String user = "ad";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa02");
2012-04-05 16:58:34 +02:00
setParams.put("hive", "h99");
2012-01-04 13:27:05 +01:00
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", "PAC/WEB");
2012-04-05 20:45:52 +02:00
setParams.put("curinetaddr", "176.9.242.77");
2012-01-04 13:27:05 +01:00
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
Thread.sleep(5000L);
2012-01-04 14:45:57 +01:00
String out = CommandShell.execute("( ls /var/local/lxc/hive/etc/apache2/sites-generated/aaa02.hostsharing.net >/dev/null 2>&1 " +
" && grep 'SSLCertificateChainFile' /var/local/lxc/hive/etc/apache2/sites-generated/aaa02.hostsharing.net >/dev/null 2>&1 " +
2012-01-04 16:53:08 +01:00
" && echo fail )" +
" || echo Ok");
2012-01-04 14:45:57 +01:00
assertTrue(out.startsWith("Ok"));
2012-01-04 13:27:05 +01:00
} catch (XmlRpcException e) {
fail(e.getMessage());
} catch (ShellException e) {
2012-01-04 14:45:57 +01:00
fail(e.getMessage());
2012-01-04 13:27:05 +01:00
} catch (InterruptedException e) {
fail(e.getMessage());
}
}
2012-01-04 13:44:10 +01:00
@Test
public void testSSLCertWithChain() {
String user = "ad";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa03");
2012-04-05 16:58:34 +02:00
setParams.put("hive", "h99");
2012-01-04 13:44:10 +01:00
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", "DW/B");
2012-04-05 20:45:52 +02:00
setParams.put("curinetaddr", "176.9.242.78");
2012-01-04 13:44:10 +01:00
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
Thread.sleep(5000L);
2012-01-04 14:45:57 +01:00
String out = CommandShell.execute("( ls /var/local/lxc/hive/etc/apache2/sites-generated/aaa03.hostsharing.net >/dev/null 2>&1 " +
" && grep 'SSLCertificate.*default' /var/local/lxc/hive/etc/apache2/sites-generated/aaa03.hostsharing.net >/dev/null 2>&1 " +
2012-01-04 16:53:08 +01:00
" && echo fail )" +
" || echo Ok");
2012-01-04 14:45:57 +01:00
assertTrue(out.startsWith("Ok"));
2012-01-04 13:44:10 +01:00
} catch (XmlRpcException e) {
fail(e.getMessage());
} catch (ShellException e) {
2012-01-04 14:45:57 +01:00
fail(e.getMessage());
2012-01-04 13:44:10 +01:00
} catch (InterruptedException e) {
fail(e.getMessage());
}
}
2012-01-04 13:27:05 +01:00
}