https://github.com/ardetrick/testcontainers-ory-hydra
The OryHydraDockerComposeContainer is a Testcontainer extension designed for the Ory Hydra OAuth 2.0 and OpenID Connect provider. It allows you to quickly integrate and test Ory Hydra functionalities in Java applications using Docker Compose.
https://github.com/ardetrick/testcontainers-ory-hydra
java oauth2 ory ory-hydra testcontainers testcontainers-java testing
Last synced: 2 months ago
JSON representation
The OryHydraDockerComposeContainer is a Testcontainer extension designed for the Ory Hydra OAuth 2.0 and OpenID Connect provider. It allows you to quickly integrate and test Ory Hydra functionalities in Java applications using Docker Compose.
- Host: GitHub
- URL: https://github.com/ardetrick/testcontainers-ory-hydra
- Owner: ardetrick
- License: mit
- Created: 2023-09-09T04:03:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-31T01:19:48.000Z (3 months ago)
- Last Synced: 2025-01-31T02:25:04.817Z (3 months ago)
- Topics: java, oauth2, ory, ory-hydra, testcontainers, testcontainers-java, testing
- Language: Java
- Homepage:
- Size: 310 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
- awesome-ory - Ory Hydra Testcontainer
- awesome-ory - Ory Hydra Testcontainer
README
= Ory Hydra Testcontainer
The `OryHydraDockerComposeContainer` is a Testcontainer extension designed for the Ory Hydra OAuth 2.0 and OpenID Connect provider. It allows you to quickly integrate and test Ory Hydra functionalities in Java applications using Docker Compose.
== Prerequisites
* Docker installed and running.
* Java JDK 8 or later.== Features
* Automatic setup of Ory Hydra's admin and public ports.
* Convenient methods to fetch base URIs for both the admin and public endpoints.
* Easy retrieval of OAuth2 Authorization and JWKS URIs.
* Customizable through a builder pattern, allowing for the configuration of Docker Compose files and environment variables.== Usage
=== Dependency
First, include the `OryHydraDockerComposeContainer` in your project's `build.gradle`:
[source,groovy]
----
dependencies {
testImplementation 'com.ardetrick.testcontainers:ory-hydra-testcontainer:0.0.1'
}
----=== Test Usage
[source,java]
----
import com.ardetrick.testcontainers.OryHydraDockerComposeContainer;public class HydraIntegrationTest {
OryHydraDockerComposeContainer> dockerComposeEnvironment;
@BeforeEach
public void beforeEachTest() {
dockerComposeEnvironment = OryHydraDockerComposeContainer.builder()
.dockerComposeFile(new File("path_to_docker_compose.yml"))
.urlsLogin("http://example.com/login")
.urlsConsent("http://example.com/consent")
.urlsSelfIssuer("http://example.com/")
.start();
}@Test
public void testOAuthFlow() {
// Use the helper methods like hydra.getOAuth2AuthUri() for your tests.
// Your test logic here...
}}
----== Configuration Options
Using the `Builder` class, you can configure:
* `dockerComposeFile(File)`: Specify the Docker Compose file to use.
* `urlsLogin(String)`: Set the login URL.
* `urlsConsent(String)`: Set the consent URL.
* `urlsSelfIssuer(String)`: Set the self-issuer URL.== Building
To build from the source using the Gradle Wrapper:
----
$ git clone https://github.com/ardetrick/ory-hydra-testcontainer.git
$ cd ory-hydra-testcontainer
$ ./gradlew clean build
----For Windows:
----
$ git clone https://github.com/ardetrick/ory-hydra-testcontainer.git
$ cd ory-hydra-testcontainer
$ gradlew.bat clean build
----== Contributing
We welcome contributions! Please submit pull requests or open issues for feedback.
This project is licensed under the MIT License. See the `LICENSE` file for details.
== Contact
For questions or feedback, open an issue on the GitHub repository.