update test sw pac migration
This commit is contained in:
parent
0ec838dbe7
commit
113489da3f
@ -39,80 +39,54 @@ public class PacMigrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() {
|
public void testCreateDW() {
|
||||||
int count = getPacsCount();
|
int count = getPacsCount();
|
||||||
String user = "ad";
|
String user = "ad";
|
||||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
|
||||||
Map<String, Object> setParams = new HashMap<String, Object>();
|
|
||||||
setParams.put("name", "aaa04");
|
|
||||||
setParams.put("hive", "h99");
|
|
||||||
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
|
|
||||||
setParams.put("basepac", BasePacType.PAC_DW);
|
|
||||||
setParams.put("curinetaddr", "176.9.242.77");
|
|
||||||
HashMap<String, String> components = new HashMap<String, String>();
|
|
||||||
components.put("QUOTA", "640");
|
|
||||||
components.put("TRAFFIC", "4");
|
|
||||||
components.put("DAEMON", "1");
|
|
||||||
setParams.put("components", components);
|
|
||||||
Object[] params = new Object[] { user,
|
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
||||||
setParams };
|
|
||||||
try {
|
try {
|
||||||
Object execute = client.execute(MODULE + ".add", params);
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||||
assertTrue(execute instanceof Map<?, ?>);
|
Object execute = addPac(user, grantingTicketURL,
|
||||||
Map<String, Object> whereParams = new HashMap<String, Object>();
|
"aaa04", BasePacType.PAC_DW, "176.9.242.77",
|
||||||
whereParams.put("name", "aaa04");
|
640, 4, 1);
|
||||||
params = new Object[] { user,
|
assertEquals(count + 1, getPacsCount());
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
validateAddedPac(execute, BasePacType.PAC_DW, 640, 4, 1);
|
||||||
whereParams };
|
setPacAdminPassword(user, grantingTicketURL, "aaa04", "test123");
|
||||||
execute = client.execute(MODULE + ".search", params);
|
|
||||||
assertNotNull(execute);
|
|
||||||
assertTrue(execute instanceof Object[]);
|
|
||||||
Object[] untypedResultArray = (Object[]) execute;
|
|
||||||
assertEquals(1, untypedResultArray.length);
|
|
||||||
assertTrue(untypedResultArray[0] instanceof Map<?,?>);
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<String, ?> pacResultMap = (Map<String, ?>) untypedResultArray[0];
|
|
||||||
assertEquals(BasePacType.PAC_DW, pacResultMap.get("basepac"));
|
|
||||||
Object compMapObj = pacResultMap.get("components");
|
|
||||||
assertTrue(compMapObj instanceof Map<?,?>);
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<String,String> compMap = (Map<String, String>) compMapObj;
|
|
||||||
assertEquals("640", compMap.get("QUOTA"));
|
|
||||||
assertEquals("4", compMap.get("TRAFFIC"));
|
|
||||||
} catch (XmlRpcException e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
assertEquals(count + 1, getPacsCount());
|
|
||||||
setParams = new HashMap<String, Object>();
|
|
||||||
Map<String, String> whereParams = new HashMap<String, String>();
|
|
||||||
setParams.put("password", "test123");
|
|
||||||
whereParams.put("name", "aaa04");
|
|
||||||
params = new Object[] { user,
|
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
||||||
setParams, whereParams };
|
|
||||||
try {
|
|
||||||
client.execute("user.update", params);
|
|
||||||
} catch (XmlRpcException e) {
|
} catch (XmlRpcException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate() {
|
public void testCreateSW() {
|
||||||
|
int count = getPacsCount();
|
||||||
String user = "ad";
|
String user = "ad";
|
||||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
|
||||||
Map<String, Object> setParams = new HashMap<String, Object>();
|
|
||||||
Map<String, String> components = new HashMap<String, String>();
|
|
||||||
setParams.put("basepac", BasePacType.PAC_WEB);
|
|
||||||
setParams.put("components", components);
|
|
||||||
// components.put("QUOTA", "2048"); // does not work till now
|
|
||||||
Map<String, String> whereParams = new HashMap<String, String>();
|
|
||||||
whereParams.put("name", "aaa04");
|
|
||||||
Object[] params = new Object[] { user,
|
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
||||||
setParams, whereParams };
|
|
||||||
try {
|
try {
|
||||||
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||||
|
Object execute = addPac(user, grantingTicketURL,
|
||||||
|
"aaa05", BasePacType.PAC_SW, "176.9.242.77",
|
||||||
|
1024, 8, 0);
|
||||||
|
assertEquals(count + 1, getPacsCount());
|
||||||
|
validateAddedPac(execute, BasePacType.PAC_SW, 1024, 8, -1);
|
||||||
|
setPacAdminPassword(user, grantingTicketURL, "aaa05", "test123");
|
||||||
|
} catch (XmlRpcException e) {
|
||||||
|
fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateDW() {
|
||||||
|
String user = "ad";
|
||||||
|
try {
|
||||||
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||||
|
Map<String, Object> setParams = new HashMap<String, Object>();
|
||||||
|
Map<String, String> components = new HashMap<String, String>();
|
||||||
|
setParams.put("basepac", BasePacType.PAC_WEB);
|
||||||
|
setParams.put("components", components);
|
||||||
|
// components.put("QUOTA", "2048"); // does not yet work
|
||||||
|
Map<String, String> whereParams = new HashMap<String, String>();
|
||||||
|
whereParams.put("name", "aaa04");
|
||||||
|
Object[] params = new Object[] { user,
|
||||||
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
setParams, whereParams };
|
||||||
Object execute = client.execute(MODULE + ".update", params);
|
Object execute = client.execute(MODULE + ".update", params);
|
||||||
assertNotNull(execute);
|
assertNotNull(execute);
|
||||||
params = new Object[] { user,
|
params = new Object[] { user,
|
||||||
@ -132,13 +106,54 @@ public class PacMigrationTest {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String,String> compMap = (Map<String, String>) compMapObj;
|
Map<String,String> compMap = (Map<String, String>) compMapObj;
|
||||||
assertEquals("1024", compMap.get("QUOTA"));
|
assertEquals("1024", compMap.get("QUOTA"));
|
||||||
// assertEquals("2048", compMap.get("QUOTA")); // does not work till now
|
// assertEquals("2048", compMap.get("QUOTA")); // does not yet work
|
||||||
assertEquals("5", compMap.get("TRAFFIC"));
|
assertEquals("5", compMap.get("TRAFFIC"));
|
||||||
} catch (XmlRpcException e) {
|
} catch (XmlRpcException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateSW() {
|
||||||
|
String user = "ad";
|
||||||
|
try {
|
||||||
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||||
|
Map<String, Object> setParams = new HashMap<String, Object>();
|
||||||
|
Map<String, String> components = new HashMap<String, String>();
|
||||||
|
setParams.put("basepac", BasePacType.PAC_WEB);
|
||||||
|
setParams.put("components", components);
|
||||||
|
// components.put("QUOTA", "2048"); // does not yet work
|
||||||
|
Map<String, String> whereParams = new HashMap<String, String>();
|
||||||
|
whereParams.put("name", "aaa05");
|
||||||
|
Object[] params = new Object[] { user,
|
||||||
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
setParams, whereParams };
|
||||||
|
Object execute = client.execute(MODULE + ".update", params);
|
||||||
|
assertNotNull(execute);
|
||||||
|
params = new Object[] { user,
|
||||||
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
whereParams };
|
||||||
|
execute = client.execute(MODULE + ".search", params);
|
||||||
|
assertNotNull(execute);
|
||||||
|
assertTrue(execute instanceof Object[]);
|
||||||
|
Object[] untypedResultArray = (Object[]) execute;
|
||||||
|
assertEquals(1, untypedResultArray.length);
|
||||||
|
assertTrue(untypedResultArray[0] instanceof Map<?,?>);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, ?> pacResultMap = (Map<String, ?>) untypedResultArray[0];
|
||||||
|
assertEquals(BasePacType.PAC_WEB, pacResultMap.get("basepac"));
|
||||||
|
Object compMapObj = pacResultMap.get("components");
|
||||||
|
assertTrue(compMapObj instanceof Map<?,?>);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String,String> compMap = (Map<String, String>) compMapObj;
|
||||||
|
assertEquals("1024", compMap.get("QUOTA"));
|
||||||
|
// assertEquals("2048", compMap.get("QUOTA")); // does not yet work
|
||||||
|
assertEquals("10", compMap.get("TRAFFIC"));
|
||||||
|
} catch (XmlRpcException e) {
|
||||||
|
fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int getPacsCount() {
|
private int getPacsCount() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
String user = "hsh00-aaa";
|
String user = "hsh00-aaa";
|
||||||
@ -158,4 +173,68 @@ public class PacMigrationTest {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object addPac(String user, String grantingTicketURL,
|
||||||
|
String pacName, String basepacName, String inetAddr,
|
||||||
|
int quota, int traffic, int daemons)
|
||||||
|
throws XmlRpcException {
|
||||||
|
Map<String, Object> setParams = new HashMap<String, Object>();
|
||||||
|
setParams.put("name", pacName);
|
||||||
|
setParams.put("hive", "h99");
|
||||||
|
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
|
||||||
|
setParams.put("basepac", basepacName);
|
||||||
|
setParams.put("curinetaddr", inetAddr);
|
||||||
|
HashMap<String, String> components = new HashMap<String, String>();
|
||||||
|
components.put("QUOTA", Integer.toString(quota));
|
||||||
|
components.put("TRAFFIC", Integer.toString(traffic));
|
||||||
|
components.put("DAEMON", Integer.toString(daemons));
|
||||||
|
setParams.put("components", components);
|
||||||
|
Object[] params = new Object[] { user,
|
||||||
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
setParams };
|
||||||
|
Object execute = client.execute(MODULE + ".add", params);
|
||||||
|
assertTrue(execute instanceof Map<?, ?>);
|
||||||
|
Map<String, Object> whereParams = new HashMap<String, Object>();
|
||||||
|
whereParams.put("name", pacName);
|
||||||
|
params = new Object[] { user,
|
||||||
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
whereParams };
|
||||||
|
execute = client.execute(MODULE + ".search", params);
|
||||||
|
return execute;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateAddedPac(Object execute, String basepacName, int quota, int traffic, int daemons) {
|
||||||
|
assertNotNull(execute);
|
||||||
|
assertTrue(execute instanceof Object[]);
|
||||||
|
Object[] untypedResultArray = (Object[]) execute;
|
||||||
|
assertEquals(1, untypedResultArray.length);
|
||||||
|
assertTrue(untypedResultArray[0] instanceof Map<?,?>);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, ?> pacResultMap = (Map<String, ?>) untypedResultArray[0];
|
||||||
|
assertEquals(basepacName, pacResultMap.get("basepac"));
|
||||||
|
Object compMapObj = pacResultMap.get("components");
|
||||||
|
assertTrue(compMapObj instanceof Map<?,?>);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String,String> compMap = (Map<String, String>) compMapObj;
|
||||||
|
assertEquals(Integer.toString(quota), compMap.get("QUOTA"));
|
||||||
|
assertEquals(Integer.toString(traffic), compMap.get("TRAFFIC"));
|
||||||
|
if (daemons >= 0) {
|
||||||
|
assertEquals(Integer.toString(daemons), compMap.get("DAEMON"));
|
||||||
|
} else {
|
||||||
|
assertTrue(compMap.get("DAEMON") == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPacAdminPassword(String user, String grantingTicketURL,
|
||||||
|
String pacName, String password)
|
||||||
|
throws XmlRpcException {
|
||||||
|
HashMap<String, Object> whereParams = new HashMap<String, Object>();
|
||||||
|
HashMap<String, Object> setParams = new HashMap<String, Object>();
|
||||||
|
whereParams.put("name", pacName);
|
||||||
|
setParams.put("password", password);
|
||||||
|
Object[] params = new Object[] { user,
|
||||||
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
setParams, whereParams };
|
||||||
|
client.execute("user.update", params);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user