Skip to content

Commit

Permalink
tests: Tweak openfga test
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Nov 29, 2024
1 parent 6ac5950 commit 6fce01c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/suites/openfga.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test_openfga() {
echo "==> Checking permissions for unknown user..."
user_is_not_server_admin
user_is_not_server_operator
user_is_not_server_viewer
user_is_not_project_admin
user_is_not_project_operator

Expand Down Expand Up @@ -105,6 +106,14 @@ test_openfga() {
shutdown_openfga
}

user_is_not_server_viewer() {
# Should still be able to list certificates.
[ "$(incus config trust list oidc-openfga: -f csv -cf | wc -l)" = 1 ]

# Cannot see any config.
! incus info oidc-openfga: | grep -Fq 'core.https_address' || false
}

user_is_not_server_admin() {
# Can always see server info (type-bound public access https://openfga.dev/docs/modeling/public-access).
incus info oidc-openfga: > /dev/null
Expand All @@ -125,13 +134,6 @@ user_is_not_server_admin() {

# Should not be able to create a storage pool.
! incus storage create oidc-openfga:test dir || false

# Should still be able to list certificates.
[ "$(incus config trust list oidc-openfga: -f csv -cf | wc -l)" = 1 ]

# Cannot edit certificates.
fingerprint="$(incus config trust list -f csv -cf)"
! incus config trust show "${fingerprint}" | sed -e "s/restricted: false/restricted: true/" | incus config trust edit "oidc-openfga:${fingerprint}" || false
}

user_is_not_server_operator() {
Expand Down Expand Up @@ -204,7 +206,6 @@ user_is_project_operator() {
}

user_is_not_project_operator() {

# Project list will not fail but there will be no output.
[ "$(incus project list oidc-openfga: -f csv | wc -l)" = 0 ]
! incus project show oidc-openfga:default || false
Expand Down

0 comments on commit 6fce01c

Please sign in to comment.