4234 consent in conjunction with versionedapiconverterinterceptor fails (#4236)
* Add constant for interceptor * add test, changelog
This commit is contained in:
parent
220bfebc1c
commit
3199728024
|
@ -24,7 +24,6 @@ import ca.uhn.fhir.rest.client.api.IBasicClient;
|
|||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClientFactory;
|
||||
import ca.uhn.fhir.tls.TlsAuthentication;
|
||||
import ca.uhn.fhir.util.FhirTerser;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
|
|
|
@ -23,6 +23,7 @@ package ca.uhn.hapi.converters.server;
|
|||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.interceptor.api.Interceptor;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
|
@ -30,6 +31,7 @@ import ca.uhn.fhir.rest.api.server.ResponseDetails;
|
|||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
|
||||
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationConstants;
|
||||
import org.hl7.fhir.converter.NullVersionConverterAdvisor10_30;
|
||||
import org.hl7.fhir.converter.NullVersionConverterAdvisor10_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
|
||||
|
@ -54,6 +56,8 @@ import static org.apache.commons.lang3.StringUtils.*;
|
|||
* Versioned API features.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
@Interceptor(order = AuthorizationConstants.ORDER_CONVERTER_INTERCEPTOR)
|
||||
public class VersionedApiConverterInterceptor extends InterceptorAdapter {
|
||||
private final FhirContext myCtxDstu2;
|
||||
private final FhirContext myCtxDstu2Hl7Org;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 4234
|
||||
jira: SMILE-4765
|
||||
title: "Fixed a bug which caused a failure when combining a Consent Interceptor with version conversion via the `Accept` header."
|
||||
|
|
@ -24,6 +24,7 @@ import ca.uhn.fhir.rest.server.interceptor.consent.IConsentService;
|
|||
import ca.uhn.fhir.util.BundleUtil;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
import ca.uhn.hapi.converters.server.VersionedApiConverterInterceptor;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
|
@ -282,6 +283,21 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConsentWorksWithVersionedApiConverterInterceptor() {
|
||||
myConsentInterceptor = new ConsentInterceptor(new IConsentService() {
|
||||
});
|
||||
ourRestServer.getInterceptorService().registerInterceptor(myConsentInterceptor);
|
||||
ourRestServer.getInterceptorService().registerInterceptor(new VersionedApiConverterInterceptor());
|
||||
|
||||
myClient.create().resource(new Patient().setGender(Enumerations.AdministrativeGender.MALE).addName(new HumanName().setFamily("1"))).execute();
|
||||
Bundle response = myClient.search().forResource(Patient.class).count(1).accept("application/fhir+json; fhirVersion=3.0").returnBundle(Bundle.class).execute();
|
||||
|
||||
assertEquals(1, response.getEntry().size());
|
||||
assertNull(response.getTotalElement().getValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHistoryAndBlockSome() {
|
||||
create50Observations();
|
||||
|
|
|
@ -24,6 +24,7 @@ public class AuthorizationConstants {
|
|||
|
||||
public static final int ORDER_CONSENT_INTERCEPTOR = 100;
|
||||
public static final int ORDER_AUTH_INTERCEPTOR = 200;
|
||||
public static final int ORDER_CONVERTER_INTERCEPTOR = 300;
|
||||
|
||||
private AuthorizationConstants() {
|
||||
super();
|
||||
|
|
Loading…
Reference in New Issue