public void configureServerWithBasicAuth(final Authenticator authenticator,
                                             final Consumer<TestServerBootstrap> serverCustomizer) {
        configureServer(bootstrap -> {
            bootstrap.setExchangeHandlerDecorator(requestHandler ->
                    new AuthenticatingDecorator(requestHandler, authenticator));
            serverCustomizer.accept(bootstrap);
        });
    }
Unit tests for automatic client authentication.
httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java