32
32
public class UriTest {
33
33
34
34
@ Test
35
- public void testUriBadSecurity () throws URISyntaxException {
35
+ public void testUriTrimmedUrl () throws URISyntaxException {
36
36
String incoming =
37
37
"https://localhost:9443/fhir-server/api/v4/_search?_count=10&_security=http://ibm.com/fhir/security&_fudge=tag&_page=1" ;
38
38
String requestUriString = incoming .split ("\\ ?" )[0 ];
@@ -62,6 +62,37 @@ public void testUriBadSecurity() throws URISyntaxException {
62
62
incoming );
63
63
}
64
64
65
+ @ Test
66
+ public void testUriBadSecurity () throws URISyntaxException {
67
+ String incoming =
68
+ "https://localhost:9443/fhir-server/api/v4/_search?_count=10&_security=http://ibm.com/fhir/security&_fudge=tag&_page=1" ;
69
+ String requestUriString = incoming ;
70
+
71
+ QueryParameterValue value = new QueryParameterValue ();
72
+ value .setValueString ("http://ibm.com/fhir/security" );
73
+ List <QueryParameterValue > values = Arrays .asList (value );
74
+ QueryParameter parameter = new QueryParameter (Type .TOKEN , "_security" , null , null , values );
75
+
76
+ List <QueryParameter > searchParameters = new ArrayList <>();
77
+
78
+ searchParameters .add (parameter );
79
+
80
+ QueryParameterValue value2 = new QueryParameterValue ();
81
+ value2 .setValueString ("tag" );
82
+ List <QueryParameterValue > values2 = Arrays .asList (value2 );
83
+ QueryParameter parameter2 = new QueryParameter (Type .TOKEN , "_fudge" , null , null , values2 );
84
+ searchParameters .add (parameter2 );
85
+
86
+
87
+ FHIRSearchContext ctx = FHIRSearchContextFactory .createSearchContext ();
88
+ ctx .setPageNumber (1 );
89
+ ctx .setPageSize (10 );
90
+ ctx .setSearchParameters (searchParameters );
91
+
92
+ assertEquals (SearchUtil .buildSearchSelfUri (requestUriString , ctx ),
93
+ incoming );
94
+ }
95
+
65
96
@ Test
66
97
public void testUriWithOnlyCompartmentInclusionSearchParmeter () throws URISyntaxException {
67
98
String expectedUri = "https://localhost:9443/fhir-server/api/v4/Patient/1234/Observation?_count=10&_page=1" ;
@@ -79,4 +110,20 @@ public void testUriWithOnlyCompartmentInclusionSearchParmeter() throws URISyntax
79
110
assertEquals (SearchUtil .buildSearchSelfUri (requestUriString , ctx ), expectedUri );
80
111
}
81
112
113
+ @ Test
114
+ public void testUriWithUnencodedPipe () throws URISyntaxException {
115
+ String expectedUri = "https://test?_count=10¶m=system%7Cvalue&_page=1" ;
116
+ String requestUriString = "https://test?param=system|value" ;
117
+
118
+ FHIRSearchContext ctx = FHIRSearchContextFactory .createSearchContext ();
119
+ ctx .setPageNumber (1 );
120
+ ctx .setPageSize (10 );
121
+ QueryParameterValue paramVal = new QueryParameterValue ();
122
+ paramVal .setValueSystem ("system" );
123
+ paramVal .setValueCode ("value" );
124
+ QueryParameter queryParameter = new QueryParameter (Type .TOKEN , "param" , null , null , Collections .singletonList (paramVal ));
125
+ ctx .setSearchParameters (Collections .singletonList (queryParameter ));
126
+
127
+ assertEquals (SearchUtil .buildSearchSelfUri (requestUriString , ctx ), expectedUri );
128
+ }
82
129
}
0 commit comments