Skip to content

Commit ab29ab8

Browse files
committed
tests: Tweak openfga test
Signed-off-by: Stéphane Graber <[email protected]>
1 parent 6ac5950 commit ab29ab8

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

test/suites/openfga.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test_openfga() {
3535
echo "==> Checking permissions for unknown user..."
3636
user_is_not_server_admin
3737
user_is_not_server_operator
38+
user_is_not_server_viewer
3839
user_is_not_project_admin
3940
user_is_not_project_operator
4041

@@ -105,12 +106,17 @@ test_openfga() {
105106
shutdown_openfga
106107
}
107108

108-
user_is_not_server_admin() {
109-
# Can always see server info (type-bound public access https://openfga.dev/docs/modeling/public-access).
110-
incus info oidc-openfga: > /dev/null
109+
user_is_not_server_viewer() {
110+
# Should still be able to list certificates.
111+
[ "$(incus config trust list oidc-openfga: -f csv -cf | wc -l)" = 0 ]
111112

112113
# Cannot see any config.
113114
! incus info oidc-openfga: | grep -Fq 'core.https_address' || false
115+
}
116+
117+
user_is_not_server_admin() {
118+
# Can always see server info (type-bound public access https://openfga.dev/docs/modeling/public-access).
119+
incus info oidc-openfga: > /dev/null
114120

115121
# Cannot set any config.
116122
! incus config set oidc-openfga: core.proxy_https=https://example.com || false
@@ -125,13 +131,6 @@ user_is_not_server_admin() {
125131

126132
# Should not be able to create a storage pool.
127133
! incus storage create oidc-openfga:test dir || false
128-
129-
# Should still be able to list certificates.
130-
[ "$(incus config trust list oidc-openfga: -f csv -cf | wc -l)" = 1 ]
131-
132-
# Cannot edit certificates.
133-
fingerprint="$(incus config trust list -f csv -cf)"
134-
! incus config trust show "${fingerprint}" | sed -e "s/restricted: false/restricted: true/" | incus config trust edit "oidc-openfga:${fingerprint}" || false
135134
}
136135

137136
user_is_not_server_operator() {
@@ -204,7 +203,6 @@ user_is_project_operator() {
204203
}
205204

206205
user_is_not_project_operator() {
207-
208206
# Project list will not fail but there will be no output.
209207
[ "$(incus project list oidc-openfga: -f csv | wc -l)" = 0 ]
210208
! incus project show oidc-openfga:default || false

0 commit comments

Comments
 (0)