provide option for developer tests without cas and ssl

fix several errors on domainoptions
This commit is contained in:
Peter Hormanns 2012-07-19 14:27:58 +00:00
parent f170f011aa
commit f09b319789
11 changed files with 274 additions and 28 deletions

View File

@ -0,0 +1,33 @@
<Context path="/hsar" reloadable="true" crossContext="true">
<ResourceLink
name="jdbc/HSAdminDB"
global="jdbc/HSAdminDB"
type="javax.sql.DataSource"/>
<ResourceLink
name="jms/QueueCF"
global="jms/QueueCF"
type="javax.jms.QueueConnectionFactory"/>
<ResourceLink
name="jms/hsadminSystem-h99"
global="jms/hsadminSystem-h99"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-testmail"
global="jms/hsadminSystem-testmail"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-testdns"
global="jms/hsadminSystem-testdns"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminStatus"
global="jms/hsadminStatus"
type="javax.jms.Queue"/>
</Context>

View File

@ -0,0 +1,185 @@
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<listener>
<listener-class>de.hsadmin.core.model.onetier.PersistenceManagerContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Queue Status Servlet</servlet-name>
<servlet-class>de.hsadmin.core.qserv.QueueStatusReceiverServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>CLI Client Connector</servlet-name>
<servlet-class>de.hsadmin.cliClientConnector.CLIClientConnectorServlet</servlet-class>
<init-param>
<param-name>proxyValidateUrl</param-name>
<param-value>TestUmgebung</param-value>
</init-param>
<init-param>
<param-name>proxyServiceUrl</param-name>
<param-value>TestUmgebung</param-value>
</init-param>
<init-param>
<param-name>Components</param-name>
<param-value>member,pac,user,domain,emailaddress,emailalias,mysqluser,mysqldb,postgresqluser,postgresqldb,q</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_member</param-name>
<param-value>de.hsadmin.mods.cust.Customer</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_member</param-name>
<param-value>Mitglieder</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_pac</param-name>
<param-value>de.hsadmin.mods.pac.Pac</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_pac</param-name>
<param-value>Pakete</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_user</param-name>
<param-value>de.hsadmin.mods.user.UnixUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_user</param-name>
<param-value>Benutzer und Postfaecher anlegen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_domain</param-name>
<param-value>de.hsadmin.mods.dom.Domain</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_domain</param-name>
<param-value>Domains aufschalten</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailaddress</param-name>
<param-value>de.hsadmin.mods.email.EMailAddress</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailaddress</param-name>
<param-value>E-Mail Adressen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailalias</param-name>
<param-value>de.hsadmin.mods.email.EMailAlias</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailalias</param-name>
<param-value>E-Mail Aliases</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqluser</param-name>
<param-value>de.hsadmin.mods.db.PgSqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqluser</param-name>
<param-value>PostgreSQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqldb</param-name>
<param-value>de.hsadmin.mods.db.PgSqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqldb</param-name>
<param-value>PostgreSQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqluser</param-name>
<param-value>de.hsadmin.mods.db.MySqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqluser</param-name>
<param-value>MySQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqldb</param-name>
<param-value>de.hsadmin.mods.db.MySqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqldb</param-name>
<param-value>MySQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_q</param-name>
<param-value>de.hsadmin.core.qserv.QueueTask</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_q</param-name>
<param-value>Offene Aktionen</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>XmlRpcServlet</servlet-name>
<servlet-class>org.apache.xmlrpc.webserver.XmlRpcServlet</servlet-class>
<init-param>
<param-name>enabledForExtensions</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Queue Status Servlet</servlet-name>
<url-pattern>/queueStatus</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CLI Client Connector</servlet-name>
<url-pattern>/hsadmin/cli-interface/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc/*</url-pattern>
</servlet-mapping>
<resource-ref>
<res-ref-name>jdbc/HSAdminDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>jms/QueueCF</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h99</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-testdns</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-testmail</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminStatus</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>

View File

@ -1,5 +1,5 @@
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=ssl://agnes.ostwall195.de:61617
java.naming.provider.url=ssl://config-test.ostwall195.de:61617
connectionFactoryNames=QueueCF
queue.hsadminSystem-h81=queue.hsadminSystem-h81
queue.hsadminStatus=queue.hsadminStatus

View File

@ -160,9 +160,6 @@ public class Transaction {
* old and new attribute values.
*/
public void detach(AbstractEntity entity) {
// TODO: replace hibernate specific implmentation
// org.hibernate.Session hSession = (Session) entityManager.getDelegate();
// hSession.evict(entity);
if (entityManager instanceof OpenJPAEntityManager) {
OpenJPAEntityManager openjpaEM = (OpenJPAEntityManager) entityManager;
openjpaEM.detach(entity);

View File

@ -40,7 +40,16 @@ public class TicketValidator {
}
public String validateTicket(String ticket) throws AuthenticationException {
if (proxyServiceURL == null || proxyServiceURL == null) {
// for testing purpose only
if ("TestUmgebung".equals(proxyServiceURL) && "TestUmgebung".equals(proxyValidateURL)) {
if (ticket.startsWith("user:")) {
return ticket.substring(5);
} else {
throw new AuthenticationException("Invalid Ticket: " + ticket);
}
}
// real implementation
if (proxyServiceURL == null || proxyValidateURL == null) {
log.fatal("TicketValidator is not initialized.");
throw new RuntimeException("TicketValidator is not initialized.");
}

View File

@ -14,6 +14,7 @@ import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
@ -68,7 +69,10 @@ public class Domain extends AbstractEntity {
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
private String dnsMaster;
@ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="domains")
@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
@JoinTable(name="domain__domain_option",
joinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")},
inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")})
private Set<DomainOption> domainOptions;
public Domain() {

View File

@ -162,6 +162,8 @@ public class DomainModuleImpl extends AbstractModuleImpl {
List<?> list = q.getResultList();
if (list.size() != 1) {
throw new HSAdminException("invalid domain option: " + opt.getName());
} else {
opt.setId(((DomainOption) list.get(0)).getId());
}
}
needsWriteAccessOn(existingEntity, "update");

View File

@ -2,17 +2,14 @@ package de.hsadmin.mods.dom;
import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Set;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@ -35,12 +32,9 @@ public class DomainOption extends AbstractEntity {
@Column(name = "domain_option_name", columnDefinition = "character varying(256)", nullable = false)
private String name;
@ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
@JoinTable(name="domain__domain_option",
joinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")},
inverseJoinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")})
private Set<Domain> domains;
@ManyToMany(mappedBy="domainOptions", fetch=FetchType.LAZY)
private List<Domain> domains;
@Override
public long id() {
return getId();
@ -78,11 +72,30 @@ public class DomainOption extends AbstractEntity {
this.name = name;
}
public Set<Domain> getDomains() {
@Override
public boolean equals(Object obj) {
if (obj instanceof DomainOption) {
DomainOption opt = (DomainOption) obj;
return getName().equals(opt.getName());
}
return false;
}
@Override
public int hashCode() {
return getName().hashCode();
}
@Override
public String toString() {
return getName();
}
public List<Domain> getDomains() {
return domains;
}
public void setDomains(Set<Domain> domains) {
public void setDomains(List<Domain> domains) {
this.domains = domains;
}

View File

@ -4,10 +4,10 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.dom.Domain;
@ -61,7 +61,7 @@ public class DomainRemote extends AbstractRemote {
u.setName(user);
dom.setUser(u);
}
Set<DomainOption> domainOptionsSet = new TreeSet<DomainOption>();
Set<DomainOption> domainOptionsSet = new HashSet<DomainOption>();
Object domOptsObj = setParams.get("domainoptions");
if (domOptsObj != null && domOptsObj instanceof Object[]) {
Object[] domOptions = (Object[]) domOptsObj;

View File

@ -51,7 +51,6 @@ public class DomainTest {
for (Object o : result) {
if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o;
// assertEquals("aaa00", row.get("user"));
assertTrue("aaa00".equals(row.get("user")) || "aaa00-admin".equals(row.get("user")));
} else {
fail("map expected");
@ -78,7 +77,6 @@ public class DomainTest {
assertNotNull(execute);
fail("exception expected");
} catch (XmlRpcException e) {
// System.out.println(e.getMessage());
}
}
@ -199,7 +197,6 @@ public class DomainTest {
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, Object> setParams = new HashMap<String, Object>();
Map<String, String> whereParams = new HashMap<String, String>();
setParams.put("user", "aaa00");
List<String> optionslist = new ArrayList<String>();
setParams.put("domainoptions", optionslist);
whereParams.put("name", "example01.org");
@ -245,16 +242,16 @@ public class DomainTest {
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
assertEquals(1, result.length);
assertEquals(result.length, 1);
assertTrue(result[0] instanceof Map<?, ?>);
Map<String, ?> domainMap = (Map<String, ?>) result[0];
assertNotNull(domainMap);
Object[] optsList = (Object[])domainMap.get("domainoptions");
// if (optsList == null) {
// count = 0;
// } else {
if (optsList == null) {
count = 0;
} else {
count = optsList.length;
// }
}
} catch (XmlRpcException e) {
fail(e.getMessage());
}

View File

@ -35,6 +35,9 @@ public class RemoteCASHelper {
}
public String getGrantingTicketURL(String user) {
if ("TestUmgebung".equals(loginURL)) {
return "granting:" + user;
}
String pw = Config.getInstance().getProperty(user + ".passWord", "-");
try {
String encodedParams = URLEncoder.encode("username", "UTF-8")
@ -49,6 +52,9 @@ public class RemoteCASHelper {
}
public String getServiceTicket(String location, String service) {
if (location.startsWith("granting:")) {
return "user:" + location.substring(9);
}
try {
String encodedParams = URLEncoder.encode("service", "UTF-8")
+ "=" + URLEncoder.encode(service, "UTF-8");