oidc junit test
This commit is contained in:
parent
9de80d518d
commit
d45d232cd8
3 changed files with 121 additions and 1 deletions
|
|
@ -20,3 +20,5 @@ You can access the application from our Web browser
|
||||||
http://localhost:8080
|
http://localhost:8080
|
||||||
|
|
||||||
(Default user `admin' - default passwort `adminadmin`)
|
(Default user `admin' - default passwort `adminadmin`)
|
||||||
|
|
||||||
|
## SSO KeyCloak
|
||||||
|
|
|
||||||
|
|
@ -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<ItemCollection> 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
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 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"
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
// @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<ItemCollection> result = workflowCLient.getTaskListByOwner(null);
|
||||||
|
assertNotNull(result);
|
||||||
|
document = result.get(0);
|
||||||
|
|
||||||
|
// compare result with test data
|
||||||
|
assertNotNull(document);
|
||||||
|
} catch (RestAPIException e) {
|
||||||
|
fail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
20
pom.xml
20
pom.xml
|
|
@ -76,6 +76,7 @@
|
||||||
<org.imixs.ai.version>1.1.4-SNAPSHOT</org.imixs.ai.version>
|
<org.imixs.ai.version>1.1.4-SNAPSHOT</org.imixs.ai.version>
|
||||||
<org.imixs.metrics.version>1.0.0-SNAPSHOT</org.imixs.metrics.version>
|
<org.imixs.metrics.version>1.0.0-SNAPSHOT</org.imixs.metrics.version>
|
||||||
<org.imixs.signature.version>1.0.0</org.imixs.signature.version>
|
<org.imixs.signature.version>1.0.0</org.imixs.signature.version>
|
||||||
|
<org.imixs.melman.version>2.1.1-SNAPSHOT</org.imixs.melman.version>
|
||||||
<net.sf.saxon.version>9.9.1-4</net.sf.saxon.version>
|
<net.sf.saxon.version>9.9.1-4</net.sf.saxon.version>
|
||||||
<apache.pdfbox.version>2.0.24</apache.pdfbox.version>
|
<apache.pdfbox.version>2.0.24</apache.pdfbox.version>
|
||||||
<!-- test dependencies -->
|
<!-- test dependencies -->
|
||||||
|
|
@ -447,6 +448,18 @@
|
||||||
<version>2.0.1</version>
|
<version>2.0.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
|
<artifactId>jersey-media-jaxb</artifactId>
|
||||||
|
<version>3.1.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
|
<artifactId>jersey-client</artifactId>
|
||||||
|
<version>3.1.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- HTTP Client -->
|
<!-- HTTP Client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
@ -455,7 +468,12 @@
|
||||||
<version>5.2.1</version>
|
<version>5.2.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.imixs.workflow</groupId>
|
||||||
|
<artifactId>imixs-melman</artifactId>
|
||||||
|
<version>${org.imixs.melman.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
Loading…
Reference in a new issue