An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

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.