[keycloak-user] Integration Tests

Marek Posolda mposolda at redhat.com
Wed Apr 5 02:29:42 EDT 2017


On 05/04/17 01:15, Gabriel Trisca wrote:
> Hi Marek,
>
> Thanks for your response. If I understood correctly, those links 
> explain how to run Keycloak's testsuit (if I modified any of the 
> Keycloak source). What I'm looking for is something that I can run 
> from my own code.
>
> Doing some more googling, I found this thread from October: 
> http://lists.jboss.org/pipermail/keycloak-user/2016-October/008031.html 
> that mentions exactly what I'm looking for: a way for me to use the 
> KeycloakServer class in my tests to programatically start and 
> configure the server, instead of using a full "distribution" version 
> of Keycloak.
>
> Are there any plans to make KeycloakServer available for these types 
> of scenarios?
Nope, I think that we don't plan to officially support the "embedded" 
variant of Keycloak server. The preferred way is to use our distribution.

However there is nothing, which prevents you to use it in your project 
though. KeycloakServer is just a helper, which allows to run keycloak 
auth-server deployed on undertow. You can likely fork some code you need 
from it and use it in your own project. Just make sure that some 
functionalities, which require real Wildfly server won't work. For 
example JTA, provider deployers, datasources etc.

In shortcut: you can use it, but it's not officially recommended and 
supported distribution.

Marek
>
> Thanks in advance!
>
>
>
> On Tue, Apr 4, 2017 at 3:48 PM, Marek Posolda <mposolda at redhat.com 
> <mailto:mposolda at redhat.com>> wrote:
>
>     Hi,
>
>     there is some docs here
>     https://github.com/keycloak/keycloak/blob/master/misc/Testsuite.md
>     <https://github.com/keycloak/keycloak/blob/master/misc/Testsuite.md>
>     and here
>     https://github.com/keycloak/keycloak/blob/master/misc/HackingOnKeycloak.md
>     <https://github.com/keycloak/keycloak/blob/master/misc/HackingOnKeycloak.md>
>
>     Marek
>
>     On 04/04/17 19:17, Gabriel Trisca wrote:
>
>         Hi all,
>
>         What is the best way to run integration tests with Keycloak? I
>         would like
>         to have an embedded Keycloak server that can be brought up as
>         a @ClassRule
>         or something along those lines, and then I can validate that
>         different
>         users have or don't have access to resources/scopes.
>
>         I found that there is a testsuite path in Git that contains
>         many useful
>         classes, like a KeycloakServer that can be initialized with a
>         realm
>         exported as JSON, but this module
>         (keycloak-testsuite-integration) is not
>         deployed to Maven central.
>
>         I tried to clone the repository and install that artifact
>         locally, but I
>         face different errors that hint at mismatched versions in
>         dependencies:
>
>         Caused by: java.lang.NoSuchMethodError:
>         org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties;
>         at
>         org.hibernate.jpa.internal.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:124)
>         at
>         org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:890)
>         at
>         org.keycloak.connections.jpa.util.JpaUtils.createEntityManagerFactory(JpaUtils.java:63)
>         ...
>
>         Thanks in advance.
>
>
>
>
>
> -- 
> *Gabriel Trisca, Software Developer*
> Cignifi | 101 Main Street, 14th Floor, Cambridge, MA 02142  USA
> P: +1 857-209-2685 • M: +1 301-433-2221 | www.cignifi.com 
> <http://www.cignifi.com/>




More information about the keycloak-user mailing list