-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testsuite of keycloak-admin-client in keycloak-client repository
closes keycloak/keycloak#31867 Signed-off-by: mposolda <[email protected]>
- Loading branch information
Showing
18 changed files
with
508 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-client-testsuite-parent</artifactId> | ||
<version>26.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>keycloak-admin-client-jee-testsuite</artifactId> | ||
|
||
<properties> | ||
<resteasy.version>${resteasy-legacy.version}</resteasy.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-client-testsuite-framework</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-admin-client</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-admin-client-testsuite</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
<type>test-jar</type> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>*</artifactId> | ||
<groupId>*</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-admin-client-jee</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.smallrye.config</groupId> | ||
<artifactId>smallrye-config</artifactId> | ||
<version>${smallrye.config.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
12 changes: 12 additions & 0 deletions
12
...ee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/ClasspathJEETest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.keycloak.client.testsuite.adminclientjee; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Marek Posolda</a> | ||
*/ | ||
public class ClasspathJEETest extends org.keycloak.client.testsuite.adminclient.ClasspathTest { | ||
|
||
@Override | ||
protected String getExpectedClientFieldClass() { | ||
return "javax.ws.rs.client.Client"; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...t-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/RealmsJEETest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.keycloak.client.testsuite.adminclientjee; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Marek Posolda</a> | ||
*/ | ||
public class RealmsJEETest extends org.keycloak.client.testsuite.adminclient.RealmsTest { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-client-testsuite-parent</artifactId> | ||
<version>26.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>keycloak-admin-client-testsuite</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-client-testsuite-framework</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifestEntries> | ||
<Multi-Release>true</Multi-Release> | ||
</manifestEntries> | ||
</archive> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
33 changes: 33 additions & 0 deletions
33
...ests/src/test/java/org/keycloak/client/testsuite/adminclient/AbstractAdminClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.keycloak.client.testsuite.adminclient; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.keycloak.admin.client.Keycloak; | ||
import org.keycloak.client.testsuite.KeycloakContainersTestsuiteContext; | ||
import org.keycloak.client.testsuite.RemoteTestsuiteContext; | ||
import org.keycloak.client.testsuite.TestsuiteContext; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Marek Posolda</a> | ||
*/ | ||
public abstract class AbstractAdminClientTest { | ||
|
||
private static TestsuiteContext testsuiteContext; | ||
protected static Keycloak adminClient; | ||
|
||
@BeforeAll | ||
public static void beforeAll() { | ||
String keycloakLifecycle = System.getProperty("keycloak.lifecycle"); | ||
testsuiteContext = "remote".equalsIgnoreCase(keycloakLifecycle) ? new RemoteTestsuiteContext() : new KeycloakContainersTestsuiteContext(); | ||
|
||
testsuiteContext.startKeycloakServer(); | ||
adminClient = testsuiteContext.getKeycloakAdminClient(); | ||
} | ||
|
||
@AfterAll | ||
public static void afterAll() { | ||
testsuiteContext.stopKeycloakServer(); | ||
} | ||
|
||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...n-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/ClasspathTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.keycloak.client.testsuite.adminclient; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
import org.jboss.resteasy.client.jaxrs.ResteasyClient; | ||
import org.junit.jupiter.api.Test; | ||
import org.keycloak.admin.client.Keycloak; | ||
import org.testcontainers.shaded.org.hamcrest.MatcherAssert; | ||
|
||
import static org.testcontainers.shaded.org.hamcrest.Matchers.equalTo; | ||
|
||
/** | ||
* Test that I have correct versions of admin-client (admin-client VS admin-client-jee) and corresponding libraries on classpath | ||
* | ||
* @author <a href="mailto:[email protected]">Marek Posolda</a> | ||
*/ | ||
public class ClasspathTest { | ||
|
||
@Test | ||
public void testCorrectResteasyClient() throws Exception { | ||
Field clientField = Keycloak.class.getDeclaredField("client"); | ||
Class clientFieldClass = clientField.getType(); | ||
MatcherAssert.assertThat(getExpectedClientFieldClass(), equalTo(clientFieldClass.getName())); | ||
} | ||
|
||
@Test | ||
public void testResteasyVersion() throws Exception { | ||
Class resteasyClientSuperclass = ResteasyClient.class.getInterfaces()[0]; | ||
MatcherAssert.assertThat(getExpectedClientFieldClass(), equalTo(resteasyClientSuperclass.getName())); | ||
} | ||
|
||
protected String getExpectedClientFieldClass() { | ||
return "jakarta.ws.rs.client.Client"; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...dmin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/RealmsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.keycloak.client.testsuite.adminclient; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.keycloak.client.testsuite.TestConstants; | ||
import org.keycloak.representations.idm.RealmRepresentation; | ||
import org.testcontainers.shaded.org.hamcrest.MatcherAssert; | ||
import org.testcontainers.shaded.org.hamcrest.Matchers; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Marek Posolda</a> | ||
*/ | ||
public class RealmsTest extends AbstractAdminClientTest { | ||
|
||
@Test | ||
public void realmsList() { | ||
List<RealmRepresentation> realms = adminClient.realms().findAll(); | ||
MatcherAssert.assertThat(realms.stream() | ||
.map(RealmRepresentation::getRealm) | ||
.filter(realmName -> TestConstants.MASTER_REALM.equals(realmName)) | ||
.findFirst() | ||
.isPresent(), Matchers.is(true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-client-testsuite-parent</artifactId> | ||
<version>26.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>keycloak-client-testsuite-framework</artifactId> | ||
|
||
<!-- No dependencies on Keycloak artifacts here --> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.dasniko</groupId> | ||
<artifactId>testcontainers-keycloak</artifactId> | ||
<version>${testcontainers.keycloak.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-admin-client</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.keycloak</groupId> | ||
<artifactId>keycloak-admin-client</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<version>${quarkus.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Oops, something went wrong.