@@ -31,7 +31,7 @@ const (
3131 rdpPassword = "testpass"
3232)
3333
34- func startRDPContainer (t * testing.T , ctx context.Context ) (testcontainers.Container , int ) {
34+ func startRDPContainer (t * testing.T , ctx context.Context ) (testcontainers.Container , string , int ) {
3535 ctr , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
3636 ContainerRequest : testcontainers.ContainerRequest {
3737 FromDockerfile : testcontainers.FromDockerfile {
@@ -53,9 +53,11 @@ func startRDPContainer(t *testing.T, ctx context.Context) (testcontainers.Contai
5353 }
5454 })
5555
56+ host , err := ctr .Host (ctx )
57+ require .NoError (t , err )
5658 port , err := ctr .MappedPort (ctx , "3389" )
5759 require .NoError (t , err )
58- return ctr , port .Int ()
60+ return ctr , host , port .Int ()
5961}
6062
6163func setupRecordingConfig (t * testing.T , ctx context.Context , infra * PAMTestInfra ) {
@@ -245,10 +247,9 @@ func TestPAM_RDP(t *testing.T) {
245247 setupRecordingConfig (t , ctx , infra )
246248
247249 rdpBinary := findFreeRDPBinary (t )
248- resourceHost := getOutboundIP (t )
249250
250251 t .Run ("connection" , func (t * testing.T ) {
251- _ , rdpPort := startRDPContainer (t , ctx )
252+ _ , resourceHost , rdpPort := startRDPContainer (t , ctx )
252253 slog .Info ("RDP container started" , "host" , resourceHost , "port" , rdpPort )
253254
254255 resourceName := "rdp-connection-resource"
@@ -258,13 +259,13 @@ func TestPAM_RDP(t *testing.T) {
258259 proxyPort := helpers .GetFreePort ()
259260 startRDPProxy (t , ctx , infra , resourceName , "rdp-connection-account" , "5m" , proxyPort )
260261
261- err := authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 30 * time .Second )
262+ err := authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 60 * time .Second )
262263 require .NoError (t , err , "NLA authentication through proxy should succeed" )
263264 slog .Info ("RDP connection test passed" )
264265 })
265266
266267 t .Run ("bad-credentials" , func (t * testing.T ) {
267- _ , rdpPort := startRDPContainer (t , ctx )
268+ _ , resourceHost , rdpPort := startRDPContainer (t , ctx )
268269
269270 resourceName := "rdp-badcreds-resource"
270271 resourceId := createRDPPamResource (t , ctx , infra , resourceName , resourceHost , rdpPort )
@@ -273,13 +274,13 @@ func TestPAM_RDP(t *testing.T) {
273274 proxyPort := helpers .GetFreePort ()
274275 startRDPProxy (t , ctx , infra , resourceName , "rdp-badcreds-account" , "5m" , proxyPort )
275276
276- err := authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 30 * time .Second )
277+ err := authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 60 * time .Second )
277278 require .Error (t , err , "NLA authentication should fail with bad credentials" )
278279 slog .Info ("Bad credentials test passed" , "error" , err )
279280 })
280281
281282 t .Run ("unreachable-target" , func (t * testing.T ) {
282- ctr , rdpPort := startRDPContainer (t , ctx )
283+ ctr , resourceHost , rdpPort := startRDPContainer (t , ctx )
283284
284285 resourceName := "rdp-unreachable-resource"
285286 resourceId := createRDPPamResource (t , ctx , infra , resourceName , resourceHost , rdpPort )
@@ -290,13 +291,13 @@ func TestPAM_RDP(t *testing.T) {
290291 proxyPort := helpers .GetFreePort ()
291292 startRDPProxy (t , ctx , infra , resourceName , "rdp-unreachable-account" , "5m" , proxyPort )
292293
293- err := authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 30 * time .Second )
294+ err := authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 60 * time .Second )
294295 require .Error (t , err , "NLA authentication should fail when target is down" )
295296 slog .Info ("Unreachable target test passed" , "error" , err )
296297 })
297298
298299 t .Run ("concurrent-connections" , func (t * testing.T ) {
299- _ , rdpPort := startRDPContainer (t , ctx )
300+ _ , resourceHost , rdpPort := startRDPContainer (t , ctx )
300301
301302 resourceName := "rdp-concurrent-resource"
302303 resourceId := createRDPPamResource (t , ctx , infra , resourceName , resourceHost , rdpPort )
@@ -313,7 +314,7 @@ func TestPAM_RDP(t *testing.T) {
313314 wg .Add (1 )
314315 go func (idx int ) {
315316 defer wg .Done ()
316- errs [idx ] = authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 30 * time .Second )
317+ errs [idx ] = authOnlyFreeRDP (t , ctx , rdpBinary , proxyPort , 60 * time .Second )
317318 }(i )
318319 }
319320
0 commit comments