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 10, 2025
1 parent c19f2af commit f7b3a8c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 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,15 @@ 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 "unrestricted"
lxdconf6_fingerprint_short="$(cert_fingerprint "${LXD_CONF6}/unrestricted.crt" | head -c12)"
lxc config trust add "${LXD_CONF6}/unrestricted.crt"
lxc config trust show "${lxdconf6_fingerprint_short}" | grep -xF "restricted: false"
[ "$(LXD_CONF="${LXD_CONF6}" CERTNAME=unrestricted my_curl -X GET "https://${LXD_ADDR}/1.0/auth/identities/current" | jq -r .metadata.fine_grained)" = "false" ]
lxc config trust remove "${lxdconf6_fingerprint_short}"

# Cleanup
lxc auth group delete test-group
lxc auth identity-provider-group delete test-idp-group
Expand All @@ -284,6 +297,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 f7b3a8c

Please sign in to comment.