This project demonstrates how to create a Quarkus application that securely connects to a Flipt instance using a self-signed certificate. It uses Testcontainers to launch a real Flipt container for integration tests, providing a complete, end-to-end example of a secure connection.
Before you begin, ensure you have the following tools installed on your system:
- Java 21 SDK (or newer)
- Apache Maven 3.9.0 (or newer)
- Docker (must be running)
- Quarkus CLI
Follow these steps to set up your environment and run the integration tests.
If you don't have the Quarkus Command Line Interface installed, follow the official guide to set it up for your operating system:
This project requires a self-signed certificate for the test environment. Use the Quarkus CLI to generate the necessary PKCS#12 keystore and truststore files.
Run the following command from the root of the project directory:
quarkus tls generate-certificate --name flipt-cert --self-signed
This will create a .certs
directory containing flipt-cert-keystore.p12
and flipt-cert-truststore.p12
.
The Flipt container used in the tests requires the certificate and private key to be in PEM format (.crt
and .key
). A helper script is provided to extract these from the files you just generated.
Make the script executable and run it:
chmod +x prepare_test_certs.sh
This will create the server.crt
and server.key
files inside the src/test/resources/
directory, which will be used by the test.
Now you are ready to build the project. The following command will compile the code, download dependencies, and execute the integration tests, which will automatically start and configure the Flipt Docker container.
mvn clean install
If all steps were followed correctly, the build should complete successfully, indicating that your Quarkus application was able to connect to the secure, containerized Flipt instance and evaluate the test flag.
This test setup requires you to create a few files for the Flipt container's configuration.
- Generate a Self-Signed Certificate:
Use
openssl
to create a certificate and key.openssl req -x509 -newkey rsa:2048 -nodes \ -keyout src/test/resources/server.key \ -out src/test/resources/server.crt \ -sha256 -days 365 \ -subj "/CN=localhost"