test(bats): Fix flaky connect helper methods (#6535)

* test(bats): Fix flaky connect helper methods

* test(bats): Add more debug

* chore: Fix copywrite headers
pull/6580/head
Michael Li 1 month ago committed by GitHub
parent 1ba947d731
commit 4eec5ce0e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -98,6 +98,7 @@ jobs:
echo "vault version:"
vault version
- name: Run cli bats tests
timeout-minutes: 30
run: |
export VAULT_ADDR=http://127.0.0.1:8200
export VAULT_TOKEN=boundarytok

@ -1,5 +1,5 @@
#!/usr/bin/with-contenv bash
# Copyright IBM Corp. 2020, 2025
# Copyright IBM Corp. 2020, 2026
# SPDX-License-Identifier: BUSL-1.1
chown 1000:1000 /etc/ssh/host-key

@ -4,18 +4,18 @@
function connect_nc() {
local id=$1
# Note: When this command returns, the session immediately goes into a "canceling" state
echo "foo" | boundary connect -exec nc -target-id $id -- {{boundary.ip}} {{boundary.port}}
echo "SSH-2.0-Test" | boundary connect -exec nc -target-id $id -- -v -w 5 {{boundary.ip}} {{boundary.port}}
}
function connect_alias() {
local alias=$1
# Note: When this command returns, the session immediately goes into a "canceling" state
echo "foo" | boundary connect $alias -exec nc -- {{boundary.ip}} {{boundary.port}}
echo "SSH-2.0-Test" | boundary connect $alias -exec nc -- -v -w 5 {{boundary.ip}} {{boundary.port}}
}
function connect_alias_with_host_id() {
local alias=$1
local hostid=$2
# Note: When this command returns, the session immediately goes into a "canceling" state
echo "foo" | boundary connect $alias -host-id $hostid -exec nc -- {{boundary.ip}} {{boundary.port}}
echo "SSH-2.0-Test" | boundary connect $alias -host-id $hostid -exec nc -- -v -w 5 {{boundary.ip}} {{boundary.port}}
}

@ -127,6 +127,8 @@ export NEW_HOST="host_for_alias_test"
@test "boundary/alias: admin user cannot connect using an alias configured with host id passing in different host id" {
local new_host_id=$(host_id NEW_HOST $DEFAULT_HOST_CATALOG)
run connect_alias_with_host_id $ALIAS_VALUE $new_host_id
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 1 ]
}

@ -11,13 +11,13 @@ load _helpers
[ "$status" -eq 0 ]
run connect_nc $DEFAULT_TARGET
echo "connecting to $id: $output"
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
# Run twice so we have two values for later testing
run connect_nc $DEFAULT_TARGET
echo "connecting to $id: $output"
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}
@ -28,13 +28,13 @@ load _helpers
[ "$status" -eq 0 ]
run connect_nc $DEFAULT_TARGET
echo "connecting to $id: $output"
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
# Run twice so we have two values for later testing
run connect_nc $DEFAULT_TARGET
echo "connecting to $id: $output"
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}

@ -14,6 +14,8 @@ load _target_host_sources
@test "boundary/target/connect: admin user can connect to default target" {
run connect_nc $DEFAULT_TARGET
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}
@ -29,7 +31,7 @@ load _target_host_sources
@test "boundary/target/connect: unpriv user can connect to default target" {
run connect_nc $DEFAULT_TARGET
echo "connecting to $id: $output"
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}
@ -88,7 +90,7 @@ load _target_host_sources
@test "boundary/target/connect: default user can connect to created target" {
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
run connect_nc $id
echo "connecting to $id: $output"
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}

@ -23,6 +23,8 @@ export ALIAS_TGT_NAME='test-alias-target'
@test "boundary/alias/target: admin user can connect to default target using alias" {
run connect_alias $ALIAS_VALUE
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}
@ -38,6 +40,8 @@ export ALIAS_TGT_NAME='test-alias-target'
@test "boundary/alias/target: unpriv user can connect to default target" {
run connect_alias $ALIAS_VALUE
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}
@ -85,7 +89,8 @@ export ALIAS_TGT_NAME='test-alias-target'
@test "boundary/alias/target: default user can connect to created target using alias" {
run connect_alias $ALIAS_VALUE
echo "connecting to $ALIAS_VALUE: $output"
echo "connecting: $output"
echo "status: $status"
[ "$status" -eq 0 ]
}
@ -136,4 +141,4 @@ export ALIAS_TGT_NAME='test-alias-target'
run delete_alias $aid
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
}

@ -1,4 +1,4 @@
// Copyright IBM Corp. 2020, 2025
// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package boundary

Loading…
Cancel
Save