Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

import com.ardetrick.testcontainers.OryHydraContainer;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;

/**
* Development-time entry point: starts the app together with a real Ory Hydra container and a
* seeded demo client, so running locally is one command with nothing to install but Docker.
*
* <p>Run {@code ./gradlew bootTestRun}, then open <a
* href="http://localhost:8080/demo">http://localhost:8080/demo</a> and log in with {@code
* foo@bar.com} / {@code password}.
* href="http://localhost:8080">http://localhost:8080</a> and log in with {@code foo@bar.com} /
* {@code password}.
*/
public class TestOryHydraReferenceApplication {

Expand All @@ -22,9 +25,20 @@ public static void main(String[] args) {
.run(args);
}

@Slf4j
@TestConfiguration(proxyBeanMethods = false)
static class LocalHydraConfiguration {

// End the startup logs with the link to click — the convention of one-command dev servers.
// Dev-time only: the production app cannot know its public URL, but this configuration
// already pins every port, so it can.
@Bean
ApplicationListener<ApplicationReadyEvent> readyMessage() {
return event ->
log.info(
"Demo ready — open http://localhost:8080 and log in with foo@bar.com / password");
}

// Hydra's host ports are pinned to the image defaults here, so Hydra's dev-mode issuer
// (http://localhost:4444), the app's default admin base path (http://localhost:4445), and
// the hardcoded links on /demo all line up with no configuration. Unlike the functional
Expand Down