2020-10-12 10:26:26 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
|
|
load _auth
|
|
|
|
|
load _connect
|
|
|
|
|
load _targets
|
|
|
|
|
load _helpers
|
2023-03-24 17:38:39 -04:00
|
|
|
load _target_host_sources
|
2020-10-12 10:26:26 -07:00
|
|
|
|
|
|
|
|
|
2021-02-11 13:14:18 -05:00
|
|
|
@test "boundary/login: can login as admin user" {
|
2020-10-12 20:57:57 -07:00
|
|
|
run login $DEFAULT_LOGIN
|
2020-10-12 10:26:26 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 13:14:18 -05:00
|
|
|
@test "boundary/target/connect: admin user can connect to default target" {
|
2020-10-13 07:41:14 -07:00
|
|
|
run connect_nc $DEFAULT_TARGET
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 13:14:18 -05:00
|
|
|
@test "boundary/target: admin user can read default target" {
|
|
|
|
|
run read_target $DEFAULT_TARGET
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/login: can login as unpriv user" {
|
|
|
|
|
run login $DEFAULT_UNPRIVILEGED_LOGIN
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/target/connect: unpriv user can connect to default target" {
|
|
|
|
|
run connect_nc $DEFAULT_TARGET
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-23 14:33:09 -05:00
|
|
|
@test "boundary/target: unpriv user can read default target" {
|
2021-02-11 13:14:18 -05:00
|
|
|
run read_target $DEFAULT_TARGET
|
2024-01-23 14:33:09 -05:00
|
|
|
[ "$status" -eq 0 ]
|
2021-02-11 13:14:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/login: login back in as admin user" {
|
|
|
|
|
run login $DEFAULT_LOGIN
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/target: admin user can create target" {
|
2020-10-12 10:26:26 -07:00
|
|
|
run create_tcp_target $DEFAULT_P_ID 22 $TGT_NAME
|
2022-07-28 14:48:51 -06:00
|
|
|
echo $output
|
2020-10-12 10:26:26 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 13:14:18 -05:00
|
|
|
@test "boundary/target: admin user can not create already created target" {
|
2020-10-12 10:26:26 -07:00
|
|
|
run create_tcp_target $DEFAULT_P_ID 22 $TGT_NAME
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 13:14:18 -05:00
|
|
|
@test "boundary/target: admin user can read created target" {
|
|
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
2020-10-12 10:26:26 -07:00
|
|
|
run read_target $id
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-29 08:04:46 -08:00
|
|
|
@test "boundary/target: the $TGT_NAME target contains default authorized-actions" {
|
2021-02-11 13:14:18 -05:00
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
2021-01-29 08:04:46 -08:00
|
|
|
local out=$(read_target $id)
|
|
|
|
|
|
2022-07-28 14:48:51 -06:00
|
|
|
run has_default_target_actions "$out"
|
2021-01-29 08:04:46 -08:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 13:14:18 -05:00
|
|
|
@test "boundary/target: admin user can add default host set to created target" {
|
|
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
2023-03-24 17:38:39 -04:00
|
|
|
run add_target_host_sources $id $DEFAULT_HOST_SET
|
2020-10-12 10:26:26 -07:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-13 07:41:14 -07:00
|
|
|
@test "boundary/target: created target has default host set" {
|
2021-02-11 13:14:18 -05:00
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
2023-03-24 17:38:39 -04:00
|
|
|
local format="json"
|
|
|
|
|
run target_has_host_source_id $id $format $DEFAULT_HOST_SET
|
2020-10-13 07:41:14 -07:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 21:15:49 -07:00
|
|
|
@test "boundary/target/connect: default user can connect to created target" {
|
2021-02-11 13:14:18 -05:00
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
2020-10-12 10:26:26 -07:00
|
|
|
run connect_nc $id
|
|
|
|
|
echo "connecting to $id: $output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-30 18:11:19 +00:00
|
|
|
@test "boundary/target/client_port: admin user set can set a client port" {
|
|
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
|
|
|
|
run update_tcp_target -id $id -default-client-port 1234
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run read_target $id
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
got=$(echo "$output")
|
|
|
|
|
|
|
|
|
|
echo "$got"
|
|
|
|
|
run field_eq "$got" ".item.attributes.default_client_port" "1234"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 10:26:26 -07:00
|
|
|
@test "boundary/target: default user can delete target" {
|
2021-02-11 13:14:18 -05:00
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
2020-10-12 10:26:26 -07:00
|
|
|
run delete_target $id
|
2021-10-19 17:21:41 -04:00
|
|
|
run has_status_code "$output" "204"
|
2020-10-12 10:26:26 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/target: default user can not read deleted target" {
|
2022-07-28 14:48:51 -06:00
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
|
2020-10-12 10:26:26 -07:00
|
|
|
run read_target $id
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
2022-12-06 12:33:28 -08:00
|
|
|
|
|
|
|
|
@test "boundary/target: create target with a network address" {
|
|
|
|
|
run create_tcp_target_with_addr $DEFAULT_P_ID "localhost" 22 $TGT_NAME_WITH_ADDR
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/target: cannot assign an host source to a target with an address" {
|
|
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME_WITH_ADDR)
|
2023-03-24 17:38:39 -04:00
|
|
|
run add_target_host_sources $id $DEFAULT_HOST_SET
|
2022-12-06 12:33:28 -08:00
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/target: can assign an host source to a target after deleting address" {
|
|
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME_WITH_ADDR)
|
|
|
|
|
run update_address $id "null"
|
|
|
|
|
[ "$status" -eq 0 ]
|
2023-03-24 17:38:39 -04:00
|
|
|
run add_target_host_sources $id $DEFAULT_HOST_SET
|
2022-12-06 12:33:28 -08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/target: cannot assign an address to a target with an host source" {
|
|
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME_WITH_ADDR)
|
|
|
|
|
run update_address $id "localhost"
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "boundary/target: can assign an an address to a target after deleting host source" {
|
|
|
|
|
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME_WITH_ADDR)
|
2023-03-24 17:38:39 -04:00
|
|
|
run remove_target_host_sources $id $DEFAULT_HOST_SET
|
2022-12-06 12:33:28 -08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run update_address $id "localhost"
|
|
|
|
|
[ "$status" -eq 0 ]
|
2023-05-30 18:11:19 +00:00
|
|
|
}
|