@@ -19,8 +19,6 @@ import (
1919const (
2020 // OryHydraImage is the Ory Hydra Image.
2121 OryHydraImage = "oryd/hydra:latest"
22- // HydraPort is the default port for Hydra.
23- HydraPort = "4445"
2422
2523 HydraConfiguration = `
2624## ORY Hydra Configuration
@@ -73,10 +71,8 @@ func New() definition.TestResource {
7371func NewWithOpts (configuration string , containerOpts ... definition.ContainerOption ) definition.TestResource {
7472 opts := definition.ContainerOpts {
7573 ImageName : OryHydraImage ,
76- Port : HydraPort ,
74+ Ports : [] string { "4444" , "4445" } ,
7775 NetworkAliases : []string {"hydra" , "auth-hydra" },
78- UseHostMode : false ,
79- EnableLogging : true ,
8076 }
8177 opts .Setup (containerOpts ... )
8278
@@ -135,17 +131,17 @@ func (d *hydraDependancy) migrateContainer(
135131}
136132
137133func (d * hydraDependancy ) Setup (ctx context.Context , ntwk * testcontainers.DockerNetwork ) error {
138- if len (d .opts .Dependancies ) == 0 || ! d .opts .Dependancies [0 ].GetDS ().IsDB () {
134+ if len (d .opts .Dependencies ) == 0 || ! d .opts .Dependencies [0 ].GetDS ().IsDB () {
139135 return errors .New ("no Database dependencies was supplied" )
140136 }
141137
142- databaseURL := d .opts .Dependancies [0 ].GetInternalDS ().String ()
138+ databaseURL := d .opts .Dependencies [0 ].GetInternalDS ().String ()
143139 err := d .migrateContainer (ctx , ntwk , databaseURL )
144140 if err != nil {
145141 return err
146142 }
147143
148- hydraPort , err := nat .NewPort ("tcp" , d .opts .Port )
144+ adminPort , err := nat .NewPort ("tcp" , d .opts .Ports [ 1 ] )
149145 if err != nil {
150146 return err
151147 }
@@ -164,15 +160,11 @@ func (d *hydraDependancy) Setup(ctx context.Context, ntwk *testcontainers.Docker
164160 FileMode : definition .ContainerFileMode ,
165161 },
166162 },
167- WaitingFor : wait .ForHTTP ("/health/ready" ).WithPort (hydraPort ),
163+ WaitingFor : wait .ForHTTP ("/health/ready" ).WithPort (adminPort ),
168164 }
169165
170166 d .opts .Configure (ctx , ntwk , & containerRequest )
171167
172- if ! d .opts .UseHostMode {
173- containerRequest .ExposedPorts = []string {fmt .Sprintf ("%s/tcp" , d .opts .Port ), "4444/tcp" }
174- }
175-
176168 hydraContainer , err := testcontainers .GenericContainer (ctx ,
177169 testcontainers.GenericContainerRequest {
178170 ContainerRequest : containerRequest ,
@@ -183,7 +175,7 @@ func (d *hydraDependancy) Setup(ctx context.Context, ntwk *testcontainers.Docker
183175 return fmt .Errorf ("failed to start hydraContainer: %w" , err )
184176 }
185177
186- port , err := hydraContainer .MappedPort (ctx , hydraPort )
178+ port , err := hydraContainer .MappedPort (ctx , adminPort )
187179 if err != nil {
188180 return fmt .Errorf ("failed to get connection string for hydraContainer: %w" , err )
189181 }
@@ -200,7 +192,7 @@ func (d *hydraDependancy) Setup(ctx context.Context, ntwk *testcontainers.Docker
200192 return fmt .Errorf ("failed to get internal host ip for hydraContainer: %w" , err )
201193 }
202194 d .internalConn = frame .DataSource (
203- fmt .Sprintf ("http://%s" , net .JoinHostPort (internalIP , d . opts . Port )),
195+ fmt .Sprintf ("http://%s" , net .JoinHostPort (internalIP , adminPort . Port () )),
204196 )
205197
206198 d .container = hydraContainer
0 commit comments