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

105 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;
2013-04-25 13:22:26 +02:00
import de.hsadmin.mods.pac.Pac;
2012-01-04 13:27:05 +01:00
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");
2013-04-25 13:22:26 +02:00
setParams.put("basepac", Pac.PAC_WEB_BASE);
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");
2013-04-25 13:22:26 +02:00
setParams.put("basepac", Pac.PAC_DW_BASE);
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
}