embedded-keycloak

embedded keycloak for testing

License

License

Categories

Categories

KeY Data Data Formats Formal Verification Keycloak Security
GroupId

GroupId

io.github.mausamyede
ArtifactId

ArtifactId

embedded-keycloak_2.13
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

embedded-keycloak
embedded keycloak for testing
Project URL

Project URL

https://github.com/mausamyede/embedded-keycloak
Project Organization

Project Organization

io.github.mausamyede
Source Code Management

Source Code Management

https://github.com/mausamyede/embedded-keycloak

Download embedded-keycloak_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.mausamyede/embedded-keycloak_2.13/ -->
<dependency>
    <groupId>io.github.mausamyede</groupId>
    <artifactId>embedded-keycloak_2.13</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.mausamyede/embedded-keycloak_2.13/
implementation 'io.github.mausamyede:embedded-keycloak_2.13:0.2.0'
// https://jarcasting.com/artifacts/io.github.mausamyede/embedded-keycloak_2.13/
implementation ("io.github.mausamyede:embedded-keycloak_2.13:0.2.0")
'io.github.mausamyede:embedded-keycloak_2.13:jar:0.2.0'
<dependency org="io.github.mausamyede" name="embedded-keycloak_2.13" rev="0.2.0">
  <artifact name="embedded-keycloak_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.mausamyede', module='embedded-keycloak_2.13', version='0.2.0')
)
libraryDependencies += "io.github.mausamyede" % "embedded-keycloak_2.13" % "0.2.0"
[io.github.mausamyede/embedded-keycloak_2.13 "0.2.0"]

Dependencies

compile (8)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.3
com.lihaoyi : requests_2.13 jar 0.6.5
com.lihaoyi : os-lib_2.13 jar 0.7.1
com.lihaoyi : upickle_2.13 jar 1.2.2
com.lihaoyi : ujson_2.13 jar 1.2.2
com.iheart : ficus_2.13 jar 1.5.0
com.typesafe.akka : akka-http_2.13 jar 10.2.1
com.typesafe.akka : akka-stream_2.13 jar 2.6.10

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.13 jar 3.2.2

Project Modules

There are no modules declared in this project.

Embedded Keycloak

Embedded keycloak server for jvm integration testing. (developed in scala)

[Build Status

Installation

add the resolver:

resolvers += "jitpack" at "https://jitpack.io"

add the dependency:

libraryDependencies += "com.github.tmtsoftware.embedded-keycloak" %% "embedded-keycloak" % "<ADD_LATEST_VERSION_HERE>"

Usage

val keycloak = new EmbeddedKeycloak(
      KeycloakData.fromConfig, // or directly: `KeycloakData(...)`
      Settings.default) // or customize: Settings(...)

val stopHandle = await(keycloak.startServerInBackground())

//do some testing here

stopHandle.stop()

Settings

the following settings options are available.

The default settings looks like this -

Settings(port: Int = 8081,
         host: String = "0.0.0.0",
         keycloakDirectory: String = "/tmp/embedded-keycloak/",
         cleanPreviousData: Boolean = true,
         alwaysDownload: Boolean = false,
         version: String = "8.0.1")

Keycloak Data

The test data can be provided in application.conf of test scope.

For example -

embedded-keycloak{
    adminUser {
      username = admin
      password = admin
    }
    realms = [{
      name = example-realm
      realmRoles = [super-admin]
      clients = [
        {
          name = some-server
          clientType = bearer-only
          clientRoles = [server-admin, server-user]
          authorizationEnabled = true
        },
        {
          name = some-client
        }
      ]
      users = [
        {
          username = user1
          password = abcd,
          realmRoles = [super-admin]
          firstName = john
        },
        {
          username = user2
          password = abcd,
          clientRoles = [{
            clientName = some-server
            roleName = server-user
          }]
      }]
    }]
}

Or the same data can be provided directly as shown below:

    val data = KeycloakData(
      adminUser = AdminUser("admin", "admin"),
      realms = Set(
        Realm(
          name = "example-realm",
          clients = Set(
            Client(
              name = "some-server",
              clientType = "bearer-only",
              clientRoles = Set("server-admin", "server-user"),
              authorizationEnabled = true
            ),
            Client(name = "some-client")
          ),
          users = Set(
            ApplicationUser(
              username = "user1",
              firstName = "john",
              password = "abcd",
              realmRoles = Set("super-admin")
            ),
            ApplicationUser(
              username = "user2",
              password = "abcd",
              clientRoles = Set(ClientRole("some-server", "server-user"))
            )
          ),
          realmRoles = Set("super-admin")
        ))
    )

Versions

Version
0.2.0
0.1.0