Test Hostmaster ad

This commit is contained in:
Peter Hormanns 2011-05-05 19:04:14 +00:00
parent 733027b6bf
commit c2da1b8f8e
2 changed files with 52 additions and 4 deletions

View File

@ -95,7 +95,7 @@ public class CustomerTest {
@Test
public void testSearchAsPacAdmin() {
String user = "peh00";
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
@ -112,7 +112,7 @@ public class CustomerTest {
@Test
public void testSearchAsPacUser() {
String user = "peh00-phor";
String user = "aaa00-test2";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
@ -129,7 +129,7 @@ public class CustomerTest {
@Test
public void testSearchAsMember() {
String user = "hsh00-peh";
String user = "hsh00-aaa";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,

View File

@ -17,6 +17,7 @@ public class InitDataTest {
private static final String CUST_MODULE = "member";
private static final String PAC_MODULE = "pac";
private static final String USER_MODULE = "user";
private XmlRpcClient client;
private RemoteCASHelper cas;
@ -93,6 +94,35 @@ public class InitDataTest {
}
@Test
public void testAddUser() {
int count = getUsersCount();
try {
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa00-test2");
setParams.put("password", "test123");
setParams.put("quota", "128");
setParams.put("quotalimit", "192");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
Object execute = client.execute(USER_MODULE + ".add", params);
if (execute instanceof Map<?, ?>) {
Map<?, ?> entry = (Map<?, ?>) execute;
assertEquals("aaa00-test2", entry.get("name"));
assertEquals("aaa00", entry.get("pac"));
assertEquals(null, entry.get("password"));
} else {
fail("map expected");
}
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count + 1, getUsersCount());
}
// @Test
public void testDelPac() {
int count = getPacsCount();
String user = "ad";
@ -110,7 +140,7 @@ public class InitDataTest {
assertEquals(count - 1, getPacsCount());
}
@Test
// @Test
public void testDelMember() {
int count = getMembersCount();
String user = "ad";
@ -166,4 +196,22 @@ public class InitDataTest {
return count;
}
private int getUsersCount() {
int count = -1;
try {
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 };
Object execute = client.execute(USER_MODULE + ".search", params);
Object[] result = (Object[]) execute;
count = result.length;
} catch (XmlRpcException e) {
fail(e.getMessage());
}
return count;
}
}