Skip to content

Commit

Permalink
test/auth: Check that 'fine_grained' is rightly set when querying the…
Browse files Browse the repository at this point in the history
… current identity info

Signed-off-by: Gabriel Mougard <[email protected]>
  • Loading branch information
gabrielmougard committed Jan 8, 2025
1 parent e416748 commit 88c7bae
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/suites/auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ groups:
tls_certificate: ""
effective_groups:
- test-group
effective_permissions: []'
effective_permissions: []
fine_grained: true'

[ "$(lxc auth identity info oidc:)" = "${expectedOIDCInfo}" ]

expectedTLSInfo="authentication_method: tls
Expand All @@ -160,7 +162,9 @@ tls_certificate: |
$(awk '{printf " %s\n", $0}' "${LXD_CONF2}/client.crt")
effective_groups:
- test-group
effective_permissions: []"
effective_permissions: []
fine_grained: true"

[ "$(LXD_CONF="${LXD_CONF2}" lxc auth identity info tls:)" = "${expectedTLSInfo}" ]


Expand Down Expand Up @@ -274,6 +278,13 @@ effective_permissions: []"
[ "$(LXD_CONF="${LXD_CONF4}" lxc_remote query tls:/1.0 | jq -r '.auth')" = "trusted" ]
[ "$(LXD_CONF="${LXD_CONF5}" lxc_remote query tls:/1.0 | jq -r '.auth')" = "untrusted" ]

# Check that an unrestricted client certificate is not fine grained.
LXD_CONF6=$(mktemp -d -p "${TEST_DIR}" XXX)
LXD_CONF="${LXD_CONF6}" gen_cert_and_key "client"
LXD_CONF="${LXD_CONF6}" lxc config trust add "${LXD_CONF}/client.crt"

Check warning

Code scanning / shellcheck

SC2097 Warning test

This assignment is only seen by the forked process.

Check warning

Code scanning / shellcheck

SC2098 Warning test

This expansion will not see the mentioned assignment.

Check warning

Code scanning / shellcheck

SC2153 Warning test

Possible misspelling: LXD_CONF may not be assigned. Did you mean LXD_CONF2?
lxc config trust show "$(openssl x509 -in "${LXD_CONF}/client.crt" -outform der | sha256sum | head -c12)" | grep -xF "restricted: false"
[ $(CERTNAME=client my_curl -X GET "https://${LXD_ADDR}/1.0/auth/identities/current" | jq -r .metadata.fine_grained) = "false" ]

Check warning

Code scanning / shellcheck

SC2046 Warning test

Quote this to prevent word splitting.

# Cleanup
lxc auth group delete test-group
lxc auth identity-provider-group delete test-idp-group
Expand All @@ -284,6 +295,7 @@ effective_permissions: []"
rm -r "${LXD_CONF3}"
rm -r "${LXD_CONF4}"
rm -r "${LXD_CONF5}"
rm -r "${LXD_CONF6}"
lxc config unset core.remote_token_expiry
lxc config unset oidc.issuer
lxc config unset oidc.client.id
Expand Down

0 comments on commit 88c7bae

Please sign in to comment.