2011-03-30 18:26:43 +02:00
|
|
|
package de.hsadmin.remote;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
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;
|
|
|
|
|
|
|
|
public class RoleTest {
|
|
|
|
|
|
|
|
private static final String MODULE = "role";
|
|
|
|
|
|
|
|
private XmlRpcClient client;
|
|
|
|
private RemoteCASHelper cas;
|
|
|
|
|
|
|
|
@Before
|
|
|
|
public void setUp() throws Exception {
|
|
|
|
client = RemoteTestHelper.getClient();
|
|
|
|
cas = new RemoteCASHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
|
|
public void tearDown() throws Exception {
|
|
|
|
client = null;
|
|
|
|
cas = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testPacAdmin() {
|
|
|
|
String user = "aaa00";
|
|
|
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
|
|
|
Map<String, String> whereParams = new HashMap<String, String>();
|
|
|
|
Object[] params = new Object[] { user,
|
|
|
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
|
|
whereParams };
|
|
|
|
try {
|
|
|
|
Object execute = client.execute(MODULE + ".search", params);
|
|
|
|
Object[] result = (Object[]) execute;
|
|
|
|
assertTrue(result.length == 1);
|
|
|
|
String role = (String) ((Map<?, ?>) result[0]).get("role");
|
2013-05-01 09:54:28 +02:00
|
|
|
assertEquals("PAC_ADMIN_DW", role);
|
2011-03-30 18:26:43 +02:00
|
|
|
} catch (XmlRpcException e) {
|
|
|
|
fail(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDomAdmin() {
|
|
|
|
String user = "aaa00-admin";
|
|
|
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
|
|
|
Map<String, String> whereParams = new HashMap<String, String>();
|
|
|
|
Object[] params = new Object[] { user,
|
|
|
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
|
|
whereParams };
|
|
|
|
try {
|
|
|
|
Object execute = client.execute(MODULE + ".search", params);
|
|
|
|
Object[] result = (Object[]) execute;
|
|
|
|
assertTrue(result.length == 1);
|
|
|
|
String role = (String) ((Map<?, ?>) result[0]).get("role");
|
|
|
|
assertEquals("DOM_ADMIN", role);
|
|
|
|
} catch (XmlRpcException e) {
|
|
|
|
fail(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCustomer() {
|
|
|
|
String user = "aaa";
|
|
|
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
|
|
|
Map<String, String> whereParams = new HashMap<String, String>();
|
|
|
|
Object[] params = new Object[] { user,
|
|
|
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
|
|
whereParams };
|
|
|
|
try {
|
|
|
|
Object execute = client.execute(MODULE + ".search", params);
|
|
|
|
Object[] result = (Object[]) execute;
|
|
|
|
assertTrue(result.length == 1);
|
|
|
|
String role = (String) ((Map<?, ?>) result[0]).get("role");
|
|
|
|
assertEquals("CUSTOMER", role);
|
|
|
|
} catch (XmlRpcException e) {
|
|
|
|
fail(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testHostmaster() {
|
2011-08-30 15:41:19 +02:00
|
|
|
String user = "ad";
|
2011-03-30 18:26:43 +02:00
|
|
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
|
|
|
Map<String, String> whereParams = new HashMap<String, String>();
|
|
|
|
Object[] params = new Object[] { user,
|
|
|
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
|
|
whereParams };
|
|
|
|
try {
|
|
|
|
Object execute = client.execute(MODULE + ".search", params);
|
|
|
|
Object[] result = (Object[]) execute;
|
|
|
|
assertTrue(result.length == 1);
|
|
|
|
String role = (String) ((Map<?, ?>) result[0]).get("role");
|
|
|
|
assertEquals("HOSTMASTER", role);
|
|
|
|
} catch (XmlRpcException e) {
|
|
|
|
fail(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|