_filter searchparam should not appear in cap stmt if disabled (#2706)
* issue reproduced and fixed * changelog * cleanup
This commit is contained in:
parent
c498522c78
commit
94d6b15db9
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 2695
|
||||
title: "The _filter search parameter was incorrectly included in the server capability statement if it was disabled
|
||||
on the server. This has been corrected."
|
|
@ -145,4 +145,9 @@ public class JpaCapabilityStatementProvider extends ServerCapabilityStatementPro
|
|||
public void setSystemDao(IFhirSystemDao<Bundle, Meta> mySystemDao) {
|
||||
this.mySystemDao = mySystemDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean searchParamEnabled(String theSearchParam) {
|
||||
return !Constants.PARAM_FILTER.equals(theSearchParam) || myDaoConfig.isFilterParameterEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package ca.uhn.fhir.jpa.provider.r4;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec;
|
||||
import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider;
|
||||
import ca.uhn.fhir.rest.api.CacheControlDirective;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.provider.ServerCapabilityStatementProvider;
|
||||
import org.hl7.fhir.r4.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r4.model.Enumerations;
|
||||
|
@ -12,22 +13,19 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
public class ServerCapabilityStatementProviderJpaR4Test extends BaseResourceProviderR4Test {
|
||||
|
||||
|
@ -117,6 +115,7 @@ public class ServerCapabilityStatementProviderJpaR4Test extends BaseResourceProv
|
|||
public void after() throws Exception {
|
||||
super.after();
|
||||
ourCapabilityStatementProvider.setRestResourceRevIncludesEnabled(ServerCapabilityStatementProvider.DEFAULT_REST_RESOURCE_REV_INCLUDES_ENABLED);
|
||||
myDaoConfig.setFilterParameterEnabled(new DaoConfig().isFilterParameterEnabled());
|
||||
}
|
||||
|
||||
|
||||
|
@ -259,6 +258,13 @@ public class ServerCapabilityStatementProviderJpaR4Test extends BaseResourceProv
|
|||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterProperlyReported() {
|
||||
myDaoConfig.setFilterParameterEnabled(false);
|
||||
CapabilityStatement cs = myClient.capabilities().ofType(CapabilityStatement.class).execute();
|
||||
assertThat(findSearchParams(cs, "Patient", Constants.PARAM_FILTER), hasSize(0));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private List<String> findSupportedProfiles(CapabilityStatement theCapabilityStatement, String theResourceType) {
|
||||
assertEquals(1, theCapabilityStatement.getRest().size());
|
||||
|
|
|
@ -391,8 +391,9 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
searchParamRegistry = mySearchParamRegistry;
|
||||
searchParams = new HashMap<>(mySearchParamRegistry.getActiveSearchParams(resourceName));
|
||||
for (Entry<String, RuntimeSearchParam> nextBuiltInSp : serverConfiguration.getActiveSearchParams(resourceName).entrySet()) {
|
||||
if (nextBuiltInSp.getKey().startsWith("_") && !searchParams.containsKey(nextBuiltInSp.getKey())) {
|
||||
searchParams.put(nextBuiltInSp.getKey(), nextBuiltInSp.getValue());
|
||||
String key = nextBuiltInSp.getKey();
|
||||
if (key.startsWith("_") && !searchParams.containsKey(key) && searchParamEnabled(key)) {
|
||||
searchParams.put(key, nextBuiltInSp.getValue());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -534,6 +535,15 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param theSearchParam
|
||||
* @return true if theSearchParam is enabled on this server
|
||||
*/
|
||||
protected boolean searchParamEnabled(String theSearchParam) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addSearchMethodIfSearchIsNamedQuery(RequestDetails theRequestDetails, Bindings theBindings, FhirTerser theTerser, Set<String> theOperationNamesAlreadyAdded, IBase theElementToAddTo, SearchMethodBinding theSearchMethodBinding) {
|
||||
if (theSearchMethodBinding.getQueryName() != null) {
|
||||
String queryName = theBindings.getNamedSearchMethodBindingToName().get(theSearchMethodBinding);
|
||||
|
|
Loading…
Reference in New Issue