Skip to content

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.

License

Notifications You must be signed in to change notification settings

ardetrick/testcontainers-ory-hydra

Repository files navigation

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:

dependencies {
    testImplementation 'com.ardetrick.testcontainers:ory-hydra-testcontainer:0.0.1'
}

Test Usage

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.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages