Files
threshold/internal/tests/cli/boundary/roles.bats
T
9169c6bacb [QTI-220] Add infrastructure integration testing (#2282)
* [QTI-275] Add infrastructure integration testing

On pull requests that originate from branches of the `hashicorp/boundary`
repo, we now conditionally dispatch infrastructure integration tests using
the Enos framework. The `integration` Enos scenario includes two `builder`
variants which allow developers or CI to deploy a Boundary cluster in AWS
using either a local `boundary` install bundle or that which is produced
in the `build` workflow for CRT. The `test` variants determine which type
of infrastructure integration test to run. At present those options are
`cli_ui` (Bats CLI tests) or `smoke` (creates target instances and a
target host catalog and verifies that `boundary` works).

In addition to the new workflow and quality scenarios, we simplified the
some `build` workflow steps and added Go module caching to speed up the
build pipeline.

See the [enos/README.md](https://github.com/hashicorp/boundary/blob/main/enos/README.md)
for a detailed explanation on how to configure and execute Enos scenarios
from your machine.

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Rebecca Willett <rwillett@hashicorp.com>
Co-authored-by: Josh Branch <jbrand@hashicorp.com>
2022-07-28 14:48:51 -06:00

134 lines
3.5 KiB
Bash

#!/usr/bin/env bats
load _accounts
load _auth
load _roles
load _helpers
export NEW_ROLE='test'
export NEW_GRANT='id=*;type=*;actions=create,read,update,delete,list'
@test "boundary/login: can login as default principal" {
run login $DEFAULT_LOGIN
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/roles: can add $NEW_ROLE role to global scope granting rights in default org scope" {
run create_role 'global' $NEW_ROLE $DEFAULT_O_ID
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/roles: can not add already created $NEW_ROLE role" {
run create_role 'global' $NEW_ROLE $DEFAULT_O_ID
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/roles: can read $NEW_ROLE role" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run read_role $rid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/roles: the $NEW_ROLE role contains default authorized-actions" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
local out=$(read_role $rid)
run has_default_role_actions "$out"
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/role/add-principals: can associate $NEW_ROLE role with default principal" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run assoc_role_principal $DEFAULT_USER $rid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/role/add-principals: $NEW_ROLE role contains default principal" {
if [ "$SKIP_FAILING_TESTS_IN_CI" == "true" ]; then
skip
fi
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run role_has_principal_id $rid $DEFAULT_USER
echo "$output"
diag "$output"
[ "$status" -eq 0 ]
}
@test "boundary/role/remove-principals: can remove default principal from $NEW_ROLE role" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run remove_role_principal $DEFAULT_USER $rid
if [ "$SKIP_FAILING_TESTS_IN_CI" == "true" ]; then
skip
fi
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/role/remove-principals: $NEW_ROLE role no longer contains default principal" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run role_has_principal_id $rid $DEFAULT_USER
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/role/add-grants: can associate $NEW_ROLE role with $NEW_GRANT grant" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run assoc_role_grant $NEW_GRANT $rid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/role/add-grantss: $NEW_ROLE role contains $NEW_GRANT grant" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run role_has_grant $rid $NEW_GRANT
if [ "$SKIP_FAILING_TESTS_IN_CI" == "true" ]; then
skip
fi
echo "$output"
diag "$output"
[ "$status" -eq 0 ]
}
@test "boundary/role/remove-grants: can remove $NEW_GRANT grant from $NEW_ROLE role" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run remove_role_grant $NEW_GRANT $rid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/role/remove-grants: $NEW_ROLE role no longer contains $NEW_GRANT grant" {
if [ "$SKIP_FAILING_TESTS_IN_CI" == "true" ]; then
skip
fi
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run role_has_grant $rid $NEW_GRANT
echo "$output"
diag "$output"
[ "$status" -eq 1 ]
}
@test "boundary/role: can delete $NEW_ROLE role" {
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run delete_role $rid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@test "boundary/roles: can not read deleted $NEW_ROLE role" {
if [ "$SKIP_FAILING_TESTS_IN_CI" == "true" ]; then
skip
fi
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run read_role $rid
echo "$output"
diag "$output"
[ "$status" -eq 1 ]
}