diff --git a/README.md b/README.md index a53b036..0e165d3 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,5 @@ You can access the application from our Web browser http://localhost:8080 (Default user `admin' - default passwort `adminadmin`) + +## SSO KeyCloak diff --git a/dynamixs-ai-app/src/test/java/ai/dynamixs/api/TestWorkfklowClient.java b/dynamixs-ai-app/src/test/java/ai/dynamixs/api/TestWorkfklowClient.java new file mode 100644 index 0000000..6c9879c --- /dev/null +++ b/dynamixs-ai-app/src/test/java/ai/dynamixs/api/TestWorkfklowClient.java @@ -0,0 +1,100 @@ +package ai.dynamixs.api; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +import java.util.List; + +import org.imixs.melman.FormAuthenticator; +import org.imixs.melman.OIDCAuthenticator; +import org.imixs.melman.RestAPIException; +import org.imixs.melman.WorkflowClient; +import org.imixs.workflow.ItemCollection; +import org.imixs.workflow.exceptions.PluginException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * Test class for workflowCLient + * + * @author rsoika + * + */ +public class TestWorkfklowClient { + + String baseURL = ""; + + @BeforeEach + public void setup() throws PluginException { + baseURL = "http://localhost:8080/api/"; + } + + /** + * test Form Based Auth + */ + // @Disabled + @Test + public void testGetDocumentFormAuth() { + + try { + FormAuthenticator basicAuth = new FormAuthenticator(baseURL, "admin", "adminadmin"); + + WorkflowClient workflowCLient = new WorkflowClient(baseURL); + + workflowCLient.registerClientRequestFilter(basicAuth); + + ItemCollection document = null; + + List result = workflowCLient.getTaskListByOwner(null); + assertNotNull(result); + document = result.get(0); + + // compare result with test data + assertNotNull(document); + } catch (RestAPIException e) { + fail(e.getMessage()); + } + } + + /** + * test OIDC + * + *
+	 *  curl -X POST \
+	-d "grant_type=password" \
+	-d "client_id=dynamixs.ai.demo" \
+	-d "client_secret=X1rogvjA3mg854pZL4Q0JKAblU3kTnHM" \
+	-d "username=rsoika" \
+	-d "password=ne-pt-un" \
+	"https://login.dynamixs.ai/realms/dynamixsai/protocol/openid-connect/token"
+	 * 
+ */ + // @Disabled + @Test + public void testGetDocumentOIDC() { + + try { + // Keycloak + String tokenEndpoint = "https://login.dynamixs.ai/realms/dynamixsai/protocol/openid-connect/token"; + OIDCAuthenticator auth = new OIDCAuthenticator( + tokenEndpoint, "dynamixs.ai.demo", "X1rogvjA3mg854pZL4Q0JKAblU3kTnHM", "rsoika", "ne-pt-un"); + + WorkflowClient workflowCLient = new WorkflowClient(baseURL); + + workflowCLient.registerClientRequestFilter(auth); + + ItemCollection document = null; + + List result = workflowCLient.getTaskListByOwner(null); + assertNotNull(result); + document = result.get(0); + + // compare result with test data + assertNotNull(document); + } catch (RestAPIException e) { + fail(e.getMessage()); + } + + } + +} diff --git a/pom.xml b/pom.xml index e34dcac..48ab79b 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,7 @@ 1.1.4-SNAPSHOT 1.0.0-SNAPSHOT 1.0.0 + 2.1.1-SNAPSHOT 9.9.1-4 2.0.24 @@ -447,6 +448,18 @@ 2.0.1 test + + org.glassfish.jersey.media + jersey-media-jaxb + 3.1.5 + test + + + org.glassfish.jersey.core + jersey-client + 3.1.5 + test + @@ -455,7 +468,12 @@ 5.2.1 test - + + org.imixs.workflow + imixs-melman + ${org.imixs.melman.version} + test + \ No newline at end of file