diff --git a/hsarback/src/de/hsadmin/hostsharing/BasePacType.java b/hsarback/src/de/hsadmin/hostsharing/BasePacType.java index a804c1e..62bdc4d 100644 --- a/hsarback/src/de/hsadmin/hostsharing/BasePacType.java +++ b/hsarback/src/de/hsadmin/hostsharing/BasePacType.java @@ -2,8 +2,6 @@ package de.hsadmin.hostsharing; public class BasePacType { - public static final String PAC_DW = "PAC/DW"; - public static final String PAC_SW = "PAC/SW"; public static final String PAC_WEB = "PAC/WEB"; public static final String PAC_SRV = "SRV/MGD"; diff --git a/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java index 90a0b63..72e90f7 100644 --- a/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java @@ -58,7 +58,7 @@ public class MySqlDatabaseModuleImpl extends AbstractModuleImpl { } //TODO: Needs better implementation String pacType = pac.getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } //TODO: Needs better implementation diff --git a/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java index 29a458e..8ee87ad 100644 --- a/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java @@ -39,7 +39,7 @@ public class MySqlUserModuleImpl extends AbstractModuleImpl { } //TODO: Needs better implementation String pacType = pac.getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } //TODO: Needs better implementation diff --git a/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java index 84d3720..464b38e 100644 --- a/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java @@ -57,7 +57,7 @@ public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl { } //TODO: Needs better implementation String pacType = pac.getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } //TODO: Needs better implementation diff --git a/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java index c6034e4..6d4617b 100644 --- a/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java @@ -34,7 +34,7 @@ public class PgSqlUserModuleImpl extends AbstractModuleImpl { } //TODO: Needs better implementation String pacType = pac.getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } //TODO: Needs better implementation diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java index 72d298e..724694c 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -127,7 +127,7 @@ public class DomainModuleImpl extends AbstractModuleImpl { //TODO: Needs better implementation final Pac pac = admin.getPac(); String pacType = pac.getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } final String hiveName = pac.getHive().getHiveName(); diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java index 4be83c4..4103fd5 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java @@ -57,7 +57,7 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl { } //TODO: Needs better implementation String pacType = dom.getUser().getPac().getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } //TODO: Needs better implementation diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java index 2825386..17827d0 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java @@ -48,7 +48,7 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl { } //TODO: Needs better implementation String pacType = pac.getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } //TODO: Needs better implementation diff --git a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java index 76510f4..9b6e839 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java @@ -95,7 +95,7 @@ public class PacModuleImpl extends AbstractModuleImpl { pac.setPacComponents(pacComponents); AbstractEntity newPacEntity = null; String pacType = pac.getBasepac().getName(); - if (pacType.equals(BasePacType.PAC_WEB) || pacType.equals(BasePacType.PAC_DW) || pacType.equals(BasePacType.PAC_SW)) { + if (pacType.equals(BasePacType.PAC_WEB)) { Set users = new HashSet(); pac.setUnixUser(users); UnixUser admin = new UnixUser(); @@ -201,7 +201,7 @@ public class PacModuleImpl extends AbstractModuleImpl { throw new AuthorisationException(getTransaction().getLoginUser(), "delete", existingEntity); } String pacType = pac.getBasepac().getName(); - if (pacType.equals(BasePacType.PAC_WEB) || pacType.equals(BasePacType.PAC_DW) || pacType.equals(BasePacType.PAC_SW)) { + if (pacType.equals(BasePacType.PAC_WEB)) { GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction()); String[] dependQueries = new String[] { diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index 8625e1f..9edd6bd 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -27,7 +27,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { EntityManager em, T entity) throws ProcessorException { Pac pac = (Pac) entity; String basepacName = pac.getBasepac().getName(); - if (basepacName.equals(BasePacType.PAC_WEB) || basepacName.equals(BasePacType.PAC_DW) || basepacName.equals(BasePacType.PAC_SW)) { + if (basepacName.equals(BasePacType.PAC_WEB)) { String pacName = pac.getName(); Hive hive = pac.getHive(); UnixUser unixUser = getPacAdminUser(pac); @@ -54,7 +54,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { throws ProcessorException { Pac pac = (Pac) entity; String basepacName = pac.getBasepac().getName(); - if (basepacName.equals(BasePacType.PAC_WEB) || basepacName.equals(BasePacType.PAC_DW) || basepacName.equals(BasePacType.PAC_SW)) { + if (basepacName.equals(BasePacType.PAC_WEB)) { return createSetQuotaProc(pac); } else { return new NullProcessor(); @@ -65,7 +65,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { public Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException { Pac pac = (Pac) entity; String basepacName = pac.getBasepac().getName(); - if (basepacName.equals(BasePacType.PAC_WEB) || basepacName.equals(BasePacType.PAC_DW) || basepacName.equals(BasePacType.PAC_SW)) { + if (basepacName.equals(BasePacType.PAC_WEB)) { Hive hive = pac.getHive(); hive.getPacs().remove(pac); WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName())); diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java index 9b3253c..5ef663f 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java @@ -129,7 +129,7 @@ public class UnixUserModuleImpl extends AbstractModuleImpl { } //TODO: Needs better implementation String pacType = pac.getBasepac().getName(); - if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) { + if (!pacType.equals(BasePacType.PAC_WEB)) { throw new HSAdminException("not allowed for this packet type"); } //TODO: Needs better implementation diff --git a/hsarback/test/de/hsadmin/remote/ContinuousIntegrationTest.java b/hsarback/test/de/hsadmin/remote/ContinuousIntegrationTest.java index b93edea..98206be 100644 --- a/hsarback/test/de/hsadmin/remote/ContinuousIntegrationTest.java +++ b/hsarback/test/de/hsadmin/remote/ContinuousIntegrationTest.java @@ -19,7 +19,6 @@ import org.junit.runners.Suite; EMailAddressTest.class, SSLCertDomainTest.class, DatabaseCleanTest.class, - PacMigrationTest.class, CustomerTest.class // LongCustomerNameTest.class, // QueueTaskTest.class diff --git a/hsarback/test/de/hsadmin/remote/PacMigrationTest.java b/hsarback/test/de/hsadmin/remote/PacMigrationTest.java deleted file mode 100644 index 0d382e3..0000000 --- a/hsarback/test/de/hsadmin/remote/PacMigrationTest.java +++ /dev/null @@ -1,294 +0,0 @@ -package de.hsadmin.remote; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Calendar; -import java.util.Date; -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.util.Config; -import de.hsadmin.core.util.TextUtil; -import de.hsadmin.hostsharing.BasePacType; - -public class PacMigrationTest { - - private static final String MODULE = "pac"; - - 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; - } - - @Test - public void testSW() { - testCreateSW(); - testUpdateSW(); - testDeleteSW(); - } - - @Test - public void testDW() { - testCreateDW(); - testUpdateDW(); - } - - public void testCreateDW() { - int count = getPacsCount(); - String user = "ad"; - try { - String grantingTicketURL = cas.getGrantingTicketURL(user); - Object execute = addPac(user, grantingTicketURL, - "aaa04", BasePacType.PAC_DW, "176.9.242.77", - 640, 4, 1); - assertEquals(count + 1, getPacsCount()); - validateAddedPac(execute, BasePacType.PAC_DW, 640, 4, 1); - setPacAdminPassword(user, grantingTicketURL, "aaa04", "test123"); - } catch (XmlRpcException e) { - fail(e.getMessage()); - } - } - - public void testCreateSW() { - int count = getPacsCount(); - String user = "ad"; - try { - String grantingTicketURL = cas.getGrantingTicketURL(user); - Object execute = addPac(user, grantingTicketURL, - "aaa05", BasePacType.PAC_SW, "176.9.242.77", - 1024, 8, -1); - assertEquals(count + 1, getPacsCount()); - validateAddedPac(execute, BasePacType.PAC_SW, 1024, 8, -1); - setPacAdminPassword(user, grantingTicketURL, "aaa05", "test123"); - } catch (XmlRpcException e) { - fail(e.getMessage()); - } - } - - public void testUpdateDW() { - String user = "ad"; - try { - String grantingTicketURL = cas.getGrantingTicketURL(user); - Map setParams = new HashMap(); - Map components = new HashMap(); - setParams.put("basepac", BasePacType.PAC_WEB); - setParams.put("components", components); -// components.put("QUOTA", "2048"); // does not yet work - Map whereParams = new HashMap(); - whereParams.put("name", "aaa04"); - 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 pacResultMap = (Map) untypedResultArray[0]; - assertEquals(BasePacType.PAC_WEB, pacResultMap.get("basepac")); - Object compMapObj = pacResultMap.get("components"); - assertTrue(compMapObj instanceof Map); - @SuppressWarnings("unchecked") - Map compMap = (Map) compMapObj; - assertEquals("1024", compMap.get("QUOTA")); -// assertEquals("2048", compMap.get("QUOTA")); // does not yet work - assertEquals("5", compMap.get("TRAFFIC")); - } catch (XmlRpcException e) { - fail(e.getMessage()); - } - } - - public void testUpdateSW() { - String user = "ad"; - try { - String grantingTicketURL = cas.getGrantingTicketURL(user); - Map setParams = new HashMap(); - Map components = new HashMap(); - setParams.put("basepac", BasePacType.PAC_WEB); - setParams.put("components", components); -// components.put("QUOTA", "2048"); // does not yet work - Map whereParams = new HashMap(); - 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 pacResultMap = (Map) untypedResultArray[0]; - assertEquals(BasePacType.PAC_WEB, pacResultMap.get("basepac")); - Object compMapObj = pacResultMap.get("components"); - assertTrue(compMapObj instanceof Map); - @SuppressWarnings("unchecked") - Map compMap = (Map) 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()); - } - } - - public void testDeleteSW() { - String user = "ad"; - try { - int count = getPacsCount(); - String grantingTicketURL = cas.getGrantingTicketURL(user); - Map setParams = new HashMap(); - setParams.put("created", TextUtil.format(daysBack(10))); - Map whereParams = new HashMap(); - 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); - setParams = new HashMap(); - setParams.put("cancelled", TextUtil.format(daysBack(1))); - whereParams = new HashMap(); - whereParams.put("name", "aaa05"); - params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), - setParams, whereParams }; - execute = client.execute(MODULE + ".update", params); - assertNotNull(execute); - whereParams.put("name", "aaa05"); - params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), - whereParams }; - execute = client.execute(MODULE + ".delete", params); - assertEquals(count - 1, getPacsCount()); - } catch (XmlRpcException e) { - fail(e.getMessage()); - } - } - - private Date daysBack(int days) { - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.DAY_OF_YEAR, -days); - return calendar.getTime(); - } - - private int getPacsCount() { - int count = 0; - String user = "hsh00-aaa"; - String grantingTicketURL = cas.getGrantingTicketURL(user); - Map whereParams = new HashMap(); - whereParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa"); - Object[] params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), - whereParams }; - try { - Object execute = client.execute(MODULE + ".search", params); - Object[] result = (Object[]) execute; - count = result.length; - } catch (XmlRpcException e) { - fail(e.getMessage()); - } - return count; - } - - private Object addPac(String user, String grantingTicketURL, - String pacName, String basepacName, String inetAddr, - int quota, int traffic, int daemons) - throws XmlRpcException { - Map setParams = new HashMap(); - 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 components = new HashMap(); - components.put("QUOTA", Integer.toString(quota)); - components.put("TRAFFIC", Integer.toString(traffic)); - if (daemons >= 0) { - 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 whereParams = new HashMap(); - 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 pacResultMap = (Map) untypedResultArray[0]; - assertEquals(basepacName, pacResultMap.get("basepac")); - Object compMapObj = pacResultMap.get("components"); - assertTrue(compMapObj instanceof Map); - @SuppressWarnings("unchecked") - Map compMap = (Map) 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 whereParams = new HashMap(); - HashMap setParams = new HashMap(); - 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); - } - -} diff --git a/hsarback/test/de/hsadmin/remote/RemoteTest.java b/hsarback/test/de/hsadmin/remote/RemoteTest.java index 11f81d9..5781974 100644 --- a/hsarback/test/de/hsadmin/remote/RemoteTest.java +++ b/hsarback/test/de/hsadmin/remote/RemoteTest.java @@ -18,7 +18,6 @@ import org.junit.runners.Suite; DomainDeleteTest.class, EMailAddressTest.class, DatabaseCleanTest.class, - PacMigrationTest.class, CustomerTest.class // LongCustomerNameTest.class // QueueTaskTest.class diff --git a/hsarback/test/de/hsadmin/remote/SSLCertDomainTest.java b/hsarback/test/de/hsadmin/remote/SSLCertDomainTest.java index 802ae3a..c40926f 100644 --- a/hsarback/test/de/hsadmin/remote/SSLCertDomainTest.java +++ b/hsarback/test/de/hsadmin/remote/SSLCertDomainTest.java @@ -79,7 +79,7 @@ public class SSLCertDomainTest { setParams.put("name", "aaa03"); setParams.put("hive", "h99"); setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa"); - setParams.put("basepac", BasePacType.PAC_DW); + setParams.put("basepac", BasePacType.PAC_WEB); setParams.put("curinetaddr", "176.9.242.78"); Object[] params = new Object[] { user, cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),