Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/grpc/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/openapi/policy/actions/actions.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/openapi/policy/attributes/attributes.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/openapi/policy/objects.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/openapi/policy/obligations/obligations.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/openapi/policy/unsafe/unsafe.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions otdfctl/e2e/resource-mapping-groups.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ setup_file() {
export HOST='--host http://localhost:8080'

# Create two namespaced values to be used in other tests
NS_NAME="resource-mapping-groups.io"
export NS_NAME="resource-mapping-groups.io"
export NS_ID=$(./otdfctl $HOST $WITH_CREDS policy attributes namespaces create -n "$NS_NAME" --json | jq -r '.id')
NS_NAME2="resource-mapping-groups-2.io"
export NS_NAME2="resource-mapping-groups-2.io"
export NS2_ID=$(./otdfctl $HOST $WITH_CREDS policy attributes namespaces create -n "$NS_NAME2" --json | jq -r '.id')
ATTR_ID=$(./otdfctl $HOST $WITH_CREDS policy attributes create --namespace "$NS_ID" --name attr1 --rule ANY_OF --json | jq -r '.id')
# Name is prefixed with RMG to avoid conflicts across tests when running in parallel
export RMG_VAL1_ID=$(./otdfctl $HOST $WITH_CREDS policy attributes values create --attribute-id "$ATTR_ID" --value val1 --json | jq -r '.id')

# Create a resource mapping group
export RMG1_NAME="rmgrp-test"
export RMG1_FQN="https://${NS_NAME}/resm/${RMG1_NAME}"
export RMG1_ID=$(./otdfctl $HOST $WITH_CREDS policy resource-mapping-groups create --namespace-id "$NS_ID" --name "$RMG1_NAME" --json | jq -r '.id')

# Create a couple resource mappings to val1 - comma separated
Expand All @@ -42,7 +43,7 @@ teardown_file() {
./otdfctl $HOST $WITH_CREDS policy attributes namespaces unsafe delete --force --id "$NS_ID"
./otdfctl $HOST $WITH_CREDS policy attributes namespaces unsafe delete --force --id "$NS2_ID"

unset HOST WITH_CREDS RMG_VAL1_ID NS_ID NS2_ID RM1_TERMS RM1_ID RM1_OTHER_TERMS RM1_OTHER_ID RMG1_NAME RMG1_ID
unset HOST WITH_CREDS RMG_VAL1_ID NS_NAME NS_ID NS_NAME2 NS2_ID RM1_TERMS RM1_ID RM1_OTHER_TERMS RM1_OTHER_ID RMG1_NAME RMG1_FQN RMG1_ID
}

@test "Create resource mapping group" {
Expand All @@ -52,6 +53,10 @@ teardown_file() {
assert_output --partial "rmgrp1"
assert_line --regexp "Namespace Id.*$NS_ID"

run_otdfctl_rmg create --namespace-id "$NS_ID" --name rmgrp1-json --json
assert_success
assert_equal "$(echo "$output" | jq -r '.fqn')" "https://${NS_NAME}/resm/rmgrp1-json"

# ns id flag must be uuid
run_otdfctl_rmg create --namespace-id "something" --name testing
assert_failure
Expand All @@ -77,6 +82,7 @@ teardown_file() {
[ $(echo $output | jq -r '.id') = "$RMG1_ID" ]
[ $(echo $output | jq -r '.namespace_id') = "$NS_ID" ]
[ $(echo $output | jq -r '.name') = "$RMG1_NAME" ]
[ $(echo $output | jq -r '.fqn') = "$RMG1_FQN" ]

# id required
run_otdfctl_rmg get
Expand Down Expand Up @@ -104,6 +110,10 @@ teardown_file() {
assert_output --partial "new-rsmg-name"
refute_output --partial "$NS_ID"
assert_output --partial "$NS2_ID"

run_otdfctl_rmg update --id "$NEW_RMG_ID" --name "new-rsmg-name-json" --json
assert_success
assert_equal "$(echo "$output" | jq -r '.fqn')" "https://${NS_NAME2}/resm/new-rsmg-name-json"
}

@test "List resource mapping groups" {
Expand All @@ -121,6 +131,7 @@ teardown_file() {
found_rmg=$(echo "$output" | jq -c --arg id "$RMG1_ID" '.resource_mapping_groups as $a | ($a | map(.id) | index($id)) as $i | $a[$i]')
assert_equal "$(echo "$found_rmg" | jq -r '.id')" "$RMG1_ID"
assert_equal "$(echo "$found_rmg" | jq -r '.name')" "$RMG1_NAME"
assert_equal "$(echo "$found_rmg" | jq -r '.fqn')" "$RMG1_FQN"
[[ "$(echo "$output" | jq -r '.pagination.total')" -ge 1 ]]
assert_equal "$(echo "$output" | jq -r '.pagination.current_offset')" "null"
assert_equal "$(echo "$output" | jq -r '.pagination.next_offset')" "null"
Expand All @@ -133,4 +144,9 @@ teardown_file() {
assert_line --regexp "Id.*$RMG1_ID"
assert_line --regexp "Namespace Id.*$NS_ID"
assert_line --regexp "Name.*$RMG1_NAME"

NEW_RMG_ID=$(./otdfctl $HOST $WITH_CREDS policy resource-mapping-groups create --namespace-id "$NS_ID" --name rmgrp-delete-json --json | jq -r '.id')
run_otdfctl_rmg delete --id "$NEW_RMG_ID" --force --json
assert_success
assert_equal "$(echo "$output" | jq -r '.fqn')" "https://${NS_NAME}/resm/rmgrp-delete-json"
}
8 changes: 4 additions & 4 deletions otdfctl/e2e/resource-mapping.bats
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@ teardown_file() {
# replace the terms
run_otdfctl_rm update --id "$NEW_RM_ID" --terms replaced,new
assert_success
refute_output --partial "test"
refute_output --partial "found"
refute_line --regexp "Terms.*test"
refute_line --regexp "Terms.*found"
assert_output --partial "replaced"
assert_output --partial "new"
assert_output --partial "$RM_VAL2_ID"

# reassign the attribute value being mapped
run_otdfctl_rm update --id "$NEW_RM_ID" --attribute-value-id "$RM_VAL1_ID"
assert_success
refute_output --partial "test"
refute_output --partial "found"
refute_line --regexp "Terms.*test"
refute_line --regexp "Terms.*found"
assert_output --partial "replaced"
assert_output --partial "new"
refute_output --partial "$RM_VAL2_ID"
Expand Down
Loading
Loading