92
92
import org .junit .jupiter .api .Test ;
93
93
import org .junit .jupiter .api .extension .RegisterExtension ;
94
94
import org .junit .jupiter .params .ParameterizedTest ;
95
+ import org .junit .jupiter .params .provider .Arguments ;
95
96
import org .junit .jupiter .params .provider .EnumSource ;
97
+ import org .junit .jupiter .params .provider .MethodSource ;
96
98
97
99
import java .io .IOException ;
98
100
import java .nio .charset .StandardCharsets ;
101
103
import java .util .Collections ;
102
104
import java .util .Date ;
103
105
import java .util .List ;
106
+ import java .util .stream .Stream ;
104
107
105
108
import static org .apache .commons .lang3 .StringUtils .isNotBlank ;
106
109
import static org .assertj .core .api .Assertions .assertThat ;
@@ -4225,7 +4228,7 @@ public void testToListOfResourcesAndExcludeContainer_withSearchSetContainingDocu
4225
4228
RequestDetails requestDetails = new SystemRequestDetails ();
4226
4229
requestDetails .setResourceName ("Bundle" );
4227
4230
4228
- List <IBaseResource > resources = AuthorizationInterceptor .toListOfResourcesAndExcludeContainerUnlessStandalone (searchSet , ourCtx );
4231
+ List <IBaseResource > resources = AuthorizationInterceptor .toListOfResourcesAndExcludeContainerUnlessStandalone (searchSet , ourCtx , requestDetails );
4229
4232
assertEquals (1 , resources .size ());
4230
4233
assertTrue (resources .contains (bundle ));
4231
4234
}
@@ -4242,12 +4245,46 @@ public void testToListOfResourcesAndExcludeContainer_withSearchSetContainingPati
4242
4245
RequestDetails requestDetails = new SystemRequestDetails ();
4243
4246
requestDetails .setResourceName ("Patient" );
4244
4247
4245
- List <IBaseResource > resources = AuthorizationInterceptor .toListOfResourcesAndExcludeContainerUnlessStandalone (searchSet , ourCtx );
4248
+ List <IBaseResource > resources = AuthorizationInterceptor .toListOfResourcesAndExcludeContainerUnlessStandalone (searchSet , ourCtx , requestDetails );
4246
4249
assertEquals (2 , resources .size ());
4247
4250
assertTrue (resources .contains (patient1 ));
4248
4251
assertTrue (resources .contains (patient2 ));
4249
4252
}
4250
4253
4254
+ @ ParameterizedTest
4255
+ @ MethodSource ("provideArgumentsForToListOfResourcesAndExcludeContainerUnlessStandalone" )
4256
+ public void givenAsearchRequestWithOperationOutcomeIntheResponse_whenToListOfResourcesAndExcludeContainerUnlessStandalone_thenReturnNoOperationOutcome (
4257
+ IBaseResource theResource , RequestDetails theRequestDetails , int theExpectedListSize
4258
+ ) {
4259
+ List <IBaseResource > resources = AuthorizationInterceptor .toListOfResourcesAndExcludeContainerUnlessStandalone (theResource , ourCtx , theRequestDetails );
4260
+ assertEquals (theExpectedListSize , resources .size ());
4261
+ }
4262
+
4263
+ private static Stream <Arguments > provideArgumentsForToListOfResourcesAndExcludeContainerUnlessStandalone () {
4264
+ Stream .Builder <Arguments > retVal = Stream .builder ();
4265
+ AuthorizationInterceptor .REST_OPERATIONS_TO_EXCLUDE_SECURITY_FOR_OPERATION_OUTCOME .forEach ((restOperationType )->{
4266
+ RequestDetails firstRequestDetails = new SystemRequestDetails ();
4267
+ RequestDetails secondRequestDetails = new SystemRequestDetails ();
4268
+ firstRequestDetails .setResourceName ("Patient" );
4269
+ firstRequestDetails .setRestOperationType (restOperationType );
4270
+ secondRequestDetails .setResourceName ("OperationOutcome" );
4271
+ secondRequestDetails .setRestOperationType (restOperationType );
4272
+
4273
+ OperationOutcome firstResponse = new OperationOutcome ();
4274
+ OperationOutcome secondResponse = new OperationOutcome ();
4275
+ firstResponse .addIssue ().
4276
+ setSeverity (OperationOutcome .IssueSeverity .INFORMATION ).
4277
+ setCode (OperationOutcome .IssueType .INFORMATIONAL );
4278
+ secondResponse .addIssue ().
4279
+ setSeverity (OperationOutcome .IssueSeverity .ERROR )
4280
+ .setCode (OperationOutcome .IssueType .CODEINVALID );
4281
+
4282
+ retVal .add (Arguments .of (firstResponse , firstRequestDetails , 0 ));
4283
+ retVal .add (Arguments .of (secondResponse , secondRequestDetails , 1 ));
4284
+ });
4285
+ return retVal .build ();
4286
+ }
4287
+
4251
4288
@ ParameterizedTest
4252
4289
@ EnumSource (value = Bundle .BundleType .class , names = {"DOCUMENT" , "MESSAGE" })
4253
4290
public void testShouldExamineBundleResources_withBundleRequestAndStandAloneBundleType_returnsFalse (Bundle .BundleType theBundleType ) {
0 commit comments