@@ -304,9 +304,16 @@ public void testElasticsearch8SecureByDefault() throws Exception {
304304 // Start the container. This step might take some time...
305305 container .start ();
306306
307- Response response = getClusterHealth (container );
308- assertThat (response .getStatusLine ().getStatusCode ()).isEqualTo (200 );
309- assertThat (EntityUtils .toString (response .getEntity ())).contains ("cluster_name" );
307+ assertClusterHealthResponse (container );
308+ }
309+ }
310+
311+ @ Test
312+ public void testDockerHubElasticsearch8ImageSecureByDefault () throws Exception {
313+ try (ElasticsearchContainer container = new ElasticsearchContainer ("elasticsearch:8.1.2" )) {
314+ container .start ();
315+
316+ assertClusterHealthResponse (container );
310317 }
311318 }
312319
@@ -351,9 +358,7 @@ public void testElasticsearch8SecureByDefaultHttpWaitStrategy() throws Exception
351358 // Start the container. This step might take some time...
352359 container .start ();
353360
354- Response response = getClusterHealth (container );
355- assertThat (response .getStatusLine ().getStatusCode ()).isEqualTo (200 );
356- assertThat (EntityUtils .toString (response .getEntity ())).contains ("cluster_name" );
361+ assertClusterHealthResponse (container );
357362 }
358363 }
359364
@@ -488,4 +493,10 @@ private void assertElasticsearchContainerHasHeapSize(ElasticsearchContainer cont
488493 assertThat (responseBody ).contains ("\" heap_init_in_bytes\" :" + heapSizeInBytes );
489494 assertThat (responseBody ).contains ("\" heap_max_in_bytes\" :" + heapSizeInBytes );
490495 }
496+
497+ private void assertClusterHealthResponse (ElasticsearchContainer container ) throws IOException {
498+ Response response = getClusterHealth (container );
499+ assertThat (response .getStatusLine ().getStatusCode ()).isEqualTo (200 );
500+ assertThat (EntityUtils .toString (response .getEntity ())).contains ("cluster_name" );
501+ }
491502}
0 commit comments