tests: add scopes CLI tests (#645)
This commit is contained in:
1 parent
70e696a446
commit
3c1670c0d0
4 files changed
+102
-1
No files matched your search
@@ -10,6 +10,7 @@ export DEFAULT_HOST_SET='hsst_1234567890'
|
||||
export DEFAULT_HOST_CATALOG='hcst_1234567890'
|
||||
export DEFAULT_HOST='hst_1234567890'
|
||||
export DEFAULT_USER='u_1234567890'
|
||||
export DEFAULT_GLOBAL='global'
|
||||
|
||||
function strip() {
|
||||
echo "$1" | tr -d '"'
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
function create_scope() {
|
||||
local parent=$1
|
||||
local name=$2
|
||||
echo "name $name scope $parent"
|
||||
boundary scopes create -name $name -scope-id $parent
|
||||
}
|
||||
|
||||
function read_scope() {
|
||||
local sid=$1
|
||||
|
||||
boundary scopes read -id $sid -format json
|
||||
}
|
||||
|
||||
function delete_scope() {
|
||||
local sid=$1
|
||||
|
||||
boundary scopes delete -id $sid
|
||||
}
|
||||
|
||||
function list_scopes() {
|
||||
boundary scopes list -scope-id $1 -format json
|
||||
}
|
||||
|
||||
function scope_id() {
|
||||
local name=$1
|
||||
local sid=$2
|
||||
|
||||
strip $(list_scopes $sid | jq -c ".[] | select(.name | contains(\"$name\")) | .[\"id\"]")
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load _auth
|
||||
load _scopes
|
||||
load _helpers
|
||||
|
||||
export NEW_PROJECT='test_project'
|
||||
export NEW_ORG='test_org'
|
||||
|
||||
@test "boundary/login: can login as default user" {
|
||||
run login $DEFAULT_LOGIN
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can create $NEW_ORG organization level scope" {
|
||||
run create_scope $DEFAULT_GLOBAL $NEW_ORG
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can read $NEW_ORG organization level scope" {
|
||||
local sid=$(scope_id $NEW_ORG $DEFAULT_GLOBAL)
|
||||
run read_scope $sid
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can create $NEW_PROJECT project level scope" {
|
||||
local parent=$(scope_id $NEW_ORG $DEFAULT_GLOBAL)
|
||||
run create_scope $parent $NEW_PROJECT
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can read $NEW_PROJECT project level scope" {
|
||||
local parent=$(scope_id $NEW_ORG $DEFAULT_GLOBAL)
|
||||
local sid=$(scope_id $NEW_PROJECT $parent)
|
||||
run read_scope $sid
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can delete $NEW_PROJECT project level scope" {
|
||||
local parent=$(scope_id $NEW_ORG $DEFAULT_GLOBAL)
|
||||
local sid=$(scope_id $NEW_PROJECT $parent)
|
||||
run delete_scope $sid
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can not read deleted $NEW_PROJECT project level scope" {
|
||||
local parent=$(scope_id $NEW_ORG $DEFAULT_GLOBAL)
|
||||
local sid=$(scope_id $NEW_PROJECT $parent)
|
||||
run read_scope $sid
|
||||
echo "$output"
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can delete $NEW_ORG organization level scope" {
|
||||
local sid=$(scope_id $NEW_ORG $DEFAULT_GLOBAL)
|
||||
run delete_scope $sid
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/scopes: can not read deleted $NEW_ORG organization level scope" {
|
||||
local sid=$(scope_id $NEW_PROJECT $DEFAULT_GLOBAL)
|
||||
run read_scope $sid
|
||||
echo "$output"
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
@@ -34,7 +34,7 @@ load _helpers
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "boundary/target: default user can connect to created target" {
|
||||
@test "boundary/target/connect: default user can connect to created target" {
|
||||
local id=$(target_id $DEFAULT_P_ID $TGT_NAME)
|
||||
run connect_nc $id
|
||||
echo "connecting to $id: $output"
|
||||
|
||||
Reference in new issue
Block a user