github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/test_files/cloud.bats (about) 1 load "$LIB_BATS_ASSERT/load.bash" 2 load "$LIB_BATS_SUPPORT/load.bash" 3 4 # These set of tests are skipped locally 5 # To run these tests locally set the SPIPETOOLS_PG_CONN_STRING and SPIPETOOLS_TOKEN env vars. 6 # These tests will be skipped locally unless both of the above env vars are set. 7 8 @test "connect to cloud workspace - passing the postgres connection string to workspace-database arg" { 9 # run steampipe query and fetch an account from the cloud workspace 10 run steampipe query "select account_aliases from all_aws.aws_account where account_id='632902152528'" --workspace-database $SPIPETOOLS_PG_CONN_STRING --output json 11 echo $output 12 13 # fetch the value of account_alias to compare 14 op=$(echo $output | jq '.rows[0].account_aliases[0]') 15 echo $op 16 17 # check if values match 18 assert_equal "$op" "\"nagraj-aaa\"" 19 } 20 21 @test "connect to cloud workspace - passing the cloud-token arg and the workspace name to workspace-database arg" { 22 # run steampipe query and fetch an account from the cloud workspace 23 run steampipe query "select account_aliases from all_aws.aws_account where account_id='632902152528'" --pipes-token $SPIPETOOLS_TOKEN --workspace-database turbot-ops/clitesting --output json 24 echo $output 25 26 # fetch the value of account_alias to compare 27 op=$(echo $output | jq '.rows[0].account_aliases[0]') 28 echo $op 29 30 # check if values match 31 assert_equal "$op" "\"nagraj-aaa\"" 32 } 33 34 @test "connect to cloud workspace - passing the cloud-host arg, the cloud-token arg and the workspace name to workspace-database arg" { 35 # run steampipe query and fetch an account from the cloud workspace 36 run steampipe query "select account_aliases from all_aws.aws_account where account_id='632902152528'" --pipes-host "pipes.turbot.com" --pipes-token $SPIPETOOLS_TOKEN --workspace-database turbot-ops/clitesting --output json 37 echo $output 38 39 # fetch the value of account_alias to compare 40 op=$(echo $output | jq '.rows[0].account_aliases[0]') 41 echo $op 42 43 # check if values match 44 assert_equal "$op" "\"nagraj-aaa\"" 45 } 46 47 @test "connect to cloud workspace(FAILED TO CONNECT) - passing wrong postgres connection string to workspace-database arg" { 48 # run steampipe query using wrong connection string 49 run steampipe query "select account_aliases from all_aws.aws_account where account_id='632902152528'" --workspace-database abcd/efgh --output json 50 echo $output 51 52 # check the error message 53 assert_output --partial 'Error: Not authenticated for Turbot Pipes.' 54 } 55 56 @test "connect to cloud workspace - passing the workspace name to workspace-database arg (unsetting ENV - the token should get picked from tptt file)" { 57 # write the pipes.turbot.com.tptt file in internal 58 # write the token to the file 59 file_name=$STEAMPIPE_INSTALL_DIR/internal/pipes.turbot.com.tptt 60 echo -ne $SPIPETOOLS_TOKEN > $file_name 61 cat $file_name 62 63 # this step will create snapshots in the workspace - but that's ok 64 # workspaces expire snapshots anyway 65 run steampipe query "select 1" --share 66 echo $output 67 68 assert_success 69 } 70 71 function teardown_file() { 72 # list running processes 73 ps -ef | grep steampipe 74 75 # check if any processes are running 76 num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') 77 assert_equal $num 0 78 } 79 80 function setup() { 81 if [[ -z "${SPIPETOOLS_PG_CONN_STRING}" || -z "${SPIPETOOLS_TOKEN}" ]]; then 82 skip 83 else 84 echo "Both SPIPETOOLS_PG_CONN_STRING and SPIPETOOLS_TOKEN are set..." 85 fi 86 }