mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-18 10:55:22 +00:00
Add tests for invalid inputs
This commit is contained in:
parent
58a2f23c0d
commit
39ae66de16
@ -306,6 +306,46 @@ public class SearchNarrowingInterceptorTest {
|
|||||||
assertNull(ourLastHitMethod);
|
assertNull(ourLastHitMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNarrowObservationsByPatientContext_ClientRequestedBadParameter() {
|
||||||
|
|
||||||
|
ourNextCompartmentList = new AuthorizedList().addCompartments("Patient/123", "Patient/456");
|
||||||
|
|
||||||
|
try {
|
||||||
|
ourClient
|
||||||
|
.search()
|
||||||
|
.forResource("Observation")
|
||||||
|
.where(Observation.PATIENT.hasAnyOfIds("Patient/"))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
fail("Expected a 403 error");
|
||||||
|
} catch (ForbiddenOperationException e) {
|
||||||
|
assertEquals(Constants.STATUS_HTTP_403_FORBIDDEN, e.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertNull(ourLastHitMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNarrowObservationsByPatientContext_ClientRequestedBadPermission() {
|
||||||
|
|
||||||
|
ourNextCompartmentList = new AuthorizedList().addCompartments("Patient/");
|
||||||
|
|
||||||
|
try {
|
||||||
|
ourClient
|
||||||
|
.search()
|
||||||
|
.forResource("Observation")
|
||||||
|
.where(Observation.PATIENT.hasAnyOfIds("Patient/111", "Patient/777"))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
fail("Expected a 403 error");
|
||||||
|
} catch (ForbiddenOperationException e) {
|
||||||
|
assertEquals(Constants.STATUS_HTTP_403_FORBIDDEN, e.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertNull(ourLastHitMethod);
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> toStrings(BaseAndListParam<? extends IQueryParameterOr<?>> theParams) {
|
private List<String> toStrings(BaseAndListParam<? extends IQueryParameterOr<?>> theParams) {
|
||||||
List<? extends IQueryParameterOr<? extends IQueryParameterType>> valuesAsQueryTokens = theParams.getValuesAsQueryTokens();
|
List<? extends IQueryParameterOr<? extends IQueryParameterType>> valuesAsQueryTokens = theParams.getValuesAsQueryTokens();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user