TestSuite PoC - Rename Test
prefix to Inject
(#31570)
* TestSuite PoC - Rename `Test` prefix to `Inject` Closes #31522 Signed-off-by: Jon Koops <jonkoops@gmail.com> * Rename test database annotation Signed-off-by: stianst <stianst@gmail.com> --------- Signed-off-by: Jon Koops <jonkoops@gmail.com> Signed-off-by: stianst <stianst@gmail.com> Co-authored-by: stianst <stianst@gmail.com>
This commit is contained in:
parent
eea1d10e23
commit
c92c642fec
23 changed files with 92 additions and 99 deletions
|
@ -6,7 +6,7 @@ import org.keycloak.admin.client.Keycloak;
|
|||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.representations.info.FeatureRepresentation;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestAdminClient;
|
||||
import org.keycloak.test.framework.annotations.InjectAdminClient;
|
||||
import org.keycloak.test.framework.server.KeycloakTestServerConfig;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -15,7 +15,7 @@ import java.util.Set;
|
|||
@KeycloakIntegrationTest(config = CustomConfigTest.CustomServerConfig.class)
|
||||
public class CustomConfigTest {
|
||||
|
||||
@TestAdminClient
|
||||
@InjectAdminClient
|
||||
Keycloak adminClient;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -5,14 +5,14 @@ import org.junit.jupiter.api.Test;
|
|||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestAdminClient;
|
||||
import org.keycloak.test.framework.annotations.InjectAdminClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@KeycloakIntegrationTest
|
||||
public class DefaultConfig1Test {
|
||||
|
||||
@TestAdminClient
|
||||
@InjectAdminClient
|
||||
Keycloak adminClient;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -5,14 +5,14 @@ import org.junit.jupiter.api.Test;
|
|||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestAdminClient;
|
||||
import org.keycloak.test.framework.annotations.InjectAdminClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@KeycloakIntegrationTest
|
||||
public class DefaultConfig2Test {
|
||||
|
||||
@TestAdminClient
|
||||
@InjectAdminClient
|
||||
Keycloak adminClient;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -6,24 +6,21 @@ import org.keycloak.admin.client.resource.ClientResource;
|
|||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.admin.client.resource.UserResource;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestClient;
|
||||
import org.keycloak.test.framework.annotations.TestRealm;
|
||||
import org.keycloak.test.framework.annotations.TestUser;
|
||||
import org.keycloak.test.framework.annotations.InjectClient;
|
||||
import org.keycloak.test.framework.annotations.InjectRealm;
|
||||
import org.keycloak.test.framework.annotations.InjectUser;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
import org.keycloak.test.framework.realm.DefaultClientConfig;
|
||||
import org.keycloak.test.framework.realm.DefaultRealmConfig;
|
||||
import org.keycloak.test.framework.realm.DefaultUserConfig;
|
||||
|
||||
@KeycloakIntegrationTest
|
||||
public class GlobalManagedResourcesTest {
|
||||
|
||||
@TestRealm(lifecycle = LifeCycle.GLOBAL)
|
||||
@InjectRealm(lifecycle = LifeCycle.GLOBAL)
|
||||
RealmResource realmResource;
|
||||
|
||||
@TestClient(lifecycle = LifeCycle.GLOBAL)
|
||||
@InjectClient(lifecycle = LifeCycle.GLOBAL)
|
||||
ClientResource clientResource;
|
||||
|
||||
@TestUser(lifecycle = LifeCycle.GLOBAL)
|
||||
@InjectUser(lifecycle = LifeCycle.GLOBAL)
|
||||
UserResource userResource;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -6,8 +6,8 @@ import org.keycloak.admin.client.resource.ClientResource;
|
|||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestClient;
|
||||
import org.keycloak.test.framework.annotations.TestRealm;
|
||||
import org.keycloak.test.framework.annotations.InjectClient;
|
||||
import org.keycloak.test.framework.annotations.InjectRealm;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -15,10 +15,10 @@ import java.util.List;
|
|||
@KeycloakIntegrationTest
|
||||
public class ManagedResources2Test {
|
||||
|
||||
@TestRealm(lifecycle = LifeCycle.CLASS)
|
||||
@InjectRealm(lifecycle = LifeCycle.CLASS)
|
||||
RealmResource realmResource;
|
||||
|
||||
@TestClient
|
||||
@InjectClient
|
||||
ClientResource clientResource;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -7,9 +7,9 @@ import org.keycloak.admin.client.resource.RealmResource;
|
|||
import org.keycloak.admin.client.resource.UserResource;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestClient;
|
||||
import org.keycloak.test.framework.annotations.TestRealm;
|
||||
import org.keycloak.test.framework.annotations.TestUser;
|
||||
import org.keycloak.test.framework.annotations.InjectClient;
|
||||
import org.keycloak.test.framework.annotations.InjectRealm;
|
||||
import org.keycloak.test.framework.annotations.InjectUser;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -17,13 +17,13 @@ import java.util.List;
|
|||
@KeycloakIntegrationTest
|
||||
public class ManagedResourcesTest {
|
||||
|
||||
@TestRealm(lifecycle = LifeCycle.CLASS)
|
||||
@InjectRealm(lifecycle = LifeCycle.CLASS)
|
||||
RealmResource realmResource;
|
||||
|
||||
@TestClient
|
||||
@InjectClient
|
||||
ClientResource clientResource;
|
||||
|
||||
@TestUser
|
||||
@InjectUser
|
||||
UserResource userResource;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -5,28 +5,27 @@ import org.junit.jupiter.api.Test;
|
|||
import org.keycloak.admin.client.resource.ClientResource;
|
||||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestClient;
|
||||
import org.keycloak.test.framework.annotations.TestRealm;
|
||||
import org.keycloak.test.framework.annotations.InjectClient;
|
||||
import org.keycloak.test.framework.annotations.InjectRealm;
|
||||
import org.keycloak.test.framework.realm.RealmConfig;
|
||||
|
||||
@KeycloakIntegrationTest
|
||||
public class MultipleInstancesTest {
|
||||
|
||||
@TestRealm
|
||||
@InjectRealm
|
||||
RealmResource realm1;
|
||||
|
||||
@TestRealm
|
||||
@InjectRealm
|
||||
RealmResource realm2;
|
||||
|
||||
@TestRealm(ref = "another", config = CustomRealmConfig.class)
|
||||
@InjectRealm(ref = "another", config = CustomRealmConfig.class)
|
||||
RealmResource realm3;
|
||||
|
||||
@TestClient(ref = "client1")
|
||||
@InjectClient(ref = "client1")
|
||||
ClientResource client;
|
||||
|
||||
@TestClient
|
||||
@InjectClient
|
||||
ClientResource client2;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,16 +3,16 @@ package org.keycloak.test.examples;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.page.LoginPage;
|
||||
import org.keycloak.test.framework.annotations.TestPage;
|
||||
import org.keycloak.test.framework.annotations.InjectPage;
|
||||
import org.keycloak.test.framework.page.WelcomePage;
|
||||
|
||||
@KeycloakIntegrationTest
|
||||
public class PagesTest {
|
||||
|
||||
@TestPage
|
||||
@InjectPage
|
||||
WelcomePage welcomePage;
|
||||
|
||||
@TestPage
|
||||
@InjectPage
|
||||
LoginPage loginPage;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -5,9 +5,9 @@ import org.junit.jupiter.api.Test;
|
|||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||
import org.keycloak.test.framework.annotations.TestAdminClient;
|
||||
import org.keycloak.test.framework.annotations.InjectAdminClient;
|
||||
import org.keycloak.test.framework.page.WelcomePage;
|
||||
import org.keycloak.test.framework.annotations.TestWebDriver;
|
||||
import org.keycloak.test.framework.annotations.InjectWebDriver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -15,10 +15,10 @@ import java.util.List;
|
|||
@KeycloakIntegrationTest
|
||||
public class WelcomePageTest {
|
||||
|
||||
@TestWebDriver
|
||||
@InjectWebDriver
|
||||
WebDriver driver;
|
||||
|
||||
@TestAdminClient
|
||||
@InjectAdminClient
|
||||
Keycloak adminClient;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.keycloak.test.framework.admin;
|
|||
import org.keycloak.OAuth2Constants;
|
||||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.admin.client.KeycloakBuilder;
|
||||
import org.keycloak.test.framework.annotations.TestAdminClient;
|
||||
import org.keycloak.test.framework.annotations.InjectAdminClient;
|
||||
import org.keycloak.test.framework.config.Config;
|
||||
import org.keycloak.test.framework.injection.InstanceContext;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
|
@ -11,11 +11,11 @@ import org.keycloak.test.framework.injection.RequestedInstance;
|
|||
import org.keycloak.test.framework.injection.Supplier;
|
||||
import org.keycloak.test.framework.server.KeycloakTestServer;
|
||||
|
||||
public class KeycloakAdminClientSupplier implements Supplier<Keycloak, TestAdminClient> {
|
||||
public class KeycloakAdminClientSupplier implements Supplier<Keycloak, InjectAdminClient> {
|
||||
|
||||
@Override
|
||||
public Class<TestAdminClient> getAnnotationClass() {
|
||||
return TestAdminClient.class;
|
||||
public Class<InjectAdminClient> getAnnotationClass() {
|
||||
return InjectAdminClient.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,7 @@ public class KeycloakAdminClientSupplier implements Supplier<Keycloak, TestAdmin
|
|||
}
|
||||
|
||||
@Override
|
||||
public Keycloak getValue(InstanceContext<Keycloak, TestAdminClient> instanceContext) {
|
||||
public Keycloak getValue(InstanceContext<Keycloak, InjectAdminClient> instanceContext) {
|
||||
KeycloakTestServer testServer = instanceContext.getDependency(KeycloakTestServer.class);
|
||||
return KeycloakBuilder.builder()
|
||||
.serverUrl(testServer.getBaseUrl())
|
||||
|
@ -41,12 +41,12 @@ public class KeycloakAdminClientSupplier implements Supplier<Keycloak, TestAdmin
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean compatible(InstanceContext<Keycloak, TestAdminClient> a, RequestedInstance<Keycloak, TestAdminClient> b) {
|
||||
public boolean compatible(InstanceContext<Keycloak, InjectAdminClient> a, RequestedInstance<Keycloak, InjectAdminClient> b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(InstanceContext<Keycloak, TestAdminClient> instanceContext) {
|
||||
public void close(InstanceContext<Keycloak, InjectAdminClient> instanceContext) {
|
||||
instanceContext.getValue().close();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,6 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface TestAdminClient {
|
||||
public @interface InjectAdminClient {
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface TestClient {
|
||||
public @interface InjectClient {
|
||||
|
||||
Class<? extends ClientConfig> config() default DefaultClientConfig.class;
|
||||
|
|
@ -7,5 +7,5 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface TestPage {
|
||||
public @interface InjectPage {
|
||||
}
|
|
@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface TestRealm {
|
||||
public @interface InjectRealm {
|
||||
|
||||
Class<? extends RealmConfig> config() default DefaultRealmConfig.class;
|
||||
|
|
@ -10,7 +10,7 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface KeycloakTestDatabase {
|
||||
public @interface InjectTestDatabase {
|
||||
|
||||
Class<? extends DatabaseConfig> config() default DatabaseConfig.class;
|
||||
|
|
@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface TestUser {
|
||||
public @interface InjectUser {
|
||||
|
||||
Class<? extends UserConfig> config() default DefaultUserConfig.class;
|
||||
|
|
@ -7,4 +7,4 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface TestWebDriver { }
|
||||
public @interface InjectWebDriver { }
|
|
@ -1,19 +1,19 @@
|
|||
package org.keycloak.test.framework.database;
|
||||
|
||||
import org.keycloak.test.framework.annotations.KeycloakTestDatabase;
|
||||
import org.keycloak.test.framework.annotations.InjectTestDatabase;
|
||||
import org.keycloak.test.framework.injection.InstanceContext;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
import org.keycloak.test.framework.injection.RequestedInstance;
|
||||
import org.keycloak.test.framework.injection.Supplier;
|
||||
|
||||
public abstract class AbstractDatabaseSupplier implements Supplier<TestDatabase, KeycloakTestDatabase> {
|
||||
public abstract class AbstractDatabaseSupplier implements Supplier<TestDatabase, InjectTestDatabase> {
|
||||
|
||||
protected static final String DEFAULT_DB_USERNAME = "keycloak";
|
||||
protected static final String DEFAULT_DB_PASSWORD = "Password1!";
|
||||
|
||||
@Override
|
||||
public Class<KeycloakTestDatabase> getAnnotationClass() {
|
||||
return KeycloakTestDatabase.class;
|
||||
public Class<InjectTestDatabase> getAnnotationClass() {
|
||||
return InjectTestDatabase.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,14 +22,14 @@ public abstract class AbstractDatabaseSupplier implements Supplier<TestDatabase,
|
|||
}
|
||||
|
||||
@Override
|
||||
public TestDatabase getValue(InstanceContext<TestDatabase, KeycloakTestDatabase> instanceContext) {
|
||||
public TestDatabase getValue(InstanceContext<TestDatabase, InjectTestDatabase> instanceContext) {
|
||||
TestDatabase testDatabase = getTestDatabase();
|
||||
testDatabase.start();
|
||||
return testDatabase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compatible(InstanceContext<TestDatabase, KeycloakTestDatabase> a, RequestedInstance<TestDatabase, KeycloakTestDatabase> b) {
|
||||
public boolean compatible(InstanceContext<TestDatabase, InjectTestDatabase> a, RequestedInstance<TestDatabase, InjectTestDatabase> b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public abstract class AbstractDatabaseSupplier implements Supplier<TestDatabase,
|
|||
abstract TestDatabase getTestDatabase();
|
||||
|
||||
@Override
|
||||
public void close(InstanceContext<TestDatabase, KeycloakTestDatabase> instanceContext) {
|
||||
public void close(InstanceContext<TestDatabase, InjectTestDatabase> instanceContext) {
|
||||
instanceContext.getValue().stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.keycloak.test.framework.page;
|
||||
|
||||
import org.keycloak.test.framework.annotations.TestPage;
|
||||
import org.keycloak.test.framework.annotations.InjectPage;
|
||||
import org.keycloak.test.framework.injection.InstanceContext;
|
||||
import org.keycloak.test.framework.injection.RequestedInstance;
|
||||
import org.keycloak.test.framework.injection.Supplier;
|
||||
|
@ -8,11 +8,11 @@ import org.openqa.selenium.WebDriver;
|
|||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class PageSupplier implements Supplier<AbstractPage, TestPage> {
|
||||
public class PageSupplier implements Supplier<AbstractPage, InjectPage> {
|
||||
|
||||
@Override
|
||||
public Class<TestPage> getAnnotationClass() {
|
||||
return TestPage.class;
|
||||
public Class<InjectPage> getAnnotationClass() {
|
||||
return InjectPage.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,13 +21,13 @@ public class PageSupplier implements Supplier<AbstractPage, TestPage> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractPage getValue(InstanceContext<AbstractPage, TestPage> instanceContext) {
|
||||
public AbstractPage getValue(InstanceContext<AbstractPage, InjectPage> instanceContext) {
|
||||
WebDriver webDriver = instanceContext.getDependency(WebDriver.class);
|
||||
return createPage(webDriver, instanceContext.getRequestedValueType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compatible(InstanceContext<AbstractPage, TestPage> a, RequestedInstance<AbstractPage, TestPage> b) {
|
||||
public boolean compatible(InstanceContext<AbstractPage, InjectPage> a, RequestedInstance<AbstractPage, InjectPage> b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,20 +4,19 @@ import jakarta.ws.rs.core.Response;
|
|||
import org.keycloak.admin.client.resource.ClientResource;
|
||||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.test.framework.annotations.TestClient;
|
||||
import org.keycloak.test.framework.annotations.InjectClient;
|
||||
import org.keycloak.test.framework.injection.InstanceContext;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
import org.keycloak.test.framework.injection.RequestedInstance;
|
||||
import org.keycloak.test.framework.injection.Supplier;
|
||||
import org.keycloak.test.framework.injection.SupplierHelpers;
|
||||
|
||||
public class ClientSupplier implements Supplier<ClientResource, TestClient> {
|
||||
public class ClientSupplier implements Supplier<ClientResource, InjectClient> {
|
||||
|
||||
private static final String CLIENT_UUID_KEY = "clientUuid";
|
||||
|
||||
@Override
|
||||
public Class<TestClient> getAnnotationClass() {
|
||||
return TestClient.class;
|
||||
public Class<InjectClient> getAnnotationClass() {
|
||||
return InjectClient.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +25,7 @@ public class ClientSupplier implements Supplier<ClientResource, TestClient> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClientResource getValue(InstanceContext<ClientResource, TestClient> instanceContext) {
|
||||
public ClientResource getValue(InstanceContext<ClientResource, InjectClient> instanceContext) {
|
||||
RealmResource realm = instanceContext.getDependency(RealmResource.class);
|
||||
|
||||
ClientConfig config = SupplierHelpers.getInstance(instanceContext.getAnnotation().config());
|
||||
|
@ -50,12 +49,12 @@ public class ClientSupplier implements Supplier<ClientResource, TestClient> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean compatible(InstanceContext<ClientResource, TestClient> a, RequestedInstance<ClientResource, TestClient> b) {
|
||||
public boolean compatible(InstanceContext<ClientResource, InjectClient> a, RequestedInstance<ClientResource, InjectClient> b) {
|
||||
return a.getAnnotation().config().equals(b.getAnnotation().config());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(InstanceContext<ClientResource, TestClient> instanceContext) {
|
||||
public void close(InstanceContext<ClientResource, InjectClient> instanceContext) {
|
||||
instanceContext.getValue().remove();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,20 +3,19 @@ package org.keycloak.test.framework.realm;
|
|||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.test.framework.annotations.TestRealm;
|
||||
import org.keycloak.test.framework.annotations.InjectRealm;
|
||||
import org.keycloak.test.framework.injection.InstanceContext;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
import org.keycloak.test.framework.injection.RequestedInstance;
|
||||
import org.keycloak.test.framework.injection.Supplier;
|
||||
import org.keycloak.test.framework.injection.SupplierHelpers;
|
||||
|
||||
public class RealmSupplier implements Supplier<RealmResource, TestRealm> {
|
||||
public class RealmSupplier implements Supplier<RealmResource, InjectRealm> {
|
||||
|
||||
private static final String REALM_NAME_KEY = "realmName";
|
||||
|
||||
@Override
|
||||
public Class<TestRealm> getAnnotationClass() {
|
||||
return TestRealm.class;
|
||||
public Class<InjectRealm> getAnnotationClass() {
|
||||
return InjectRealm.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +24,7 @@ public class RealmSupplier implements Supplier<RealmResource, TestRealm> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RealmResource getValue(InstanceContext<RealmResource, TestRealm> instanceContext) {
|
||||
public RealmResource getValue(InstanceContext<RealmResource, InjectRealm> instanceContext) {
|
||||
Keycloak adminClient = instanceContext.getDependency(Keycloak.class);
|
||||
|
||||
RealmConfig config = SupplierHelpers.getInstance(instanceContext.getAnnotation().config());
|
||||
|
@ -48,12 +47,12 @@ public class RealmSupplier implements Supplier<RealmResource, TestRealm> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean compatible(InstanceContext<RealmResource, TestRealm> a, RequestedInstance<RealmResource, TestRealm> b) {
|
||||
public boolean compatible(InstanceContext<RealmResource, InjectRealm> a, RequestedInstance<RealmResource, InjectRealm> b) {
|
||||
return a.getAnnotation().config().equals(b.getAnnotation().config());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(InstanceContext<RealmResource, TestRealm> instanceContext) {
|
||||
public void close(InstanceContext<RealmResource, InjectRealm> instanceContext) {
|
||||
instanceContext.getValue().remove();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,20 +4,19 @@ import jakarta.ws.rs.core.Response;
|
|||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.admin.client.resource.UserResource;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.test.framework.annotations.TestUser;
|
||||
import org.keycloak.test.framework.annotations.InjectUser;
|
||||
import org.keycloak.test.framework.injection.InstanceContext;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
import org.keycloak.test.framework.injection.RequestedInstance;
|
||||
import org.keycloak.test.framework.injection.Supplier;
|
||||
import org.keycloak.test.framework.injection.SupplierHelpers;
|
||||
|
||||
public class UserSupplier implements Supplier<UserResource, TestUser> {
|
||||
public class UserSupplier implements Supplier<UserResource, InjectUser> {
|
||||
|
||||
private static final String USER_UUID_KEY = "userUuid";
|
||||
|
||||
@Override
|
||||
public Class<TestUser> getAnnotationClass() {
|
||||
return TestUser.class;
|
||||
public Class<InjectUser> getAnnotationClass() {
|
||||
return InjectUser.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +25,7 @@ public class UserSupplier implements Supplier<UserResource, TestUser> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserResource getValue(InstanceContext<UserResource, TestUser> instanceContext) {
|
||||
public UserResource getValue(InstanceContext<UserResource, InjectUser> instanceContext) {
|
||||
RealmResource realm = instanceContext.getDependency(RealmResource.class);
|
||||
|
||||
UserConfig config = SupplierHelpers.getInstance(instanceContext.getAnnotation().config());
|
||||
|
@ -50,12 +49,12 @@ public class UserSupplier implements Supplier<UserResource, TestUser> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean compatible(InstanceContext<UserResource, TestUser> a, RequestedInstance<UserResource, TestUser> b) {
|
||||
public boolean compatible(InstanceContext<UserResource, InjectUser> a, RequestedInstance<UserResource, InjectUser> b) {
|
||||
return a.getAnnotation().config().equals(b.getAnnotation().config());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(InstanceContext<UserResource, TestUser> instanceContext) {
|
||||
public void close(InstanceContext<UserResource, InjectUser> instanceContext) {
|
||||
instanceContext.getValue().remove();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.keycloak.test.framework.webdriver;
|
||||
|
||||
import org.keycloak.test.framework.annotations.TestWebDriver;
|
||||
import org.keycloak.test.framework.annotations.InjectWebDriver;
|
||||
import org.keycloak.test.framework.injection.InstanceContext;
|
||||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
import org.keycloak.test.framework.injection.RequestedInstance;
|
||||
|
@ -11,11 +11,11 @@ import org.openqa.selenium.remote.AbstractDriverOptions;
|
|||
|
||||
import java.time.Duration;
|
||||
|
||||
public abstract class AbstractWebDriverSupplier implements Supplier<WebDriver, TestWebDriver> {
|
||||
public abstract class AbstractWebDriverSupplier implements Supplier<WebDriver, InjectWebDriver> {
|
||||
|
||||
@Override
|
||||
public Class<TestWebDriver> getAnnotationClass() {
|
||||
return TestWebDriver.class;
|
||||
public Class<InjectWebDriver> getAnnotationClass() {
|
||||
return InjectWebDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,22 +24,22 @@ public abstract class AbstractWebDriverSupplier implements Supplier<WebDriver, T
|
|||
}
|
||||
|
||||
@Override
|
||||
public WebDriver getValue(InstanceContext<WebDriver, TestWebDriver> instanceContext) {
|
||||
public WebDriver getValue(InstanceContext<WebDriver, InjectWebDriver> instanceContext) {
|
||||
return getWebDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compatible(InstanceContext<WebDriver, TestWebDriver> a, RequestedInstance<WebDriver, TestWebDriver> b) {
|
||||
public boolean compatible(InstanceContext<WebDriver, InjectWebDriver> a, RequestedInstance<WebDriver, InjectWebDriver> b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LifeCycle getLifeCycle(TestWebDriver annotation) {
|
||||
public LifeCycle getLifeCycle(InjectWebDriver annotation) {
|
||||
return LifeCycle.GLOBAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(InstanceContext<WebDriver, TestWebDriver> instanceContext) {
|
||||
public void close(InstanceContext<WebDriver, InjectWebDriver> instanceContext) {
|
||||
instanceContext.getValue().quit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue