Skip to content

Commit 1ef4a4a

Browse files
committed
backport of commit 63e1ccf
1 parent e883780 commit 1ef4a4a

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

testing/internal/e2e/tests/base_with_worker/target_tcp_worker_connect_ssh_test.go

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func TestCliTcpTargetWorkerConnectTarget(t *testing.T) {
308308
require.Equal(t, c.TargetAddress, strings.TrimSpace(string(output.Stdout)))
309309
t.Log("Successfully connected to target with new filter")
310310

311-
// Remove tags
311+
// Remove API tags
312312
output = e2e.RunCommand(ctx, "boundary",
313313
e2e.WithArgs(
314314
"workers", "remove-worker-tags",
@@ -330,4 +330,71 @@ func TestCliTcpTargetWorkerConnectTarget(t *testing.T) {
330330
require.NoError(t, err)
331331
require.NotContains(t, workerReadResult.Item.CanonicalTags["k"], "v")
332332
require.NotContains(t, workerReadResult.Item.CanonicalTags["a"], "v")
333+
334+
// Add an API tag that's the same as a config tag
335+
t.Log("Adding API tag that's the same as a config tag...")
336+
require.NoError(t, err)
337+
output = e2e.RunCommand(ctx, "boundary",
338+
e2e.WithArgs(
339+
"workers", "add-worker-tags",
340+
"-id", workerList[0].Id,
341+
"-tag", fmt.Sprintf("%s=%s", "type", c.WorkerTagEgress),
342+
),
343+
)
344+
require.NoError(t, output.Err, string(output.Stderr))
345+
t.Cleanup(func() {
346+
_ = e2e.RunCommand(ctx, "boundary",
347+
e2e.WithArgs(
348+
"workers", "remove-worker-tags",
349+
"-id", workerList[0].Id,
350+
"-tag", fmt.Sprintf("%s=%s", "type", c.WorkerTagEgress),
351+
),
352+
)
353+
})
354+
output = e2e.RunCommand(ctx, "boundary",
355+
e2e.WithArgs(
356+
"targets", "update", "tcp",
357+
"-id", targetId,
358+
"-egress-worker-filter", fmt.Sprintf(`"%s" in "/tags/type"`, c.WorkerTagEgress),
359+
),
360+
)
361+
require.NoError(t, output.Err, string(output.Stderr))
362+
output = e2e.RunCommand(ctx, "boundary",
363+
e2e.WithArgs(
364+
"connect", "ssh",
365+
"-target-id", targetId,
366+
"-remote-command", "hostname -i",
367+
"--",
368+
"-o", "UserKnownHostsFile=/dev/null",
369+
"-o", "StrictHostKeyChecking=no",
370+
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
371+
),
372+
)
373+
require.NoError(t, output.Err, string(output.Stderr))
374+
require.Equal(t, c.TargetAddress, strings.TrimSpace(string(output.Stdout)))
375+
t.Log("Successfully connected to target")
376+
377+
// Remove API tag
378+
output = e2e.RunCommand(ctx, "boundary",
379+
e2e.WithArgs(
380+
"workers", "remove-worker-tags",
381+
"-id", workerList[0].Id,
382+
"-tag", fmt.Sprintf("%s=%s", "type", c.WorkerTagEgress),
383+
),
384+
)
385+
require.NoError(t, output.Err, string(output.Stderr))
386+
output = e2e.RunCommand(ctx, "boundary",
387+
e2e.WithArgs(
388+
"connect", "ssh",
389+
"-target-id", targetId,
390+
"-remote-command", "hostname -i",
391+
"--",
392+
"-o", "UserKnownHostsFile=/dev/null",
393+
"-o", "StrictHostKeyChecking=no",
394+
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
395+
),
396+
)
397+
require.NoError(t, output.Err, string(output.Stderr))
398+
require.Equal(t, c.TargetAddress, strings.TrimSpace(string(output.Stdout)))
399+
t.Log("Successfully connected to target")
333400
}

0 commit comments

Comments
 (0)