Skip to content

Commit 90b6da2

Browse files
committed
fix(e2e): start Xvfb in CI, use container.Host for RDP resource
Start Xvfb and export DISPLAY in CI so xfreerdp3 runs directly without the xvfb-run shell wrapper. Use container.Host(ctx) for the resource host instead of getOutboundIP, matching the pattern used by SSH, Postgres and Redis tests. Increase xfreerdp timeout to 60s.
1 parent 95a21fe commit 90b6da2

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/run-cli-e2e-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ jobs:
100100
- name: Build the CLI
101101
run: CGO_ENABLED=1 go build -tags rdp -o infisical-cli
102102
- name: Install RDP test dependencies
103-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends freerdp3-x11 xvfb
103+
run: |
104+
sudo apt-get update && sudo apt-get install -y --no-install-recommends freerdp3-x11 xvfb
105+
Xvfb :99 -screen 0 1024x768x24 &
106+
echo "DISPLAY=:99" >> "$GITHUB_ENV"
104107
- name: Checkout infisical repo
105108
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
106109
with:

e2e/pam/rdp_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

6163
func 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

Comments
 (0)