exasol / exasol-testcontainers

Test container for Exasol on Docker
MIT License
9 stars 2 forks source link

What was TlsConnectionIT.testCertificateFailsWithHttpClient supposed to prove? #231

Closed redcatbear closed 1 year ago

redcatbear commented 1 year ago

Situation

We had the following test failing with 8.17.0:

TlsConnectionIT.testCertificateFailsWithHttpClient

wrong exception message
Expected: ("No subject alternative names present" or "No name matching localhost found")
     but: was "HTTP/1.1 header parser received no bytes"

I read the test a couple of times, but did not understand, what it was supposed to prove. It looked like it exercised a client instead of the Exasol Test Container (which should be the unit under test).

@kaklakariada, when you are back, maybe you can shed some light on this.

kaklakariada commented 1 year ago

See https://github.com/exasol/exasol-testcontainers/blob/03cc060072aa0e05ba3ae0803d72f9860b163685/src/test/java/com/exasol/containers/tls/TlsConnectionIT.java#L150-L168

    @Test
    void testCertificateFailsWithHttpClient() throws KeyManagementException, KeyStoreException,
            NoSuchAlgorithmException, CertificateException, IOException, InterruptedException, URISyntaxException {

        final SSLContext sslContext = createSslContextWithCertificate();

        ExceptionAssertions.assertThrowsWithMessage(IOException.class, () -> sendRequestWithHttpClient(sslContext),
                either(equalTo("No subject alternative names present"))
                        .or(equalTo("No name matching localhost found")));
    }

    private HttpResponse<String> sendRequestWithHttpClient(final SSLContext sslContext)
            throws IOException, InterruptedException, URISyntaxException {
        final HttpClient httpClient = HttpClient.newBuilder().sslContext(sslContext).build();

        final HttpRequest request = HttpRequest.newBuilder(new URI(CONTAINER.getRpcUrl()))
                .POST(BodyPublishers.ofString("")).build();
        return httpClient.send(request, BodyHandlers.ofString());
    }

This test tries to connect to the container's RPC port and expects a failure. I think it should verify that the RPC port is open.

redcatbear commented 1 year ago

After discussing with @kaklakariada, we agreed that this test exercises a feature of the docker-db, not of the exasol-testcontainer and thus does not belong here.