Skip to content

Commit

Permalink
Merge pull request #588 from simondeziel/trust-token
Browse files Browse the repository at this point in the history
Skip password auth tests if not supported by LXD
  • Loading branch information
simondeziel authored Jun 19, 2024
2 parents 3fdca7e + d8852d3 commit 854587d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions integration/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ fi
# Make sure a client.{crt,key} exist by trying to add a bogus remote
lxc remote add foo 127.0.0.1:1234 2>/dev/null || true

lxc config set core.trust_password password
if ! lxc query /1.0 | grep -q '"explicit_trust_token"$'; then
lxc config set core.trust_password password
fi
lxc config set core.https_address 127.0.0.1

if ! lxc storage show default >/dev/null 2>&1; then
Expand Down Expand Up @@ -62,5 +64,7 @@ for cert in $(comm -13 "${OLD_TRUST_LIST}" "${NEW_TRUST_LIST}"); do
done
rm -f "${OLD_TRUST_LIST}" "${NEW_TRUST_LIST}"

lxc config unset core.trust_password || true
if ! lxc query /1.0 | grep -q '"explicit_trust_token"$'; then
lxc config unset core.trust_password || true
fi
lxc config unset core.https_address || true
10 changes: 10 additions & 0 deletions integration/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class TestClient(IntegrationTestCase):
"""Tests for `Client`."""

def test_authenticate(self):
if self.client.has_api_extension("explicit_trust_token"):
self.skipTest(
"Required LXD support for password authentication not available!"
)

client = pylxd.Client("https://127.0.0.1:8443/")

self.assertFalse(client.trusted)
Expand All @@ -30,6 +35,11 @@ def test_authenticate(self):
self.assertTrue(client.trusted)

def test_authenticate_with_project(self):
if self.client.has_api_extension("explicit_trust_token"):
self.skipTest(
"Required LXD support for password authentication not available!"
)

try:
client = pylxd.Client("https://127.0.0.1:8443/", project="test-project")
except exceptions.ClientConnectionFailed as e:
Expand Down

0 comments on commit 854587d

Please sign in to comment.