diff --git a/server-spi/src/main/java/org/keycloak/http/FormPartValue.java b/server-spi/src/main/java/org/keycloak/http/FormPartValue.java new file mode 100644 index 0000000000..c6aee35bfb --- /dev/null +++ b/server-spi/src/main/java/org/keycloak/http/FormPartValue.java @@ -0,0 +1,27 @@ +/* + * Copyright 2022 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.http; + +import java.io.InputStream; + +public interface FormPartValue { + + String asString(); + InputStream asInputStream(); + +} diff --git a/server-spi/src/main/java/org/keycloak/http/HttpRequest.java b/server-spi/src/main/java/org/keycloak/http/HttpRequest.java index 2dc6c8ed75..fd2d1279f8 100644 --- a/server-spi/src/main/java/org/keycloak/http/HttpRequest.java +++ b/server-spi/src/main/java/org/keycloak/http/HttpRequest.java @@ -47,6 +47,13 @@ public interface HttpRequest { */ MultivaluedMap getDecodedFormParameters(); + /** + * Parses the parts from a multipart form request (e.g.: multipart/form-data media type). + * + * @return the parts from a multipart form request + */ + MultivaluedMap getMultiPartFormParameters(); + /** * Returns the HTTP headers. * diff --git a/services/src/main/java/org/keycloak/broker/oidc/AbstractOAuth2IdentityProvider.java b/services/src/main/java/org/keycloak/broker/oidc/AbstractOAuth2IdentityProvider.java index b9a7bc4e02..2484d06822 100755 --- a/services/src/main/java/org/keycloak/broker/oidc/AbstractOAuth2IdentityProvider.java +++ b/services/src/main/java/org/keycloak/broker/oidc/AbstractOAuth2IdentityProvider.java @@ -136,7 +136,7 @@ public abstract class AbstractOAuth2IdentityProvider(); } - UriInfo originalUriInfo = getContextObject(UriInfo.class); - uriInfo.put(type, new KeycloakUriInfo(session, type, originalUriInfo)); + uriInfo.put(type, new KeycloakUriInfo(session, type, getHttpRequest().getUri())); } return uriInfo.get(type); } diff --git a/services/src/main/java/org/keycloak/services/FormPartValueImpl.java b/services/src/main/java/org/keycloak/services/FormPartValueImpl.java new file mode 100644 index 0000000000..3e2f944764 --- /dev/null +++ b/services/src/main/java/org/keycloak/services/FormPartValueImpl.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.services; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import org.keycloak.http.FormPartValue; + +public class FormPartValueImpl implements FormPartValue { + + private String value; + private InputStream inputStream; + + public FormPartValueImpl(String value) { + this.value = value; + } + + public FormPartValueImpl(InputStream inputStream) { + this.inputStream = inputStream; + this.value = null; + } + + @Override + public String asString() { + if (inputStream != null) { + throw new RuntimeException("Value is a input stream"); + } + return value; + } + + @Override + public InputStream asInputStream() { + if (inputStream == null) { + return new ByteArrayInputStream(value.getBytes()); + } + return inputStream; + } +} diff --git a/services/src/main/java/org/keycloak/services/HttpRequestImpl.java b/services/src/main/java/org/keycloak/services/HttpRequestImpl.java index 231568c93e..d4ddb8e0b0 100644 --- a/services/src/main/java/org/keycloak/services/HttpRequestImpl.java +++ b/services/src/main/java/org/keycloak/services/HttpRequestImpl.java @@ -17,12 +17,26 @@ package org.keycloak.services; -import org.keycloak.http.HttpRequest; +import static javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA_TYPE; +import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE; +import java.io.IOException; +import java.io.InputStream; +import java.security.cert.X509Certificate; +import java.util.List; +import java.util.Map; import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; -import java.security.cert.X509Certificate; +import javax.ws.rs.ext.MessageBodyReader; +import javax.ws.rs.ext.Providers; +import org.jboss.resteasy.core.ResteasyContext; +import org.jboss.resteasy.plugins.providers.multipart.InputPart; +import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +import org.keycloak.http.FormPartValue; +import org.keycloak.http.HttpRequest; public class HttpRequestImpl implements HttpRequest { @@ -48,6 +62,41 @@ public class HttpRequestImpl implements HttpRequest { return delegate.getDecodedFormParameters(); } + @Override + public MultivaluedMap getMultiPartFormParameters() { + try { + MediaType mediaType = getHttpHeaders().getMediaType(); + + if (!MULTIPART_FORM_DATA_TYPE.isCompatible(mediaType) || !mediaType.getParameters().containsKey("boundary")) { + return new MultivaluedHashMap<>(); + } + + Providers providers = ResteasyContext.getContextData(Providers.class); + MessageBodyReader multiPartProvider = providers.getMessageBodyReader( + MultipartFormDataInput.class, null, null, MULTIPART_FORM_DATA_TYPE); + MultipartFormDataInput inputs = multiPartProvider + .readFrom(null, null, null, mediaType, getHttpHeaders().getRequestHeaders(), + delegate.getInputStream()); + MultivaluedHashMap parts = new MultivaluedHashMap<>(); + + for (Map.Entry> entry : inputs.getFormDataMap().entrySet()) { + for (InputPart value : entry.getValue()) { + MediaType valueMediaType = value.getMediaType(); + + if (TEXT_PLAIN_TYPE.isCompatible(valueMediaType)) { + parts.add(entry.getKey(), new FormPartValueImpl(value.getBodyAsString())); + } else { + parts.add(entry.getKey(), new FormPartValueImpl(value.getBody(InputStream.class, null))); + } + } + } + + return parts; + } catch (IOException cause) { + throw new RuntimeException("Failed to parse multi part request", cause); + } + } + @Override public HttpHeaders getHttpHeaders() { if (delegate == null) { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java index 29081af174..790f02f7a5 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java @@ -40,6 +40,7 @@ import org.keycloak.urls.UrlType; import javax.ws.rs.GET; import javax.ws.rs.HttpMethod; +import javax.ws.rs.OPTIONS; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; @@ -223,6 +224,18 @@ public class AdminRoot { return new RealmsAdminResource(session, auth, tokenManager); } + @Path("{any:.*}") + @OPTIONS + public Object preFlight() { + HttpRequest request = getHttpRequest(); + + if (!isAdminApiEnabled()) { + throw new NotFoundException(); + } + + return new AdminCorsPreflightService(request); + } + /** * General information about the server * diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java index a132401c7a..9859c44c43 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientAttributeCertificateResource.java @@ -18,8 +18,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 javax.ws.rs.NotAcceptableException; import javax.ws.rs.NotFoundException; @@ -29,6 +27,7 @@ import org.keycloak.common.util.StreamUtil; import org.keycloak.common.util.KeystoreUtil.KeystoreFormat; import org.keycloak.events.admin.OperationType; import org.keycloak.events.admin.ResourceType; +import org.keycloak.http.FormPartValue; import org.keycloak.jose.jwk.JSONWebKeySet; import org.keycloak.jose.jwk.JWK; import org.keycloak.jose.jwk.JWKParser; @@ -52,6 +51,7 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -61,8 +61,6 @@ import java.security.PrivateKey; import java.security.PublicKey; import java.security.cert.Certificate; import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -140,11 +138,11 @@ public class ClientAttributeCertificateResource { @Path("upload") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) - public CertificateRepresentation uploadJks(MultipartFormDataInput input) throws IOException { + public CertificateRepresentation uploadJks() throws IOException { auth.clients().requireConfigure(client); try { - CertificateRepresentation info = getCertFromRequest(input); + CertificateRepresentation info = getCertFromRequest(); CertificateInfoHelper.updateClientModelCertificateInfo(client, info, attributePrefix); adminEvent.operation(OperationType.ACTION).resourcePath(session.getContext().getUri()).representation(info).success(); @@ -165,11 +163,11 @@ public class ClientAttributeCertificateResource { @Path("upload-certificate") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) - public CertificateRepresentation uploadJksCertificate(MultipartFormDataInput input) throws IOException { + public CertificateRepresentation uploadJksCertificate() throws IOException { auth.clients().requireConfigure(client); try { - CertificateRepresentation info = getCertFromRequest(input); + CertificateRepresentation info = getCertFromRequest(); info.setPrivateKey(null); CertificateInfoHelper.updateClientModelCertificateInfo(client, info, attributePrefix); @@ -180,16 +178,16 @@ public class ClientAttributeCertificateResource { } } - private CertificateRepresentation getCertFromRequest(MultipartFormDataInput input) throws IOException { + private CertificateRepresentation getCertFromRequest() throws IOException { auth.clients().requireManage(client); CertificateRepresentation info = new CertificateRepresentation(); - Map> uploadForm = input.getFormDataMap(); - List keystoreFormatPart = uploadForm.get("keystoreFormat"); + MultivaluedMap uploadForm = session.getContext().getHttpRequest().getMultiPartFormParameters(); + FormPartValue keystoreFormatPart = uploadForm.getFirst("keystoreFormat"); if (keystoreFormatPart == null) throw new BadRequestException(); - String keystoreFormat = keystoreFormatPart.get(0).getBodyAsString(); - List inputParts = uploadForm.get("file"); + String keystoreFormat = keystoreFormatPart.asString(); + FormPartValue inputParts = uploadForm.getFirst("file"); if (keystoreFormat.equals(CERTIFICATE_PEM)) { - String pem = StreamUtil.readString(inputParts.get(0).getBody(InputStream.class, null)); + String pem = StreamUtil.readString(inputParts.asInputStream()); pem = PemUtils.removeBeginEnd(pem); @@ -199,7 +197,7 @@ public class ClientAttributeCertificateResource { info.setCertificate(pem); return info; } else if (keystoreFormat.equals(PUBLIC_KEY_PEM)) { - String pem = StreamUtil.readString(inputParts.get(0).getBody(InputStream.class, null)); + String pem = StreamUtil.readString(inputParts.asInputStream()); // Validate format KeycloakModelUtils.getPublicKey(pem); @@ -207,7 +205,7 @@ public class ClientAttributeCertificateResource { info.setPublicKey(pem); return info; } else if (keystoreFormat.equals(JSON_WEB_KEY_SET)) { - InputStream stream = inputParts.get(0).getBody(InputStream.class, null); + InputStream stream = inputParts.asInputStream(); JSONWebKeySet keySet = JsonSerialization.readValue(stream, JSONWebKeySet.class); JWK publicKeyJwk = JWKSUtils.getKeyForUse(keySet, JWK.Use.SIG); if (publicKeyJwk == null) { @@ -222,17 +220,17 @@ public class ClientAttributeCertificateResource { } - String keyAlias = uploadForm.get("keyAlias").get(0).getBodyAsString(); - List keyPasswordPart = uploadForm.get("keyPassword"); - char[] keyPassword = keyPasswordPart != null ? keyPasswordPart.get(0).getBodyAsString().toCharArray() : null; + String keyAlias = uploadForm.getFirst("keyAlias").asString(); + FormPartValue keyPasswordPart = uploadForm.getFirst("keyPassword"); + char[] keyPassword = keyPasswordPart != null ? keyPasswordPart.asString().toCharArray() : null; - List storePasswordPart = uploadForm.get("storePassword"); - char[] storePassword = storePasswordPart != null ? storePasswordPart.get(0).getBodyAsString().toCharArray() : null; + FormPartValue storePasswordPart = uploadForm.getFirst("storePassword"); + char[] storePassword = storePasswordPart != null ? storePasswordPart.asString().toCharArray() : null; PrivateKey privateKey = null; X509Certificate certificate = null; try { KeyStore keyStore = CryptoIntegration.getProvider().getKeyStore(KeystoreFormat.valueOf(keystoreFormat)); - keyStore.load(inputParts.get(0).getBody(InputStream.class, null), storePassword); + keyStore.load(inputParts.asInputStream(), storePassword); try { privateKey = (PrivateKey)keyStore.getKey(keyAlias, keyPassword); } catch (Exception e) { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java b/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java index f331e574ea..1f1bfd8c62 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java @@ -31,6 +31,7 @@ import org.keycloak.representations.idm.GroupRepresentation; import org.keycloak.representations.idm.ManagementPermissionReference; import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.services.ErrorResponse; +import org.keycloak.services.Urls; import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluator; import org.keycloak.services.resources.admin.permissions.AdminPermissionManagement; import org.keycloak.services.resources.admin.permissions.AdminPermissions; @@ -169,8 +170,12 @@ public class GroupResource { child = realm.createGroup(groupName, group); updateGroup(rep, child, realm, session); URI uri = session.getContext().getUri().getBaseUriBuilder() - .path(session.getContext().getUri().getMatchedURIs().get(2)) - .path(child.getId()).build(); + .path(AdminRoot.class) + .path(AdminRoot.class, "getRealmsAdmin") + .path(RealmsAdminResource.class, "getRealmAdmin") + .path(RealmAdminResource.class, "getGroups") + .path(GroupsResource.class, "getGroupById") + .build(realm.getName(), child.getId()); builder.status(201).location(uri); rep.setId(child.getId()); adminEvent.operation(OperationType.CREATE); 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 74bd01d402..05140e09b9 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 @@ -19,14 +19,13 @@ package org.keycloak.services.resources.admin; import com.google.common.collect.Streams; 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.keycloak.broker.provider.IdentityProvider; import org.keycloak.broker.provider.IdentityProviderFactory; import org.keycloak.broker.social.SocialIdentityProvider; import org.keycloak.connections.httpclient.HttpClientProvider; import org.keycloak.events.admin.OperationType; import org.keycloak.events.admin.ResourceType; +import org.keycloak.http.FormPartValue; import org.keycloak.models.IdentityProviderModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; @@ -47,10 +46,10 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import java.io.IOException; import java.io.InputStream; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Stream; @@ -106,15 +105,14 @@ public class IdentityProvidersResource { @Path("import-config") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) - public Map importFrom(MultipartFormDataInput input) throws IOException { + public Map importFrom() throws IOException { this.auth.realm().requireManageIdentityProviders(); - Map> formDataMap = input.getFormDataMap(); + MultivaluedMap formDataMap = session.getContext().getHttpRequest().getMultiPartFormParameters(); 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); + String providerId = formDataMap.getFirst("providerId").asString(); + InputStream inputStream = formDataMap.getFirst("file").asInputStream(); IdentityProviderFactory providerFactory = getProviderFactoryById(providerId); Map config = providerFactory.parseConfig(session, inputStream); return config; @@ -133,7 +131,7 @@ public class IdentityProvidersResource { @Produces(MediaType.APPLICATION_JSON) public Map importFrom(Map data) throws IOException { this.auth.realm().requireManageIdentityProviders(); - if (!(data.containsKey("providerId") && data.containsKey("fromUrl"))) { + if (data == null || !(data.containsKey("providerId") && data.containsKey("fromUrl"))) { throw new BadRequestException(); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java index cd7315e7ac..0d6288befd 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -540,6 +540,7 @@ public class RealmAdminResource { * */ @Path("push-revocation") + @Produces(MediaType.APPLICATION_JSON) @POST public GlobalRequestResult pushRevocation() { auth.realm().requireManageRealm(); @@ -1010,6 +1011,7 @@ public class RealmAdminResource { */ @Path("partialImport") @POST + @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response partialImport(InputStream requestBody) { auth.realm().requireManageRealm(); @@ -1065,6 +1067,7 @@ public class RealmAdminResource { * @return */ @Path("partial-export") + @Produces(MediaType.APPLICATION_JSON) @POST public Response partialExport(@QueryParam("exportGroupsAndRoles") Boolean exportGroupsAndRoles, @QueryParam("exportClients") Boolean exportClients) { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmLocalizationResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmLocalizationResource.java index 9eb89e7222..0a41e70364 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmLocalizationResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmLocalizationResource.java @@ -19,8 +19,7 @@ package org.keycloak.services.resources.admin; import com.fasterxml.jackson.core.type.TypeReference; -import org.jboss.resteasy.plugins.providers.multipart.InputPart; -import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +import org.keycloak.http.FormPartValue; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; import org.keycloak.models.RealmModel; @@ -28,7 +27,6 @@ import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluato import java.io.IOException; import java.io.InputStream; -import java.util.List; import java.util.Map; import java.util.HashMap; import java.util.stream.Stream; @@ -45,6 +43,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import org.keycloak.util.JsonSerialization; import org.keycloak.utils.StringUtil; @@ -82,16 +81,14 @@ public class RealmLocalizationResource { @POST @Path("{locale}") @Consumes(MediaType.MULTIPART_FORM_DATA) - public void createOrUpdateRealmLocalizationTextsFromFile(@PathParam("locale") String locale, - MultipartFormDataInput input) { + public void createOrUpdateRealmLocalizationTextsFromFile(@PathParam("locale") String locale) { this.auth.realm().requireManageRealm(); - Map> formDataMap = input.getFormDataMap(); + MultivaluedMap formDataMap = session.getContext().getHttpRequest().getMultiPartFormParameters(); if (!formDataMap.containsKey("file")) { throw new BadRequestException(); } - InputPart file = formDataMap.get("file").get(0); - try (InputStream inputStream = file.getBody(InputStream.class, null)) { + try (InputStream inputStream = formDataMap.getFirst("file").asInputStream()) { TypeReference> typeRef = new TypeReference>() { }; Map rep = JsonSerialization.readValue(inputStream, typeRef); diff --git a/services/src/main/java/org/keycloak/services/util/ObjectMapperResolver.java b/services/src/main/java/org/keycloak/services/util/ObjectMapperResolver.java old mode 100755 new mode 100644 diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/OAuthClient.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/OAuthClient.java index b3e170dd7e..81fe8a0d1b 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/OAuthClient.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/OAuthClient.java @@ -1893,7 +1893,7 @@ public class OAuthClient { Header[] contentTypeHeaders = response.getHeaders("Content-Type"); String contentType = (contentTypeHeaders != null && contentTypeHeaders.length > 0) ? contentTypeHeaders[0].getValue() : null; - if (!"application/json".equals(contentType)) { + if (contentType == null || !contentType.startsWith("application/json")) { Assert.fail("Invalid content type. Status: " + statusCode + ", contentType: " + contentType); } 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 d8240661a1..b92dfa3450 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 @@ -18,10 +18,8 @@ package org.keycloak.testsuite.admin; import org.hamcrest.Matchers; -import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput; import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.keycloak.admin.client.Keycloak; @@ -642,12 +640,12 @@ public class PermissionsTest extends AbstractKeycloakTest { invoke(new Invocation() { public void invoke(RealmResource realm) { - realm.clients().get(foo.getId()).getCertficateResource("nosuch").uploadJks(new MultipartFormDataOutput()); + realm.clients().get(foo.getId()).getCertficateResource("nosuch").uploadJks(null); } }, Resource.CLIENT, true); invoke(new Invocation() { public void invoke(RealmResource realm) { - realm.clients().get(foo.getId()).getCertficateResource("nosuch").uploadJksCertificate(new MultipartFormDataOutput()); + realm.clients().get(foo.getId()).getCertficateResource("nosuch").uploadJksCertificate(null); } }, Resource.CLIENT, true); @@ -1727,7 +1725,7 @@ public class PermissionsTest extends AbstractKeycloakTest { }, Resource.IDENTITY_PROVIDER, true); invoke(new Invocation() { public void invoke(RealmResource realm) { - realm.identityProviders().importFrom(new MultipartFormDataOutput()); + realm.identityProviders().importFrom(null); } }, Resource.IDENTITY_PROVIDER, true); } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/util/URLAssert.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/util/URLAssert.java index f0900943f2..8ae4bf1ddb 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/util/URLAssert.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/util/URLAssert.java @@ -177,7 +177,7 @@ public class URLAssert { public void assertResponse(CloseableHttpResponse response) throws IOException { HttpEntity entity = response.getEntity(); Header contentType = entity.getContentType(); - Assert.assertEquals("application/json", contentType.getValue()); + Assert.assertTrue(contentType.getValue().startsWith("application/json")); char [] buf = new char[8192]; StringWriter out = new StringWriter();