private void assertElasticsearchContainerHasHeapSize(ElasticsearchContainer container, long heapSizeInBytes)
        throws Exception {
        Response response = getClient(container).performRequest(new Request("GET", "/_nodes/_all/jvm"));
        String responseBody = EntityUtils.toString(response.getEntity());
        assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
        assertThat(responseBody).contains("\"heap_init_in_bytes\":" + heapSizeInBytes);
        assertThat(responseBody).contains("\"heap_max_in_bytes\":" + heapSizeInBytes);
    }
From 6.8, we can optionally activate security with a default password.
modules/elasticsearch/src/test/java/org/testcontainers/elasticsearch/ElasticsearchContainerTest.java