diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientAttributeCertificateResource.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientAttributeCertificateResource.java index 5ede9fed90..9f78aa8313 100644 --- a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientAttributeCertificateResource.java +++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientAttributeCertificateResource.java @@ -27,6 +27,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput; import org.keycloak.representations.KeyStoreConfig; import org.keycloak.representations.idm.CertificateRepresentation; @@ -67,7 +68,7 @@ public interface ClientAttributeCertificateResource { @Path("upload") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) - public CertificateRepresentation uploadJks(MultipartFormDataInput input); + public CertificateRepresentation uploadJks(MultipartFormDataOutput input); /** * Upload only certificate, not private key @@ -79,7 +80,7 @@ public interface ClientAttributeCertificateResource { @Path("upload-certificate") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) - public CertificateRepresentation uploadJksCertificate(MultipartFormDataInput input); + public CertificateRepresentation uploadJksCertificate(MultipartFormDataOutput input); /** * Get a keystore file for the client, containing private key and public certificate diff --git a/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java index a6019304ee..4974a6b87c 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/IdentityProvidersResource.java @@ -20,7 +20,6 @@ package org.keycloak.services.resources.admin; import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; -import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.broker.provider.IdentityProvider; import org.keycloak.broker.provider.IdentityProviderFactory; @@ -37,6 +36,7 @@ import org.keycloak.representations.idm.IdentityProviderRepresentation; import org.keycloak.services.ErrorResponse; import org.keycloak.broker.social.SocialIdentityProvider; +import javax.ws.rs.BadRequestException; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -108,6 +108,9 @@ public class IdentityProvidersResource { public Map importFrom(@Context UriInfo uriInfo, MultipartFormDataInput input) throws IOException { this.auth.requireManage(); Map> formDataMap = input.getFormDataMap(); + if (!(formDataMap.containsKey("providerId") && formDataMap.containsKey("file"))) { + throw new BadRequestException(); + } String providerId = formDataMap.get("providerId").get(0).getBodyAsString(); InputPart file = formDataMap.get("file").get(0); InputStream inputStream = file.getBody(InputStream.class, null); @@ -130,7 +133,9 @@ public class IdentityProvidersResource { @Produces(MediaType.APPLICATION_JSON) public Map importFrom(@Context UriInfo uriInfo, Map data) throws IOException { this.auth.requireManage(); - + if (!(data.containsKey("providerId") && data.containsKey("fromUrl"))) { + throw new BadRequestException(); + } String providerId = data.get("providerId").toString(); String from = data.get("fromUrl").toString(); InputStream inputStream = session.getProvider(HttpClientProvider.class).get(from); diff --git a/testsuite/integration-arquillian/pom.xml b/testsuite/integration-arquillian/pom.xml index 882eab4cc1..5266731c2f 100644 --- a/testsuite/integration-arquillian/pom.xml +++ b/testsuite/integration-arquillian/pom.xml @@ -100,14 +100,6 @@ xml-maven-plugin 1.0.1 - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/PermissionsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/PermissionsTest.java index 3b5d1ce814..98bf9e6dea 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/PermissionsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/PermissionsTest.java @@ -17,6 +17,7 @@ package org.keycloak.testsuite.admin; +import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput; import org.junit.Rule; import org.junit.Test; import org.keycloak.admin.client.Keycloak; @@ -32,6 +33,7 @@ import org.keycloak.representations.idm.ClientInitialAccessCreatePresentation; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.ClientTemplateRepresentation; import org.keycloak.representations.idm.GroupRepresentation; +import org.keycloak.representations.idm.IdentityProviderMapperRepresentation; import org.keycloak.representations.idm.IdentityProviderRepresentation; import org.keycloak.representations.idm.PartialImportRepresentation; import org.keycloak.representations.idm.ProtocolMapperRepresentation; @@ -76,19 +78,24 @@ public class PermissionsTest extends AbstractKeycloakTest { private Map clients = new HashMap<>(); - @Rule - public GreenMailRule greenMailRule = new GreenMailRule(); + @Rule public GreenMailRule greenMailRule = new GreenMailRule(); @Override public void addTestRealms(List testRealms) { RealmBuilder builder = RealmBuilder.create().name(REALM_NAME).testMail(); builder.client(ClientBuilder.create().clientId("test-client").publicClient().directAccessGrants()); - builder.user(UserBuilder.create().username(AdminRoles.REALM_ADMIN).role(Constants.REALM_MANAGEMENT_CLIENT_ID, AdminRoles.REALM_ADMIN).addPassword("password")); - clients.put(AdminRoles.REALM_ADMIN, Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", REALM_NAME, AdminRoles.REALM_ADMIN, "password", "test-client", "secret")); + builder.user(UserBuilder.create() + .username(AdminRoles.REALM_ADMIN) + .role(Constants.REALM_MANAGEMENT_CLIENT_ID, AdminRoles.REALM_ADMIN) + .addPassword("password")); + clients.put(AdminRoles.REALM_ADMIN, + Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", REALM_NAME, AdminRoles.REALM_ADMIN, "password", "test-client", + "secret")); builder.user(UserBuilder.create().username("none").addPassword("password")); - clients.put("none", Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", REALM_NAME, "none", "password", "test-client", "secret")); + clients.put("none", + Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", REALM_NAME, "none", "password", "test-client", "secret")); for (String role : AdminRoles.ALL_REALM_ROLES) { builder.user(UserBuilder.create().username(role).role(Constants.REALM_MANAGEMENT_CLIENT_ID, role).addPassword("password")); @@ -119,7 +126,9 @@ public class PermissionsTest extends AbstractKeycloakTest { master.users().get(userId).resetPassword(CredentialBuilder.create().password("password").build()); - clients.put("master-none", Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", "master", "permissions-test-master-none", "password", Constants.ADMIN_CLI_CLIENT_ID)); + clients.put("master-none", + Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", "master", "permissions-test-master-none", "password", + Constants.ADMIN_CLI_CLIENT_ID)); } for (String role : AdminRoles.ALL_REALM_ROLES) { @@ -132,7 +141,9 @@ public class PermissionsTest extends AbstractKeycloakTest { RoleRepresentation roleRep = master.clients().get(clientId).roles().get(role).toRepresentation(); master.users().get(userId).roles().clientLevel(clientId).add(Collections.singletonList(roleRep)); - clients.put("master-" + role, Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", "master", "permissions-test-master-" + role, "password", Constants.ADMIN_CLI_CLIENT_ID)); + clients.put("master-" + role, + Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth", "master", "permissions-test-master-" + role, "password", + Constants.ADMIN_CLI_CLIENT_ID)); } } @@ -148,8 +159,16 @@ public class PermissionsTest extends AbstractKeycloakTest { @Test public void realms() { // Check returned realms - invoke((realm) -> { clients.get("master-none").realms().findAll(); }, clients.get("none"), false); - invoke((realm) -> { clients.get("none").realms().findAll(); }, clients.get("none"), false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get("master-none").realms().findAll(); + } + }, clients.get("none"), false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get("none").realms().findAll(); + } + }, clients.get("none"), false); Assert.assertNames(clients.get("master-admin").realms().findAll(), "master", REALM_NAME, "realm2"); Assert.assertNames(clients.get(AdminRoles.REALM_ADMIN).realms().findAll(), REALM_NAME); Assert.assertNames(clients.get("REALM2").realms().findAll(), "realm2"); @@ -164,322 +183,1277 @@ public class PermissionsTest extends AbstractKeycloakTest { assertNotNull(realms.get(0).getAccessTokenLifespan()); // Create realm - invoke((realm) -> { clients.get("master-admin").realms().create(RealmBuilder.create().name("master").build()); }, adminClient, true); - invoke((realm) -> { clients.get("master-" + AdminRoles.MANAGE_USERS).realms().create(RealmBuilder.create().name("master").build()); }, adminClient, false); - invoke((realm) -> { clients.get(AdminRoles.REALM_ADMIN).realms().create(RealmBuilder.create().name("master").build()); }, adminClient, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get("master-admin").realms().create(RealmBuilder.create().name("master").build()); + } + }, adminClient, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get("master-" + AdminRoles.MANAGE_USERS).realms().create(RealmBuilder.create().name("master").build()); + } + }, adminClient, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get(AdminRoles.REALM_ADMIN).realms().create(RealmBuilder.create().name("master").build()); + } + }, adminClient, false); // Get realm - invoke((realm) -> { realm.toRepresentation(); }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.toRepresentation(); + } + }, Resource.REALM, false, true); assertGettersEmpty(clients.get(AdminRoles.VIEW_USERS).realm(REALM_NAME).toRepresentation()); - invoke((realm) -> { realm.update(new RealmRepresentation()); }, Resource.REALM, true); - invoke((realm) -> { realm.pushRevocation(); }, Resource.REALM, true); - invoke((realm) -> { realm.deleteSession("nosuch"); }, Resource.USER, true); - invoke((realm) -> { realm.getClientSessionStats(); }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.update(new RealmRepresentation()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.pushRevocation(); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.deleteSession("nosuch"); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.getClientSessionStats(); + } + }, Resource.REALM, false); - invoke((realm) -> { realm.getDefaultGroups(); }, Resource.REALM, false); - invoke((realm) -> { realm.addDefaultGroup("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.removeDefaultGroup("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.getGroupByPath("nosuch"); }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.getDefaultGroups(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.addDefaultGroup("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.removeDefaultGroup("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.getGroupByPath("nosuch"); + } + }, Resource.REALM, false); - invoke((realm, response) -> { response.set(realm.testLDAPConnection("nosuch", "nosuch", "nosuch", "nosuch", "nosuch")); }, Resource.REALM, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.testLDAPConnection("nosuch", "nosuch", "nosuch", "nosuch", "nosuch")); + } + }, Resource.REALM, true); - invoke((realm, response) -> { response.set(realm.partialImport(new PartialImportRepresentation())); }, Resource.REALM, true); - invoke((realm) -> { realm.clearRealmCache(); }, Resource.REALM, true); - invoke((realm) -> { realm.clearUserCache(); }, Resource.REALM, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.partialImport(new PartialImportRepresentation())); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clearRealmCache(); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clearUserCache(); + } + }, Resource.REALM, true); // Delete realm - invoke((realm) -> { clients.get("master-admin").realms().realm("nosuch").remove(); }, adminClient, true); - invoke((realm) -> { clients.get("REALM2").realms().realm(REALM_NAME).remove(); }, adminClient, false); - invoke((realm) -> { clients.get(AdminRoles.MANAGE_USERS).realms().realm(REALM_NAME).remove(); }, adminClient, false); - invoke((realm) -> { clients.get(AdminRoles.REALM_ADMIN).realms().realm(REALM_NAME).remove(); }, adminClient, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get("master-admin").realms().realm("nosuch").remove(); + } + }, adminClient, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get("REALM2").realms().realm(REALM_NAME).remove(); + } + }, adminClient, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get(AdminRoles.MANAGE_USERS).realms().realm(REALM_NAME).remove(); + } + }, adminClient, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + clients.get(AdminRoles.REALM_ADMIN).realms().realm(REALM_NAME).remove(); + } + }, adminClient, true); + } - // TODO - // invoke((realm) -> { realm.logoutAll(); }, Resource.USER, true); + @Test + public void realmLogoutAll() { + Invocation invocation = new Invocation() { + public void invoke(RealmResource realm) { + realm.logoutAll(); + } + }; + + invoke(invocation, clients.get("master-none"), false); + invoke(invocation, clients.get("master-view-realm"), false); + + invoke(invocation, clients.get("REALM2"), false); + + invoke(invocation, clients.get("none"), false); + invoke(invocation, clients.get("view-users"), false); + invoke(invocation, clients.get("manage-realm"), false); + invoke(invocation, clients.get("master-manage-realm"), false); + + invoke(invocation, clients.get("manage-users"), true); + invoke(invocation, clients.get("master-manage-users"), true); } @Test public void events() { - invoke((realm) -> { realm.getRealmEventsConfig(); }, Resource.EVENTS, false); - invoke((realm) -> { realm.updateRealmEventsConfig(new RealmEventsConfigRepresentation()); }, Resource.EVENTS, true); - invoke((realm) -> { realm.getEvents(); }, Resource.EVENTS, false); - invoke((realm) -> { realm.getAdminEvents(); }, Resource.EVENTS, false); - invoke((realm) -> { realm.clearEvents(); }, Resource.EVENTS, true); - invoke((realm) -> { realm.clearAdminEvents(); }, Resource.EVENTS, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.getRealmEventsConfig(); + } + }, Resource.EVENTS, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.updateRealmEventsConfig(new RealmEventsConfigRepresentation()); + } + }, Resource.EVENTS, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.getEvents(); + } + }, Resource.EVENTS, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.getAdminEvents(); + } + }, Resource.EVENTS, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clearEvents(); + } + }, Resource.EVENTS, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clearAdminEvents(); + } + }, Resource.EVENTS, true); } @Test public void attackDetection() { - invoke((realm) -> { realm.attackDetection().bruteForceUserStatus("nosuch"); }, Resource.USER, false); - invoke((realm) -> { realm.attackDetection().clearBruteForceForUser("nosuch"); }, Resource.USER, true); - invoke((realm) -> { realm.attackDetection().clearAllBruteForce(); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.attackDetection().bruteForceUserStatus("nosuch"); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.attackDetection().clearBruteForceForUser("nosuch"); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.attackDetection().clearAllBruteForce(); + } + }, Resource.USER, true); } @Test public void clients() { - invoke((realm) -> { realm.clients().findAll(); }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().findAll(); + } + }, Resource.CLIENT, false, true); List l = clients.get(AdminRoles.VIEW_USERS).realm(REALM_NAME).clients().findAll(); assertGettersEmpty(l.get(0)); - invoke((realm) -> { realm.convertClientDescription("blahblah"); }, Resource.CLIENT, true); - invoke((realm, response) -> { response.set(realm.clients().create(ClientBuilder.create().clientId("foo").build())); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").toRepresentation(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getInstallationProvider("nosuch"); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").update(new ClientRepresentation()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").remove(); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").generateNewSecret(); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").regenerateRegistrationAccessToken(); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getSecret(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getServiceAccountUser(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").pushRevocation(); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getApplicationSessionCount(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getUserSessions(0, 100); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getOfflineSessionCount(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getOfflineUserSessions(0, 100); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").registerNode(new HashMap<>()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").unregisterNode("nosuch"); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").testNodesAvailable(); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.convertClientDescription("blahblah"); + } + }, Resource.CLIENT, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.clients().create(ClientBuilder.create().clientId("foo").build())); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").toRepresentation(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getInstallationProvider("nosuch"); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").update(new ClientRepresentation()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").remove(); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").generateNewSecret(); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").regenerateRegistrationAccessToken(); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getSecret(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getServiceAccountUser(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").pushRevocation(); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getApplicationSessionCount(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getUserSessions(0, 100); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getOfflineSessionCount(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getOfflineUserSessions(0, 100); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").registerNode(Collections.emptyMap()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").unregisterNode("nosuch"); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").testNodesAvailable(); + } + }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getCertficateResource("nosuch").generate(); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getCertficateResource("nosuch").generateAndGetKeystore(new KeyStoreConfig()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getCertficateResource("nosuch").getKeyInfo(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getCertficateResource("nosuch").getKeystore(new KeyStoreConfig()); }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getCertficateResource("nosuch").generate(); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getCertficateResource("nosuch").generateAndGetKeystore(new KeyStoreConfig()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getCertficateResource("nosuch").getKeyInfo(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getCertficateResource("nosuch").getKeystore(new KeyStoreConfig()); + } + }, Resource.CLIENT, false); - // TODO - // invoke((realm) -> { realm.clients().get("nosuch").getCertficateResource("nosuch").uploadJks(null); }, Resource.CLIENT, true); - // invoke((realm) -> { realm.clients().get("nosuch").getCertficateResource("nosuch").uploadJksCertificate(null); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getCertficateResource("nosuch").uploadJks(new MultipartFormDataOutput()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getCertficateResource("nosuch").uploadJksCertificate(new MultipartFormDataOutput()); + } + }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getProtocolMappers().createMapper(Collections.EMPTY_LIST); }, Resource.CLIENT, true); - invoke((realm, response) -> { response.set(realm.clients().get("nosuch").getProtocolMappers().createMapper(new ProtocolMapperRepresentation())); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getProtocolMappers().getMapperById("nosuch"); }, Resource.CLIENT, false, true); - invoke((realm) -> { realm.clients().get("nosuch").getProtocolMappers().getMappers(); }, Resource.CLIENT, false, true); - invoke((realm) -> { realm.clients().get("nosuch").getProtocolMappers().getMappersPerProtocol("nosuch"); }, Resource.CLIENT, false, true); - invoke((realm) -> { realm.clients().get("nosuch").getProtocolMappers().update("nosuch", new ProtocolMapperRepresentation()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getProtocolMappers().delete("nosuch"); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getProtocolMappers().createMapper(Collections.EMPTY_LIST); + } + }, Resource.CLIENT, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.clients().get("nosuch").getProtocolMappers().createMapper(new ProtocolMapperRepresentation())); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getProtocolMappers().getMapperById("nosuch"); + } + }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getProtocolMappers().getMappers(); + } + }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getProtocolMappers().getMappersPerProtocol("nosuch"); + } + }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getProtocolMappers().update("nosuch", new ProtocolMapperRepresentation()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getProtocolMappers().delete("nosuch"); + } + }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getScopeMappings().getAll(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getScopeMappings().realmLevel().listAll(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getScopeMappings().realmLevel().listEffective(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getScopeMappings().realmLevel().listAvailable(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").getScopeMappings().realmLevel().add(Collections.emptyList()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").getScopeMappings().realmLevel().remove(Collections.emptyList()); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getScopeMappings().getAll(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getScopeMappings().realmLevel().listAll(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getScopeMappings().realmLevel().listEffective(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getScopeMappings().realmLevel().listAvailable(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getScopeMappings().realmLevel().add(Collections.emptyList()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").getScopeMappings().realmLevel().remove(Collections.emptyList()); + } + }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").roles().list(); }, Resource.CLIENT, false, true); - invoke((realm) -> { realm.clients().get("nosuch").roles().create(new RoleRepresentation()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").roles().get("nosuch").toRepresentation(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").roles().deleteRole("nosuch"); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").roles().get("nosuch").update(new RoleRepresentation()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").roles().get("nosuch").addComposites(Collections.emptyList()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").roles().get("nosuch").deleteComposites(Collections.emptyList()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clients().get("nosuch").roles().get("nosuch").getRoleComposites(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").roles().get("nosuch").getRealmRoleComposites(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clients().get("nosuch").roles().get("nosuch").getClientRoleComposites("nosuch"); }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().list(); + } + }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().create(new RoleRepresentation()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().get("nosuch").toRepresentation(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().deleteRole("nosuch"); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().get("nosuch").update(new RoleRepresentation()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().get("nosuch").addComposites(Collections.emptyList()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().get("nosuch").deleteComposites(Collections.emptyList()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().get("nosuch").getRoleComposites(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().get("nosuch").getRealmRoleComposites(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clients().get("nosuch").roles().get("nosuch").getClientRoleComposites("nosuch"); + } + }, Resource.CLIENT, false); } @Test public void clientTemplates() { - invoke((realm) -> { realm.clientTemplates().findAll(); }, Resource.CLIENT, false); - invoke((realm, response) -> { response.set(realm.clientTemplates().create(new ClientTemplateRepresentation())); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").toRepresentation(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").update(new ClientTemplateRepresentation()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").remove(); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().findAll(); + } + }, Resource.CLIENT, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.clientTemplates().create(new ClientTemplateRepresentation())); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").toRepresentation(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").update(new ClientTemplateRepresentation()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").remove(); + } + }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getProtocolMappers().getMappers(); }, Resource.CLIENT, false, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getProtocolMappers().getMappersPerProtocol("nosuch"); }, Resource.CLIENT, false, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getProtocolMappers().getMapperById("nosuch"); }, Resource.CLIENT, false, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getProtocolMappers().update("nosuch", new ProtocolMapperRepresentation()); }, Resource.CLIENT, true); - invoke((realm, response) -> { response.set(realm.clientTemplates().get("nosuch").getProtocolMappers().createMapper(new ProtocolMapperRepresentation())); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getProtocolMappers().createMapper(Collections.emptyList()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getProtocolMappers().delete("nosuch"); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getProtocolMappers().getMappers(); + } + }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getProtocolMappers().getMappersPerProtocol("nosuch"); + } + }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getProtocolMappers().getMapperById("nosuch"); + } + }, Resource.CLIENT, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getProtocolMappers().update("nosuch", new ProtocolMapperRepresentation()); + } + }, Resource.CLIENT, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.clientTemplates().get("nosuch").getProtocolMappers().createMapper(new ProtocolMapperRepresentation())); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getProtocolMappers().createMapper(Collections.emptyList()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getProtocolMappers().delete("nosuch"); + } + }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().getAll(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().listAll(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().listAvailable(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().listEffective(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().add(Collections.emptyList()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().remove(Collections.emptyList()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").listAll(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").listAvailable(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").listEffective(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").add(Collections.emptyList()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").remove(Collections.emptyList()); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().getAll(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().listAll(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().listAvailable(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().listEffective(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().add(Collections.emptyList()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().realmLevel().remove(Collections.emptyList()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").listAll(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").listAvailable(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").listEffective(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").add(Collections.emptyList()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientTemplates().get("nosuch").getScopeMappings().clientLevel("nosuch").remove(Collections.emptyList()); + } + }, Resource.CLIENT, true); } @Test public void clientInitialAccess() { - invoke((realm) -> { realm.clientInitialAccess().list(); }, Resource.CLIENT, false); - invoke((realm) -> { realm.clientInitialAccess().create(new ClientInitialAccessCreatePresentation()); }, Resource.CLIENT, true); - invoke((realm) -> { realm.clientInitialAccess().delete("nosuch"); }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientInitialAccess().list(); + } + }, Resource.CLIENT, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientInitialAccess().create(new ClientInitialAccessCreatePresentation()); + } + }, Resource.CLIENT, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.clientInitialAccess().delete("nosuch"); + } + }, Resource.CLIENT, true); } @Test public void roles() { - invoke((realm) -> { realm.roles().list(); }, Resource.REALM, false, true); - invoke((realm) -> { realm.roles().get("nosuch").toRepresentation(); }, Resource.REALM, false); - invoke((realm) -> { realm.roles().get("nosuch").update(new RoleRepresentation()); }, Resource.REALM, true); - invoke((realm) -> { realm.roles().create(new RoleRepresentation()); }, Resource.REALM, true); - invoke((realm) -> { realm.roles().deleteRole("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.roles().get("nosuch").getRoleComposites(); }, Resource.REALM, false); - invoke((realm) -> { realm.roles().get("nosuch").addComposites(Collections.emptyList()); }, Resource.REALM, true); - invoke((realm) -> { realm.roles().get("nosuch").deleteComposites(Collections.emptyList()); }, Resource.REALM, true); - invoke((realm) -> { realm.roles().get("nosuch").getRoleComposites(); }, Resource.REALM, false); - invoke((realm) -> { realm.roles().get("nosuch").getRealmRoleComposites(); }, Resource.REALM, false); - invoke((realm) -> { realm.roles().get("nosuch").getClientRoleComposites("nosuch"); }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().list(); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").toRepresentation(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").update(new RoleRepresentation()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().create(new RoleRepresentation()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().deleteRole("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").getRoleComposites(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").addComposites(Collections.emptyList()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").deleteComposites(Collections.emptyList()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").getRoleComposites(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").getRealmRoleComposites(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.roles().get("nosuch").getClientRoleComposites("nosuch"); + } + }, Resource.REALM, false); } @Test public void flows() { - invoke((realm) -> { realm.flows().getFormProviders(); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().getAuthenticatorProviders(); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().getClientAuthenticatorProviders(); }, Resource.REALM, false, true); - invoke((realm) -> { realm.flows().getFormActionProviders(); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().getFlows(); }, Resource.REALM, false, true); - invoke((realm, response) -> { response.set(realm.flows().createFlow(new AuthenticationFlowRepresentation())); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().getFlow("nosuch"); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().deleteFlow("nosuch"); }, Resource.REALM, true); - invoke((realm, response) -> { response.set(realm.flows().copy("nosuch", new HashMap<>())); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().addExecutionFlow("nosuch", new HashMap<>()); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().addExecution("nosuch", new HashMap<>()); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().getExecutions("nosuch"); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().updateExecutions("nosuch", new AuthenticationExecutionInfoRepresentation()); }, Resource.REALM, true); - AuthenticationExecutionRepresentation rep = new AuthenticationExecutionRepresentation(); - rep.setAuthenticator("auth-cookie"); - rep.setRequirement("OPTIONAL"); - invoke((realm, response) -> { response.set(realm.flows().addExecution(rep)); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().raisePriority("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().lowerPriority("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().removeExecution("nosuch"); }, Resource.REALM, true); - invoke((realm, response) -> { response.set(realm.flows().newExecutionConfig("nosuch", new AuthenticatorConfigRepresentation())); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().getUnregisteredRequiredActions(); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().registerRequiredAction(new RequiredActionProviderSimpleRepresentation()); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().getRequiredActions(); }, Resource.REALM, false, true); - invoke((realm) -> { realm.flows().getRequiredAction("nosuch"); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().removeRequiredAction("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().updateRequiredAction("nosuch", new RequiredActionProviderRepresentation()); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().getAuthenticatorConfigDescription("nosuch"); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().getPerClientConfigDescription(); }, Resource.REALM, false, true); - invoke((realm) -> { realm.flows().getAuthenticatorConfig("nosuch"); }, Resource.REALM, false); - invoke((realm) -> { realm.flows().removeAuthenticatorConfig("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.flows().updateAuthenticatorConfig("nosuch", new AuthenticatorConfigRepresentation()); }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getFormProviders(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getAuthenticatorProviders(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getClientAuthenticatorProviders(); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getFormActionProviders(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getFlows(); + } + }, Resource.REALM, false, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.flows().createFlow(new AuthenticationFlowRepresentation())); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getFlow("nosuch"); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().deleteFlow("nosuch"); + } + }, Resource.REALM, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.flows().copy("nosuch", Collections.emptyMap())); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().addExecutionFlow("nosuch", Collections.emptyMap()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().addExecution("nosuch", Collections.emptyMap()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getExecutions("nosuch"); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().updateExecutions("nosuch", new AuthenticationExecutionInfoRepresentation()); + } + }, Resource.REALM, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + AuthenticationExecutionRepresentation rep = new AuthenticationExecutionRepresentation(); + rep.setAuthenticator("auth-cookie"); + rep.setRequirement("OPTIONAL"); + response.set(realm.flows().addExecution(rep)); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().raisePriority("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().lowerPriority("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().removeExecution("nosuch"); + } + }, Resource.REALM, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.flows().newExecutionConfig("nosuch", new AuthenticatorConfigRepresentation())); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getAuthenticatorConfig("nosuch"); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getUnregisteredRequiredActions(); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().registerRequiredAction(new RequiredActionProviderSimpleRepresentation()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getRequiredActions(); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getRequiredAction("nosuch"); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().removeRequiredAction("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().updateRequiredAction("nosuch", new RequiredActionProviderRepresentation()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getAuthenticatorConfigDescription("nosuch"); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getPerClientConfigDescription(); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().getAuthenticatorConfig("nosuch"); + } + }, Resource.REALM, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().removeAuthenticatorConfig("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.flows().updateAuthenticatorConfig("nosuch", new AuthenticatorConfigRepresentation()); + } + }, Resource.REALM, true); } @Test public void rolesById() { - invoke((realm) -> { realm.rolesById().getRole("nosuch"); }, Resource.REALM, false, true); - invoke((realm) -> { realm.rolesById().updateRole("nosuch", new RoleRepresentation()); }, Resource.REALM, true); - invoke((realm) -> { realm.rolesById().deleteRole("nosuch"); }, Resource.REALM, true); - invoke((realm) -> { realm.rolesById().getRoleComposites("nosuch"); }, Resource.REALM, false, true); - invoke((realm) -> { realm.rolesById().addComposites("nosuch", Collections.emptyList()); }, Resource.REALM, true); - invoke((realm) -> { realm.rolesById().deleteComposites("nosuch", Collections.emptyList()); }, Resource.REALM, true); - invoke((realm) -> { realm.rolesById().getRoleComposites("nosuch"); }, Resource.REALM, false, true); - invoke((realm) -> { realm.rolesById().getRealmRoleComposites("nosuch"); }, Resource.REALM, false, true); - invoke((realm) -> { realm.rolesById().getClientRoleComposites("nosuch", "nosuch"); }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().getRole("nosuch"); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().updateRole("nosuch", new RoleRepresentation()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().deleteRole("nosuch"); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().getRoleComposites("nosuch"); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().addComposites("nosuch", Collections.emptyList()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().deleteComposites("nosuch", Collections.emptyList()); + } + }, Resource.REALM, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().getRoleComposites("nosuch"); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().getRealmRoleComposites("nosuch"); + } + }, Resource.REALM, false, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.rolesById().getClientRoleComposites("nosuch", "nosuch"); + } + }, Resource.REALM, false, true); } @Test public void groups() { - invoke((realm) -> { realm.groups().groups(); }, Resource.USER, false); - invoke((realm, response) -> { response.set(realm.groups().add(new GroupRepresentation())); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().groups(); + } + }, Resource.USER, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.groups().add(new GroupRepresentation())); + } + }, Resource.USER, true); - invoke((realm) -> { realm.groups().group("nosuch").toRepresentation(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").update(new GroupRepresentation()); }, Resource.USER, true); - invoke((realm) -> { realm.groups().group("nosuch").remove(); }, Resource.USER, true); - invoke((realm) -> { realm.groups().group("nosuch").members(0, 100); }, Resource.USER, false); - invoke((realm, response) -> { response.set(realm.groups().group("nosuch").subGroup(new GroupRepresentation())); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").toRepresentation(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").update(new GroupRepresentation()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").remove(); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").members(0, 100); + } + }, Resource.USER, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.groups().group("nosuch").subGroup(new GroupRepresentation())); + } + }, Resource.USER, true); - invoke((realm) -> { realm.groups().group("nosuch").roles().getAll(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").roles().realmLevel().listAll(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").roles().realmLevel().listEffective(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").roles().realmLevel().listAvailable(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").roles().realmLevel().add(Collections.emptyList()); }, Resource.USER, true); - invoke((realm) -> { realm.groups().group("nosuch").roles().realmLevel().remove(Collections.emptyList()); }, Resource.USER, true); - invoke((realm) -> { realm.groups().group("nosuch").roles().clientLevel("nosuch").listAll(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").roles().clientLevel("nosuch").listEffective(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").roles().clientLevel("nosuch").listAvailable(); }, Resource.USER, false); - invoke((realm) -> { realm.groups().group("nosuch").roles().clientLevel("nosuch").add(Collections.emptyList()); }, Resource.USER, true); - invoke((realm) -> { realm.groups().group("nosuch").roles().clientLevel("nosuch").remove(Collections.emptyList()); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().getAll(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().realmLevel().listAll(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().realmLevel().listEffective(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().realmLevel().listAvailable(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().realmLevel().add(Collections.emptyList()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().realmLevel().remove(Collections.emptyList()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().clientLevel("nosuch").listAll(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().clientLevel("nosuch").listEffective(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().clientLevel("nosuch").listAvailable(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().clientLevel("nosuch").add(Collections.emptyList()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.groups().group("nosuch").roles().clientLevel("nosuch").remove(Collections.emptyList()); + } + }, Resource.USER, true); } // Permissions for impersonation tested in ImpersonationTest @Test public void users() { - invoke((realm) -> { realm.users().get("nosuch").toRepresentation(); }, Resource.USER, false); - invoke((realm, response) -> { response.set(realm.users().create(UserBuilder.create().username("testuser").build())); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").update(UserBuilder.create().enabled(true).build()); }, Resource.USER, true); - invoke((realm) -> { realm.users().search("foo", 0, 1); }, Resource.USER, false); - invoke((realm) -> { realm.users().count(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").getUserSessions(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").getOfflineSessions("nosuch"); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").getFederatedIdentity(); }, Resource.USER, false); - invoke((realm, response) -> { response.set(realm.users().get("nosuch").addFederatedIdentity("nosuch", FederatedIdentityBuilder.create().identityProvider("nosuch").userId("nosuch").userName("nosuch").build())); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").removeFederatedIdentity("nosuch"); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").getConsents(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").revokeConsent("testclient"); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").logout(); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").remove(); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").resetPassword(CredentialBuilder.create().password("password").build()); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").removeTotp(); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").resetPasswordEmail(); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").executeActionsEmail(Collections.emptyList()); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").sendVerifyEmail(); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").groups(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").leaveGroup("nosuch"); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").joinGroup("nosuch"); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").toRepresentation(); + } + }, Resource.USER, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.users().create(UserBuilder.create().username("testuser").build())); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").update(UserBuilder.create().enabled(true).build()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().search("foo", 0, 1); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().count(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").getUserSessions(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").getOfflineSessions("nosuch"); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").getFederatedIdentity(); + } + }, Resource.USER, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.users() + .get("nosuch") + .addFederatedIdentity("nosuch", + FederatedIdentityBuilder.create().identityProvider("nosuch").userId("nosuch").userName("nosuch").build())); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").removeFederatedIdentity("nosuch"); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").getConsents(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").revokeConsent("testclient"); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").logout(); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").remove(); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").resetPassword(CredentialBuilder.create().password("password").build()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").removeTotp(); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").resetPasswordEmail(); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").executeActionsEmail(Collections.emptyList()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").sendVerifyEmail(); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").groups(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").leaveGroup("nosuch"); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").joinGroup("nosuch"); + } + }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").roles().getAll(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").roles().realmLevel().listAll(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").roles().realmLevel().listAvailable(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").roles().realmLevel().listEffective(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").roles().realmLevel().add(Collections.emptyList()); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").roles().realmLevel().remove(Collections.emptyList()); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().getAll(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().realmLevel().listAll(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().realmLevel().listAvailable(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().realmLevel().listEffective(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().realmLevel().add(Collections.emptyList()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().realmLevel().remove(Collections.emptyList()); + } + }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").roles().clientLevel("nosuch").listAll(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").roles().clientLevel("nosuch").listAvailable(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").roles().clientLevel("nosuch").listEffective(); }, Resource.USER, false); - invoke((realm) -> { realm.users().get("nosuch").roles().clientLevel("nosuch").add(Collections.emptyList()); }, Resource.USER, true); - invoke((realm) -> { realm.users().get("nosuch").roles().clientLevel("nosuch").remove(Collections.emptyList()); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().clientLevel("nosuch").listAll(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().clientLevel("nosuch").listAvailable(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().clientLevel("nosuch").listEffective(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().clientLevel("nosuch").add(Collections.emptyList()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.users().get("nosuch").roles().clientLevel("nosuch").remove(Collections.emptyList()); + } + }, Resource.USER, true); } @Test public void identityProviders() { - invoke((realm) -> { realm.identityProviders().findAll(); }, Resource.IDENTITY_PROVIDER, false); - invoke((realm, response) -> { response.set(realm.identityProviders().create(IdentityProviderBuilder.create().providerId("nosuch").alias("foo").build())); }, Resource.IDENTITY_PROVIDER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().findAll(); + } + }, Resource.IDENTITY_PROVIDER, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.identityProviders().create(IdentityProviderBuilder.create().providerId("nosuch").alias("foo").build())); + } + }, Resource.IDENTITY_PROVIDER, true); - invoke((realm) -> { realm.identityProviders().get("nosuch").toRepresentation(); }, Resource.IDENTITY_PROVIDER, false); - invoke((realm) -> { realm.identityProviders().get("nosuch").update(new IdentityProviderRepresentation()); }, Resource.IDENTITY_PROVIDER, true); - invoke((realm, response) -> { response.set(realm.identityProviders().get("nosuch").export("saml")); }, Resource.IDENTITY_PROVIDER, false); - invoke((realm) -> { realm.identityProviders().get("nosuch").remove(); }, Resource.IDENTITY_PROVIDER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().get("nosuch").toRepresentation(); + } + }, Resource.IDENTITY_PROVIDER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().get("nosuch").update(new IdentityProviderRepresentation()); + } + }, Resource.IDENTITY_PROVIDER, true); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.identityProviders().get("nosuch").export("saml")); + } + }, Resource.IDENTITY_PROVIDER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().get("nosuch").remove(); + } + }, Resource.IDENTITY_PROVIDER, true); - // TODO Mappers - // TODO importFrom + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.identityProviders().get("nosuch").addMapper(new IdentityProviderMapperRepresentation())); + } + }, Resource.IDENTITY_PROVIDER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().get("nosuch").delete("nosuch"); + } + }, Resource.IDENTITY_PROVIDER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().get("nosuch").getMappers(); + } + }, Resource.IDENTITY_PROVIDER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().get("nosuch").getMapperById("nosuch"); + } + }, Resource.IDENTITY_PROVIDER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().get("nosuch").getMapperTypes(); + } + }, Resource.IDENTITY_PROVIDER, false); + + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().importFrom(Collections.emptyMap()); + } + }, Resource.IDENTITY_PROVIDER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.identityProviders().importFrom(new MultipartFormDataOutput()); + } + }, Resource.IDENTITY_PROVIDER, true); } @Test public void userFederation() { - invoke((realm) -> { realm.userFederation().getProviderInstances(); }, Resource.USER, false); - invoke((realm) -> { realm.userFederation().getProviderFactories(); }, Resource.USER, false); - invoke((realm) -> { realm.userFederation().getProviderFactory("nosuch"); }, Resource.USER, false); - - UserFederationProviderRepresentation rep = new UserFederationProviderRepresentation(); - rep.setProviderName("ldap"); - invoke((realm, response) -> { response.set(realm.userFederation().create(rep)); }, Resource.USER, true); - invoke((realm) -> { realm.userFederation().get("nosuch").toRepresentation(); }, Resource.USER, false); - invoke((realm) -> { realm.userFederation().get("nosuch").update(new UserFederationProviderRepresentation()); }, Resource.USER, true); - invoke((realm) -> { realm.userFederation().get("nosuch").remove(); }, Resource.USER, true); - invoke((realm) -> { realm.userFederation().get("nosuch").syncUsers("nosuch"); }, Resource.USER, true); - invoke((realm) -> { realm.userFederation().get("nosuch").getMapperTypes(); }, Resource.USER, false); - invoke((realm) -> { realm.userFederation().get("nosuch").getMappers(); }, Resource.USER, false); - invoke((realm, response) -> { response.set(realm.userFederation().get("nosuch").addMapper(new UserFederationMapperRepresentation())); }, Resource.USER, true); - invoke((realm) -> { realm.userFederation().get("nosuch").getMapperById("nosuch"); }, Resource.USER, false); - invoke((realm) -> { realm.userFederation().get("nosuch").syncMapperData("nosuch", "nosuch"); }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().getProviderInstances(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().getProviderFactories(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().getProviderFactory("nosuch"); + } + }, Resource.USER, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + UserFederationProviderRepresentation rep = new UserFederationProviderRepresentation(); + rep.setProviderName("ldap"); + response.set(realm.userFederation().create(rep)); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").toRepresentation(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").update(new UserFederationProviderRepresentation()); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").remove(); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").syncUsers("nosuch"); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").getMapperTypes(); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").getMappers(); + } + }, Resource.USER, false); + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + response.set(realm.userFederation().get("nosuch").addMapper(new UserFederationMapperRepresentation())); + } + }, Resource.USER, true); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").getMapperById("nosuch"); + } + }, Resource.USER, false); + invoke(new Invocation() { + public void invoke(RealmResource realm) { + realm.userFederation().get("nosuch").syncMapperData("nosuch", "nosuch"); + } + }, Resource.USER, true); } - private void invoke(Invocation invocation, Resource resource, boolean manage) { - invoke((realm, response) -> { invocation.invoke(realm); }, resource, manage); + private void invoke(final Invocation invocation, Resource resource, boolean manage) { + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + invocation.invoke(realm); + } + }, resource, manage); } - private void invoke(Invocation invocation, Resource resource, boolean manage, boolean skipDifferentRole) { - invoke((realm, response) -> { invocation.invoke(realm); }, resource, manage, skipDifferentRole); + private void invoke(final Invocation invocation, Resource resource, boolean manage, boolean skipDifferentRole) { + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + invocation.invoke(realm); + } + }, resource, manage, skipDifferentRole); } private void invoke(InvocationWithResponse invocation, Resource resource, boolean manage) { @@ -513,8 +1487,12 @@ public class PermissionsTest extends AbstractKeycloakTest { invoke(invocation, clients.get("REALM2"), false); } - private void invoke(Invocation invocation, Keycloak client, boolean expectSuccess) { - invoke((realm, response) -> { invocation.invoke(realm); }, client, expectSuccess); + private void invoke(final Invocation invocation, Keycloak client, boolean expectSuccess) { + invoke(new InvocationWithResponse() { + public void invoke(RealmResource realm, AtomicReference response) { + invocation.invoke(realm); + } + }, client, expectSuccess); } private void invoke(InvocationWithResponse invocation, Keycloak client, boolean expectSuccess) {