Skip to content

Commit 06ab43c

Browse files
committed
feat: log the demo url once dev-time startup completes
1 parent df3f0e8 commit 06ab43c

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

reference-app/src/test/java/com/ardetrick/oryhydrareference/TestOryHydraReferenceApplication.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
import com.ardetrick.testcontainers.OryHydraContainer;
44
import java.util.List;
5+
import lombok.extern.slf4j.Slf4j;
56
import org.springframework.boot.SpringApplication;
7+
import org.springframework.boot.context.event.ApplicationReadyEvent;
68
import org.springframework.boot.test.context.TestConfiguration;
9+
import org.springframework.context.ApplicationListener;
710
import org.springframework.context.annotation.Bean;
811

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

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

28+
@Slf4j
2529
@TestConfiguration(proxyBeanMethods = false)
2630
static class LocalHydraConfiguration {
2731

32+
// End the startup logs with the link to click — the convention of one-command dev servers.
33+
// Dev-time only: the production app cannot know its public URL, but this configuration
34+
// already pins every port, so it can.
35+
@Bean
36+
ApplicationListener<ApplicationReadyEvent> readyMessage() {
37+
return event ->
38+
log.info(
39+
"Demo ready — open http://localhost:8080 and log in with foo@bar.com / password");
40+
}
41+
2842
// Hydra's host ports are pinned to the image defaults here, so Hydra's dev-mode issuer
2943
// (http://localhost:4444), the app's default admin base path (http://localhost:4445), and
3044
// the hardcoded links on /demo all line up with no configuration. Unlike the functional

0 commit comments

Comments
 (0)