PostgresHandle { public Future<SqlConnection> getConnection() { return pool.getConnection(); } PostgresHandle(Vertx vertx, JsonObject conf); Future<SqlConnection> getConnection(); PostgresQuery getQuery();  }
@Test @DisplayName("Basic connectivity test without encryption") @SuppressWarnings("java:S2699") void connectWithoutSsl(Vertx vertx, VertxTestContext vtc) { configure("ssl = off"); JsonObject config = config(); config.remove("postgres_server_pem"); new PostgresHandle(vertx, config).getConnection().onComplete(vtc.completing()); }
@Test void rejectWithoutSsl(Vertx vertx, VertxTestContext vtc) { configure("ssl = off"); new PostgresHandle(vertx, config()).getConnection().onComplete(vtc.failing(fail -> vtc.completeNow())); }
@Test void tlsv1_3(Vertx vertx, VertxTestContext vtc) { configure("ssl = on"); new PostgresHandle(vertx, config()).getConnection().onComplete(vtc.succeeding(connection -> vtc.verify(() -> { assertThat(connection.isSSL()).isTrue(); String sql = "SELECT version FROM pg_stat_ssl WHERE pid = pg_backend_pid()"; connection.query(sql).execute(vtc.succeeding(rowset -> vtc.verify(() -> { assertThat(rowset.iterator().next().getString(0)).isEqualTo("TLSv1.3"); vtc.completeNow(); }))); }))); }
@Test void rejectTlsv1_2(Vertx vertx, VertxTestContext vtc) { configure("ssl = on", "ssl_min_protocol_version = TLSv1.2", "ssl_max_protocol_version = TLSv1.2"); new PostgresHandle(vertx, config()).getConnection().onComplete(vtc.failing(fail -> vtc.completeNow())); }