aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/test/java')
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/module/test/TestRequestImpl.java264
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/SpringExpressionAwareProcessEngineTest.java95
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/CreateSAML1AssertionTask.java8
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/GetIdentityLinkTask.java9
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SelectBKUTask.java6
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SignAuthBlockTask.java10
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateIdentityLinkTask.java6
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateSignedAuthBlockTask.java6
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HalloWeltTask.java7
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HelloWorldTask.java7
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/ProcessEngineTest.java111
-rw-r--r--id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/UnitTestCase.java3
-rw-r--r--id/server/idserverlib/src/test/java/test/tlenz/simpletest.java44
13 files changed, 498 insertions, 78 deletions
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/module/test/TestRequestImpl.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/module/test/TestRequestImpl.java
new file mode 100644
index 000000000..66dffe311
--- /dev/null
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/module/test/TestRequestImpl.java
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.module.test;
+
+import java.util.Collection;
+
+import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
+import at.gv.egovernment.moa.id.commons.api.exceptions.SessionDataStorageException;
+
+/**
+ * @author tlenz
+ *
+ */
+public class TestRequestImpl implements IRequest {
+
+ private String processInstanceID = null;
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#requestedModule()
+ */
+ @Override
+ public String requestedModule() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#requestedAction()
+ */
+ @Override
+ public String requestedAction() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getOAURL()
+ */
+ @Override
+ public String getOAURL() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#isPassiv()
+ */
+ @Override
+ public boolean isPassiv() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#forceAuth()
+ */
+ @Override
+ public boolean forceAuth() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getGenericData(java.lang.String)
+ */
+ @Override
+ public Object getGenericData(String key) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getGenericData(java.lang.String, java.lang.Class)
+ */
+ @Override
+ public <T> T getGenericData(String key, Class<T> clazz) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#setGenericDataToSession(java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setGenericDataToSession(String key, Object object) throws SessionDataStorageException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getRequestID()
+ */
+ @Override
+ public String getRequestID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getMOASessionIdentifier()
+ */
+ @Override
+ public String getMOASessionIdentifier() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getUniqueTransactionIdentifier()
+ */
+ @Override
+ public String getUniqueTransactionIdentifier() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getUniqueSessionIdentifier()
+ */
+ @Override
+ public String getUniqueSessionIdentifier() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getProcessInstanceId()
+ */
+ @Override
+ public String getProcessInstanceId() {
+ return processInstanceID;
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getAuthURL()
+ */
+ @Override
+ public String getAuthURL() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getAuthURLWithOutSlash()
+ */
+ @Override
+ public String getAuthURLWithOutSlash() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#isNeedAuthentication()
+ */
+ @Override
+ public boolean isNeedAuthentication() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#needSingleSignOnFunctionality()
+ */
+ @Override
+ public boolean needSingleSignOnFunctionality() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#setNeedSingleSignOnFunctionality(boolean)
+ */
+ @Override
+ public void setNeedSingleSignOnFunctionality(boolean needSSO) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#isAuthenticated()
+ */
+ @Override
+ public boolean isAuthenticated() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#setAuthenticated(boolean)
+ */
+ @Override
+ public void setAuthenticated(boolean isAuthenticated) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getOnlineApplicationConfiguration()
+ */
+ @Override
+ public IOAAuthParameters getOnlineApplicationConfiguration() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @param processInstanceID the processInstanceID to set
+ */
+ public void setProcessInstanceID(String processInstanceID) {
+ this.processInstanceID = processInstanceID;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#isAbortedByUser()
+ */
+ @Override
+ public boolean isAbortedByUser() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#setAbortedByUser(boolean)
+ */
+ @Override
+ public void setAbortedByUser(boolean isAborted) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.moduls.IRequest#getRequestedAttributes()
+ */
+ @Override
+ public Collection<String> getRequestedAttributes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/SpringExpressionAwareProcessEngineTest.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/SpringExpressionAwareProcessEngineTest.java
index 7288ae2b2..2cb2a3278 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/SpringExpressionAwareProcessEngineTest.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/SpringExpressionAwareProcessEngineTest.java
@@ -1,30 +1,32 @@
package at.gv.egovernment.moa.id.process.spring.test;
-import static at.gv.egovernment.moa.id.process.ProcessInstanceState.*;
-import static org.junit.Assert.*;
+import static at.gv.egovernment.moa.id.process.ProcessInstanceState.NOT_STARTED;
+import static at.gv.egovernment.moa.id.process.ProcessInstanceState.SUSPENDED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.hibernate.cfg.Configuration;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
import at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils;
-import at.gv.egovernment.moa.id.commons.db.dao.session.InterfederationSessionStore;
-import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
+import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore;
+import at.gv.egovernment.moa.id.module.test.TestRequestImpl;
import at.gv.egovernment.moa.id.process.ProcessDefinitionParserException;
import at.gv.egovernment.moa.id.process.ProcessEngine;
import at.gv.egovernment.moa.id.process.ProcessEngineImpl;
import at.gv.egovernment.moa.id.process.ProcessExecutionException;
import at.gv.egovernment.moa.id.process.ProcessInstance;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
-import at.gv.egovernment.moa.id.process.dao.ProcessInstanceStore;
import at.gv.egovernment.moa.id.process.spring.SpringExpressionEvaluator;
/**
@@ -34,25 +36,34 @@ import at.gv.egovernment.moa.id.process.spring.SpringExpressionEvaluator;
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration
+@ContextConfiguration("/at/gv/egovernment/moa/id/process/spring/test/SpringExpressionAwareProcessEngineTest-context.xml")
public class SpringExpressionAwareProcessEngineTest {
+ @Autowired private static ProcessEngine pe;
+ @Autowired private ApplicationContext applicationContext;
- private static ProcessEngine pe;
+ private boolean isInitialized = false;
- @BeforeClass
- public static void init() throws IOException, ProcessDefinitionParserException {
+ @Before
+ public void init() throws IOException, ProcessDefinitionParserException {
- pe = new ProcessEngineImpl();
- ((ProcessEngineImpl) pe).setTransitionConditionExpressionEvaluator(new SpringExpressionEvaluator());
- try (InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream("SampleProcessDefinitionWithExpression1.xml")) {
- ((ProcessEngineImpl) pe).registerProcessDefinition(in);
- }
- try (InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream("SampleProcessDefinitionForSAML1Authentication.xml")) {
- ((ProcessEngineImpl) pe).registerProcessDefinition(in);
- }
+ if (!isInitialized) {
+
+ if (pe == null) {
+ pe = applicationContext.getBean("processEngine", ProcessEngine.class);
+
+ }
+
+ ((ProcessEngineImpl) pe).setTransitionConditionExpressionEvaluator(new SpringExpressionEvaluator());
+ try (InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream("SampleProcessDefinitionWithExpression1.xml")) {
+ ((ProcessEngineImpl) pe).registerProcessDefinition(in);
+ }
+ try (InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream("SampleProcessDefinitionForSAML1Authentication.xml")) {
+ ((ProcessEngineImpl) pe).registerProcessDefinition(in);
+ }
initHibernateForTesting();
+ }
}
private static void initHibernateForTesting() throws IOException{
@@ -65,8 +76,8 @@ public class SpringExpressionAwareProcessEngineTest {
//ConfigurationDBUtils.initHibernate(props);
Configuration config = new Configuration();
config.addProperties(props);
- config.addAnnotatedClass(ProcessInstanceStore.class);
- config.addAnnotatedClass(InterfederationSessionStore.class);
+ //config.addAnnotatedClass(ProcessInstanceStore.class);
+ config.addAnnotatedClass(AssertionStore.class);
MOASessionDBUtils.initHibernate(config, props);
} catch (Exception e) {
e.printStackTrace();
@@ -77,30 +88,44 @@ public class SpringExpressionAwareProcessEngineTest {
@Test
public void testSampleProcessDefinitionWithExpression1() throws IOException, ProcessDefinitionParserException, ProcessExecutionException {
+ TestRequestImpl req = new TestRequestImpl();
+
String piId = pe.createProcessInstance("SampleProcessWithExpression1");
ProcessInstance pi = pe.getProcessInstance(piId);
assertEquals(NOT_STARTED, pi.getState());
// start process
- pe.start(piId);
- pi = pe.getProcessInstance(piId);
- assertEquals(ENDED, pi.getState());
+ req.setProcessInstanceID(piId);
+ pe.start(req);
+
+ //processInstance should be removed when it ends
+ try {
+ pi = pe.getProcessInstance(piId);
+ throw new ProcessExecutionException("ProcessInstance should be removed already, but it was found.");
+ //assertEquals(ENDED, pi.getState());
+
+ } catch (IllegalArgumentException e) {
+ // do nothing because processInstance should be already removed
+
+ }
}
@Test
public void testSampleProcessDefinitionForSAML1Authentication() throws IOException, ProcessDefinitionParserException, ProcessExecutionException {
+ TestRequestImpl req = new TestRequestImpl();
+
String piId = pe.createProcessInstance("SampleProcessDefinitionForSAML1Authentication");
ProcessInstance pi = pe.getProcessInstance(piId);
assertEquals(NOT_STARTED, pi.getState());
// start process
- pe.start(piId);
- pi = pe.getProcessInstance(piId);
- assertEquals(ENDED, pi.getState());
-
+ req.setProcessInstanceID(piId);
+ pe.start(req);
pi = pe.getProcessInstance(piId);
+ assertEquals(SUSPENDED, pi.getState());
+
ExecutionContext ec = pi.getExecutionContext();
assertNotNull(ec);
System.out.println(ec.keySet());
@@ -111,6 +136,20 @@ public class SpringExpressionAwareProcessEngineTest {
assertNotNull(ec.get("SignedAuthBlock"));
assertNotNull(ec.get("isSignedAuthBlockValidated"));
assertNotNull(ec.get("SAML1Assertion"));
+
+ pe.signal(req);
+ try {
+ pi = pe.getProcessInstance(piId);
+ throw new ProcessExecutionException("ProcessInstance should be removed already, but it was found.");
+ //assertEquals(ENDED, pi.getState());
+
+ } catch (IllegalArgumentException e) {
+ // do nothing because processInstance should be already removed
+
+ }
+
+
+
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/CreateSAML1AssertionTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/CreateSAML1AssertionTask.java
index ebda3c5c3..54515ab8e 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/CreateSAML1AssertionTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/CreateSAML1AssertionTask.java
@@ -8,8 +8,10 @@ import java.util.Objects;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
import at.gv.egovernment.moa.id.auth.modules.TaskExecutionException;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -34,12 +36,13 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("CreateSAML1AssertionTask")
public class CreateSAML1AssertionTask implements Task {
private Logger log = LoggerFactory.getLogger(getClass());
@Override
- public void execute(ExecutionContext executionContext) throws TaskExecutionException {
+ public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException {
Objects.requireNonNull(executionContext.get("IdentityLink"));
assert (Boolean.TRUE.equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated"))));
Objects.requireNonNull(executionContext.get("SignedAuthBlock"));
@@ -51,9 +54,10 @@ public class CreateSAML1AssertionTask implements Task {
executionContext.put("SAML1Assertion", IOUtils.toString(in, Charset.forName("UTF-8")));
} catch (IOException e) {
- throw new TaskExecutionException("", e);
+ throw new TaskExecutionException(null, "", e);
}
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/GetIdentityLinkTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/GetIdentityLinkTask.java
index bd08ec6a1..266878d7e 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/GetIdentityLinkTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/GetIdentityLinkTask.java
@@ -8,8 +8,10 @@ import java.util.Objects;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
import at.gv.egovernment.moa.id.auth.modules.TaskExecutionException;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -33,12 +35,13 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("GetIdentityLinkTask")
public class GetIdentityLinkTask implements Task {
private Logger log = LoggerFactory.getLogger(getClass());
@Override
- public void execute(ExecutionContext executionContext) throws TaskExecutionException {
+ public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException {
Objects.requireNonNull(executionContext.get("bkuURL"));
log.debug("Using bkuURL in order to retrieve IdentityLink.");
@@ -47,8 +50,10 @@ public class GetIdentityLinkTask implements Task {
executionContext.put("IdentityLink", IOUtils.toString(in, Charset.forName("UTF-8")));
} catch (IOException e) {
- throw new TaskExecutionException("", e);
+ throw new TaskExecutionException(null, "", e);
}
+
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SelectBKUTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SelectBKUTask.java
index 54195ec91..915cb3b1e 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SelectBKUTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SelectBKUTask.java
@@ -2,7 +2,9 @@ package at.gv.egovernment.moa.id.process.spring.test.task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -20,14 +22,16 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("SelectBKUTask")
public class SelectBKUTask implements Task {
private Logger log = LoggerFactory.getLogger(getClass());
@Override
- public void execute(ExecutionContext executionContext) {
+ public IRequest execute(IRequest penReq, ExecutionContext executionContext) {
log.debug("Providing BKU selection.");
executionContext.put("bkuURL", "https://127.0.0.1:3496/https-security-layer-request");
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SignAuthBlockTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SignAuthBlockTask.java
index 8f9b72cea..41ccb4451 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SignAuthBlockTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/SignAuthBlockTask.java
@@ -8,8 +8,10 @@ import java.util.Objects;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
import at.gv.egovernment.moa.id.auth.modules.TaskExecutionException;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -35,12 +37,13 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("SignAuthBlockTask")
public class SignAuthBlockTask implements Task {
private Logger log = LoggerFactory.getLogger(getClass());
@Override
- public void execute(ExecutionContext executionContext) throws TaskExecutionException {
+ public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException {
Objects.requireNonNull(executionContext.get("IdentityLink"));
assert (Boolean.TRUE.equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated"))));
Objects.requireNonNull(executionContext.get("bkuURL"));
@@ -49,9 +52,10 @@ public class SignAuthBlockTask implements Task {
try (InputStream in = getClass().getResourceAsStream("SignedAuthBlock.xml")) {
executionContext.put("SignedAuthBlock", IOUtils.toString(in, Charset.forName("UTF-8")));
} catch (IOException e) {
- throw new TaskExecutionException("", e);
-
+ throw new TaskExecutionException(null, "", e);
+
}
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateIdentityLinkTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateIdentityLinkTask.java
index a8e7df3d7..818e8b479 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateIdentityLinkTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateIdentityLinkTask.java
@@ -4,7 +4,9 @@ import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -26,17 +28,19 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("ValidateIdentityLinkTask")
public class ValidateIdentityLinkTask implements Task {
private Logger log = LoggerFactory.getLogger(getClass());
@Override
- public void execute(ExecutionContext executionContext) {
+ public IRequest execute(IRequest penReq, ExecutionContext executionContext) {
Objects.requireNonNull(executionContext.get("IdentityLink"));
log.debug("Validating IdentityLink.");
executionContext.put("isIdentityLinkValidated", true);
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateSignedAuthBlockTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateSignedAuthBlockTask.java
index cece373d4..2ee67ec27 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateSignedAuthBlockTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/spring/test/task/ValidateSignedAuthBlockTask.java
@@ -4,8 +4,10 @@ import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
import at.gv.egovernment.moa.id.auth.modules.TaskExecutionException;
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -29,12 +31,13 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("ValidateSignedAuthBlockTask")
public class ValidateSignedAuthBlockTask implements Task {
private Logger log = LoggerFactory.getLogger(getClass());
@Override
- public void execute(ExecutionContext executionContext) throws TaskExecutionException {
+ public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException {
Objects.requireNonNull(executionContext.get("IdentityLink"));
assert (Boolean.TRUE.equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated"))));
Objects.requireNonNull(executionContext.get("SignedAuthBlock"));
@@ -42,6 +45,7 @@ public class ValidateSignedAuthBlockTask implements Task {
log.debug("Using validated IdentityLink and signed auth block in order to validate signed auth block.");
executionContext.put("isSignedAuthBlockValidated", true);
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HalloWeltTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HalloWeltTask.java
index d05200ee8..1f77eadbc 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HalloWeltTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HalloWeltTask.java
@@ -1,5 +1,8 @@
package at.gv.egovernment.moa.id.process.test;
+import org.springframework.stereotype.Service;
+
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -9,11 +12,13 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("HalloWeltTask")
public class HalloWeltTask implements Task {
@Override
- public void execute(ExecutionContext executionContext) {
+ public IRequest execute(IRequest pendingReq, ExecutionContext executionContext) {
System.out.println("Hallo Welt");
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HelloWorldTask.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HelloWorldTask.java
index e79bb8198..bc640e97a 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HelloWorldTask.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/HelloWorldTask.java
@@ -1,5 +1,8 @@
package at.gv.egovernment.moa.id.process.test;
+import org.springframework.stereotype.Service;
+
+import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.process.api.Task;
@@ -9,11 +12,13 @@ import at.gv.egovernment.moa.id.process.api.Task;
* @author tknall
*
*/
+@Service("HelloWorldTask")
public class HelloWorldTask implements Task {
@Override
- public void execute(ExecutionContext executionContext) {
+ public IRequest execute(IRequest pendingReq, ExecutionContext executionContext) {
System.out.println("Hello World");
+ return null;
}
}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/ProcessEngineTest.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/ProcessEngineTest.java
index fa9f2ad06..a7e351e25 100644
--- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/ProcessEngineTest.java
+++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/process/test/ProcessEngineTest.java
@@ -1,51 +1,66 @@
package at.gv.egovernment.moa.id.process.test;
-import static at.gv.egovernment.moa.id.process.ProcessInstanceState.*;
-import static org.junit.Assert.*;
+import static at.gv.egovernment.moa.id.process.ProcessInstanceState.NOT_STARTED;
+import static at.gv.egovernment.moa.id.process.ProcessInstanceState.SUSPENDED;
+import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.hibernate.cfg.Configuration;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils;
-import at.gv.egovernment.moa.id.commons.db.dao.session.InterfederationSessionStore;
-import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
+import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore;
+import at.gv.egovernment.moa.id.module.test.TestRequestImpl;
import at.gv.egovernment.moa.id.process.ProcessDefinitionParser;
import at.gv.egovernment.moa.id.process.ProcessDefinitionParserException;
import at.gv.egovernment.moa.id.process.ProcessEngine;
import at.gv.egovernment.moa.id.process.ProcessEngineImpl;
import at.gv.egovernment.moa.id.process.ProcessExecutionException;
import at.gv.egovernment.moa.id.process.ProcessInstance;
-import at.gv.egovernment.moa.id.process.dao.ProcessInstanceStore;
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/at/gv/egovernment/moa/id/process/spring/test/SpringExpressionAwareProcessEngineTest-context.xml")
public class ProcessEngineTest {
- private static ProcessEngine pe;
-
- @BeforeClass
- public static void init() throws IOException, ProcessDefinitionParserException {
-
- ProcessDefinitionParser pdp = new ProcessDefinitionParser();
+ @Autowired private static ProcessEngine pe;
- pe = new ProcessEngineImpl();
-
- ((ProcessEngineImpl) pe).setTransitionConditionExpressionEvaluator(new BooleanStringExpressionEvaluator());
- try (InputStream in = ProcessEngineTest.class.getResourceAsStream("SampleProcessDefinition1.xml")) {
- ((ProcessEngineImpl) pe).registerProcessDefinition(pdp.parse(in));
- }
- try (InputStream in = ProcessEngineTest.class.getResourceAsStream("SampleProcessDefinition2.xml")) {
- ((ProcessEngineImpl) pe).registerProcessDefinition(pdp.parse(in));
+ @Autowired private ApplicationContext applicationContext;
+
+ private boolean isInitialized = false;
+
+ @Before
+ public void init() throws IOException, ProcessDefinitionParserException {
+
+ if (!isInitialized) {
+ ProcessDefinitionParser pdp = new ProcessDefinitionParser();
+
+ if (pe == null) {
+ pe = applicationContext.getBean("processEngine", ProcessEngine.class);
+
+ }
+
+ ((ProcessEngineImpl) pe).setTransitionConditionExpressionEvaluator(new BooleanStringExpressionEvaluator());
+ try (InputStream in = ProcessEngineTest.class.getResourceAsStream("SampleProcessDefinition1.xml")) {
+ ((ProcessEngineImpl) pe).registerProcessDefinition(pdp.parse(in));
+ }
+ try (InputStream in = ProcessEngineTest.class.getResourceAsStream("SampleProcessDefinition2.xml")) {
+ ((ProcessEngineImpl) pe).registerProcessDefinition(pdp.parse(in));
+ }
+
+ initHibernateForTesting();
+ isInitialized = true;
}
-
- initHibernateForTesting();
}
-
-
+
private static void initHibernateForTesting() throws IOException{
InputStream in = ProcessEngineTest.class.getResourceAsStream("/at/gv/egovernment/moa/id/process/hibernate.configuration.test.properties");
@@ -56,8 +71,8 @@ public class ProcessEngineTest {
//ConfigurationDBUtils.initHibernate(props);
Configuration config = new Configuration();
config.addProperties(props);
- config.addAnnotatedClass(ProcessInstanceStore.class);
- config.addAnnotatedClass(InterfederationSessionStore.class);
+ //config.addAnnotatedClass(ProcessInstanceStore.class);
+ config.addAnnotatedClass(AssertionStore.class);
MOASessionDBUtils.initHibernate(config, props);
} catch (Exception e) {
e.printStackTrace();
@@ -66,38 +81,62 @@ public class ProcessEngineTest {
@Test
public void testSampleProcess1() throws IOException, ProcessDefinitionParserException, ProcessExecutionException {
-
+
+ TestRequestImpl testReq = new TestRequestImpl();
+
String piId = pe.createProcessInstance("SampleProcess1");
ProcessInstance pi = pe.getProcessInstance(piId);
assertEquals(NOT_STARTED, pi.getState());
// start process
- pe.start(piId);
+ testReq.setProcessInstanceID(piId);
+ pe.start(testReq);
pi = pe.getProcessInstance(piId);
assertEquals(SUSPENDED, pi.getState());
System.out.println("Do something asynchronously");
- pe.signal(piId);
- pi = pe.getProcessInstance(piId);
- assertEquals(ENDED, pi.getState());
+ testReq.setProcessInstanceID(piId);
+ pe.signal(testReq);
+ try {
+ pi = pe.getProcessInstance(piId);
+ throw new ProcessExecutionException("ProcessInstance should be removed already, but it was found.");
+ //assertEquals(ENDED, pi.getState());
+
+ } catch (IllegalArgumentException e) {
+ // do nothing because processInstance should be already removed
+
+ }
}
@Test
public void testSampleProcess2() throws IOException, ProcessDefinitionParserException, ProcessExecutionException {
+ TestRequestImpl testReq = new TestRequestImpl();
+
String piId = pe.createProcessInstance("SampleProcess2");
ProcessInstance pi = pe.getProcessInstance(piId);
assertEquals(NOT_STARTED, pi.getState());
// start process
- pe.start(piId);
+ testReq.setProcessInstanceID(piId);
+ pe.start(testReq);
pi = pe.getProcessInstance(piId);
assertEquals(SUSPENDED, pi.getState());
System.out.println("Do something asynchronously");
- pe.signal(piId);
- pi = pe.getProcessInstance(piId);
- assertEquals(ENDED, pi.getState());
+ testReq.setProcessInstanceID(piId);
+ pe.signal(testReq);
+ try {
+ pi = pe.getProcessInstance(piId);
+ throw new ProcessExecutionException("ProcessInstance should be removed already, but it was found.");
+ //assertEquals(ENDED, pi.getState());
+
+ } catch (IllegalArgumentException e) {
+ // do nothing because processInstance should be already removed
+
+ }
+
+
}
@Test(expected = IllegalArgumentException.class)
diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/UnitTestCase.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/UnitTestCase.java
index a645aa5a2..a05159c27 100644
--- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/UnitTestCase.java
+++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/UnitTestCase.java
@@ -46,10 +46,9 @@
package test.at.gv.egovernment.moa.id;
+import at.gv.egovernment.moa.id.commons.api.ConfigurationProvider;
import test.MOAIDTestCase;
-import at.gv.egovernment.moa.id.config.ConfigurationProvider;
-
/**
* Base class for MOA ID test cases.
*
diff --git a/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java b/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java
index fd1473b1f..2c80b7ffd 100644
--- a/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java
+++ b/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java
@@ -1,7 +1,11 @@
package test.tlenz;
+import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import org.w3c.dom.Element;
@@ -58,6 +62,46 @@ import at.gv.egovernment.moa.util.DOMUtils;
public class simpletest {
//
public static void main(String[] args) {
+
+
+ URI fileURI = null;
+ try {
+ fileURI = new URI("file:c:/moa3/tomcat8/conf/moa-id/moa-id.properties");
+ File propertiesFile = new File(fileURI);
+
+ InputStream in = new FileInputStream(propertiesFile);
+ ObjectInputStream testOIS = new ObjectInputStream(in);
+
+ Object test = testOIS.readObject();
+
+
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ try {
+ fileURI = new URI("file:/c:/moa3/tomcat8/conf/moa-id/moa-id.properties");
+ File propertiesFile = new File(fileURI);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ try {
+ fileURI = new URI("file://c:/moa3/tomcat8/conf/moa-id/moa-id.properties");
+ File propertiesFile = new File(fileURI);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ try {
+ fileURI = new URI("file:///c:/moa3/tomcat8/conf/moa-id/moa-id.properties");
+ File propertiesFile = new File(fileURI);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+
+
try {
InputStream s = new FileInputStream("D:/idl_test/identity_link.xml");
Element idlTemplate = DOMUtils.parseXmlValidating(s);