Make it easier to use test utils
This commit is contained in:
parent
63ee50e39e
commit
42aba41d6b
6 changed files with 110 additions and 72 deletions
5
pom.xml
5
pom.xml
|
@ -400,6 +400,11 @@
|
|||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
Executing testsuite
|
||||
===================
|
||||
|
||||
Browser
|
||||
-------
|
||||
|
||||
The testsuite uses Sellenium. By default it uses the HtmlUnit WebDriver, but can also be executed with Chrome or Firefox.
|
||||
|
||||
To run the tests with Firefox add `-Dbrowser=firefox` or for Chrome add `-Dbrowser=chrome`
|
||||
|
||||
|
||||
Test utils
|
||||
==========
|
||||
|
||||
Keycloak server
|
||||
---------------
|
||||
|
||||
To start a basic Keycloak server for testing run:
|
||||
|
||||
mvn exec:java -Dexec.mainClass=org.keycloak.testutils.KeycloakServer
|
||||
|
||||
or just run KeycloakServer from your favourite IDE!
|
||||
|
||||
When starting the server it can also import a realm from a json file:
|
||||
|
||||
mvn exec:java -Dexec.mainClass=org.keycloak.testutils.KeycloakServer -Dexec.args="-import testrealm.json"
|
||||
|
||||
You can also change the host and port the server is bound to:
|
||||
|
||||
mvn exec:java -Dexec.mainClass=org.keycloak.testutils.KeycloakServer -Dexec.args="-b host -p 8080"
|
||||
|
||||
TOTP codes
|
||||
----------
|
||||
|
||||
To generate totp codes without Google authenticator run:
|
||||
|
||||
mvn exec:java -Dexec.mainClass=org.keycloak.testutils.TotpGenerator -Dexec.args="PJBX GURY NZIT C2JX I44T S3D2 JBKD G6SB"
|
||||
|
||||
or just run TotpGenerator from your favourite IDE!
|
||||
|
||||
Replace value of -Dexec.args with the secret from the totp configuration page
|
||||
|
||||
Mail server
|
||||
-----------
|
||||
|
||||
To start a test mail server for testing email sending run:
|
||||
|
||||
mvn exec:java -Dexec.mainClass=org.keycloak.testutils.MailServer
|
||||
|
||||
or just run MailServer from your favourite IDE!
|
||||
|
||||
To configure Keycloak to use the above server add:
|
||||
|
||||
-Dkeycloak.mail.smtp.from=auto@keycloak.org -Dkeycloak.mail.smtp.host=localhost -Dkeycloak.mail.smtp.port=3025
|
57
testsuite/integration/README.md
Normal file
57
testsuite/integration/README.md
Normal file
|
@ -0,0 +1,57 @@
|
|||
Executing testsuite
|
||||
===================
|
||||
|
||||
Browser
|
||||
-------
|
||||
|
||||
The testsuite uses Sellenium. By default it uses the HtmlUnit WebDriver, but can also be executed with Chrome or Firefox.
|
||||
|
||||
To run the tests with Firefox add `-Dbrowser=firefox` or for Chrome add `-Dbrowser=chrome`
|
||||
|
||||
|
||||
Test utils
|
||||
==========
|
||||
|
||||
Keycloak server
|
||||
---------------
|
||||
|
||||
To start a basic Keycloak server for testing run:
|
||||
|
||||
mvn exec:java -Pkeycloak-server
|
||||
|
||||
or run org.keycloak.testutils.KeycloakServer from your favourite IDE!
|
||||
|
||||
When starting the server it can also import a realm from a json file:
|
||||
|
||||
mvn exec:java -Pkeycloak-server -Dimport=testrealm.json
|
||||
|
||||
TOTP codes
|
||||
----------
|
||||
|
||||
To generate totp codes without Google authenticator run:
|
||||
|
||||
mvn exec:java -Ptotp -Dsecret='PJBX GURY NZIT C2JX I44T S3D2 JBKD G6SB'
|
||||
|
||||
or run org.keycloak.testutils.TotpGenerator from your favourite IDE!
|
||||
|
||||
Replace value of -Dsecret with the secret from the totp configuration page (remember quotes!)
|
||||
|
||||
Mail server
|
||||
-----------
|
||||
|
||||
To start a test mail server for testing email sending run:
|
||||
|
||||
mvn exec:java -Pmail-server
|
||||
|
||||
or run org.keycloak.testutils.MailServer from your favourite IDE!
|
||||
|
||||
To configure Keycloak to use the above server add the following system properties:
|
||||
|
||||
keycloak.mail.smtp.from=auto@keycloak.org
|
||||
keycloak.mail.smtp.host=localhost
|
||||
keycloak.mail.smtp.port=3025
|
||||
|
||||
For example if using the test utils Keycloak server start it with:
|
||||
|
||||
mvn exec:java -Pkeycloak-server -Dkeycloak.mail.smtp.from=auto@keycloak.org -Dkeycloak.mail.smtp.host=localhost -Dkeycloak.mail.smtp.port=3025
|
||||
|
|
@ -205,26 +205,49 @@
|
|||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jboss-managed</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jboss.as</groupId>
|
||||
<artifactId>jboss-as-arquillian-container-managed</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>7.1.1.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<id>keycloak-server</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>org.keycloak.testutils.KeycloakServer</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jboss-remote</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jboss.as</groupId>
|
||||
<artifactId>jboss-as-arquillian-container-remote</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>7.1.1.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<id>mail-server</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>org.keycloak.testutils.MailServer</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>totp</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>org.keycloak.testutils.TotpGenerator</mainClass>
|
||||
<arguments>
|
||||
<argument>${secret}</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -121,6 +121,10 @@ public class KeycloakServer {
|
|||
}
|
||||
}
|
||||
|
||||
if (System.getProperties().containsKey("import")) {
|
||||
keycloak.importRealm(new FileInputStream(System.getProperty("import")));
|
||||
}
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -13,6 +13,9 @@ public class MailServer {
|
|||
|
||||
GreenMail greenMail = new GreenMail(setup);
|
||||
greenMail.start();
|
||||
|
||||
System.out.println("Started mail server (localhost:3025)");
|
||||
System.out.println();
|
||||
|
||||
while (true) {
|
||||
int c = greenMail.getReceivedMessages().length;
|
||||
|
|
Loading…
Reference in a new issue