@@ -203,91 +203,6 @@ public void testDoGetCoreModifiedURL() throws Exception {
203203 assertNull (response .getHeader ("Content-Disposition" ));
204204 }
205205
206- @ Test
207- public void testDoGetExtension () throws Exception {
208- // Test /webstart/extensions/testextension
209- HttpServletRequest request = mock (HttpServletRequest .class );
210- when (request .getRequestURI ()).thenReturn ("/webstart/extensions/testextension" );
211- when (request .getServletPath ()).thenReturn ("/webstart/extensions" );
212- when (request .getPathInfo ()).thenReturn ("/testextension" );
213- when (request .getParameterNames ()).thenReturn (Collections .emptyEnumeration ());
214-
215- TestHttpServletResponse response = new TestHttpServletResponse ();
216-
217- webStartServlet .doGet (request , response );
218-
219- assertEquals (normalizeWhitespace (EXTENSION_JNLP ), normalizeWhitespace (response .getResponseString ()));
220- assertEquals ("application/x-java-jnlp-file" , response .getContentType ());
221- assertEquals ("no-cache" , response .getHeader ("Pragma" ));
222- assertEquals ("nosniff" , response .getHeader ("X-Content-Type-Options" ));
223- assertEquals ("attachment; filename = \" testextension.jnlp\" " , response .getHeader ("Content-Disposition" ));
224-
225- // Test /webstart/extensions/testextension.jnlp
226- request = mock (HttpServletRequest .class );
227- when (request .getRequestURI ()).thenReturn ("/webstart/extensions/testextension.jnlp" );
228- when (request .getServletPath ()).thenReturn ("/webstart/extensions" );
229- when (request .getPathInfo ()).thenReturn ("/testextension" );
230- when (request .getParameterNames ()).thenReturn (Collections .emptyEnumeration ());
231-
232- response = new TestHttpServletResponse ();
233-
234- webStartServlet .doGet (request , response );
235-
236- assertEquals (normalizeWhitespace (EXTENSION_JNLP ), normalizeWhitespace (response .getResponseString ()));
237- assertEquals ("application/x-java-jnlp-file" , response .getContentType ());
238- assertEquals ("no-cache" , response .getHeader ("Pragma" ));
239- assertEquals ("nosniff" , response .getHeader ("X-Content-Type-Options" ));
240- assertEquals ("attachment; filename = \" testextension.jnlp\" " , response .getHeader ("Content-Disposition" ));
241- }
242-
243- @ Test
244- public void testDoGetExtensionQueryParams () throws Exception {
245- HttpServletRequest request = mock (HttpServletRequest .class );
246- when (request .getRequestURI ()).thenReturn ("/webstart/extensions/testextension" );
247- when (request .getServletPath ()).thenReturn ("/webstart/extensions" );
248- when (request .getPathInfo ()).thenReturn ("/testextension" );
249-
250- Map <String , String []> parameters = new HashMap <>();
251- parameters .put ("maxHeapSize" , new String [] { "1024m" });
252-
253- when (request .getParameterNames ()).thenReturn (Collections .enumeration (parameters .keySet ()));
254- when (request .getParameter (anyString ())).thenAnswer (new Answer <String >() {
255- @ Override
256- public String answer (InvocationOnMock invocation ) throws Throwable {
257- Object [] args = invocation .getArguments ();
258- return parameters .get ((String ) args [0 ])[0 ];
259- }
260- });
261- when (request .getParameterMap ()).thenReturn (parameters );
262-
263- TestHttpServletResponse response = new TestHttpServletResponse ();
264-
265- webStartServlet .doGet (request , response );
266-
267- assertEquals ("" , response .getResponseString ().trim ());
268- assertEquals ("" , response .getResponseString ().trim ());
269- assertEquals ("" , response .getContentType ());
270- assertNull (response .getHeader ("Content-Disposition" ));
271- }
272-
273- @ Test
274- public void testDoGetExtensionModifiedURL () throws Exception {
275- HttpServletRequest request = mock (HttpServletRequest .class );
276- when (request .getRequestURI ()).thenReturn ("/webstart/extensions/testextension;rfd.bat" );
277- when (request .getServletPath ()).thenReturn ("/webstart/extensions" );
278- when (request .getPathInfo ()).thenReturn ("/testextension" );
279- when (request .getParameterNames ()).thenReturn (Collections .emptyEnumeration ());
280-
281- TestHttpServletResponse response = new TestHttpServletResponse ();
282-
283- webStartServlet .doGet (request , response );
284-
285- assertEquals ("" , response .getResponseString ().trim ());
286- assertEquals ("" , response .getResponseString ().trim ());
287- assertEquals ("" , response .getContentType ());
288- assertNull (response .getHeader ("Content-Disposition" ));
289- }
290-
291206 private static class TestHttpServletResponse implements HttpServletResponse {
292207
293208 private String contentType ;
@@ -521,13 +436,6 @@ protected Document getAdministratorJnlp(HttpServletRequest request) throws Excep
521436 return factory .newDocumentBuilder ()
522437 .parse (new ByteArrayInputStream (CORE_JNLP .getBytes ()));
523438 }
524-
525- @ Override
526- protected Document getExtensionJnlp (String extensionPath ) throws Exception {
527- DocumentBuilderFactory factory = getSecureDocumentBuilderFactory ();
528- return factory .newDocumentBuilder ()
529- .parse (new ByteArrayInputStream (EXTENSION_JNLP .getBytes ()));
530- }
531439 }
532440
533441 private static DocumentBuilderFactory getSecureDocumentBuilderFactory () throws Exception {
@@ -558,16 +466,9 @@ private static String normalizeWhitespace(String input) {
558466 + " <j2se href=\" http://java.sun.com/products/autodl/j2se\" max-heap-size=\" 512m\" version=\" 1.6+\" />\n "
559467 + " <jar download=\" eager\" href=\" webstart/client-lib/mirth-client.jar\" main=\" true\" sha256=\" 0Lv3mOM4e10OBhk78/ST2CzHrXtm+EcZibxV7VfdbI8=\" />\n "
560468 + " <jar download=\" eager\" href=\" webstart/client-lib/mirth-client-core.jar\" sha256=\" testsha256\" />\n "
561- + " <extension href=\" webstart/extensions/test.jnlp\" />\n " + " </resources>\n " + " \n "
469+ + " <jar download=\" eager\" href=\" webstart/extensions/libs/file/test-client.jar\" sha256=\" testsha256\" />\n "
470+ + " <jar download=\" eager\" href=\" webstart/extensions/libs/file/test-shared.jar\" sha256=\" testsha256\" />\n " + " </resources>\n " + " \n "
562471 + " <application-desc main-class=\" com.mirth.connect.client.ui.Mirth\" >\n "
563472 + " <argument>https://localhost:8443</argument>\n " + " <argument>99.99.99</argument>\n "
564473 + " </application-desc>\n " + "</jnlp>" ;
565-
566- private static String EXTENSION_JNLP = "<jnlp>\n " + " <information>\n "
567- + " <title>Mirth Connect Extension - [Test Writer,Test Reader]</title>\n "
568- + " <vendor>NextGen Healthcare</vendor>\n " + " </information>\n " + " <security>\n "
569- + " <all-permissions/>\n " + " </security>\n " + " <resources>\n "
570- + " <jar download=\" eager\" href=\" libs/file/test-client.jar\" sha256=\" testsha256\" />\n "
571- + " <jar download=\" eager\" href=\" libs/file/test-shared.jar\" sha256=\" testsha256\" />\n "
572- + " </resources>\n " + " <component-desc/>\n " + "</jnlp>\n " + "" ;
573474}
0 commit comments