Skip to content

Commit

Permalink
migration: Use token over password if needed
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Jul 16, 2024
1 parent 16ec945 commit e55031d
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions migration/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.

import os

from integration.testing import IntegrationTestCase


Expand All @@ -35,10 +37,20 @@ def test_migrate_running(self):
second_host = "https://10.0.3.222:8443/"

client1 = Client(endpoint=first_host, verify=False)
client1.authenticate("password")
if client1.has_api_extension("explicit_trust_token"):
secret = os.getenv("LXD_TOKEN_ONE")
else:
secret = "password"

client1.authenticate(secret)

client2 = Client(endpoint=second_host, verify=False)
client2.authenticate("password")
if client2.has_api_extension("explicit_trust_token"):
secret = os.getenv("LXD_TOKEN_TWO")
else:
secret = "password"

client2.authenticate(secret)
an_container = client1.containers.get(self.container.name)
an_container.start(wait=True)
an_container.sync()
Expand All @@ -53,7 +65,12 @@ def test_migrate_local_client(self):

second_host = "https://10.0.3.222:8443/"
client2 = Client(endpoint=second_host, verify=False)
client2.authenticate("password")
if client2.has_api_extension("explicit_trust_token"):
secret = os.getenv("LXD_TOKEN_TWO")
else:
secret = "password"

client2.authenticate(secret)

self.assertRaises(ValueError, self.container.migrate, client2)

Expand All @@ -65,10 +82,20 @@ def test_migrate_stopped(self):
second_host = "https://10.0.3.222:8443/"

client1 = Client(endpoint=first_host, verify=False)
client1.authenticate("password")
if client1.has_api_extension("explicit_trust_token"):
secret = os.getenv("LXD_TOKEN_ONE")
else:
secret = "password"

client1.authenticate(secret)

client2 = Client(endpoint=second_host, verify=False)
client2.authenticate("password")
if client2.has_api_extension("explicit_trust_token"):
secret = os.getenv("LXD_TOKEN_TWO")
else:
secret = "password"

client2.authenticate(secret)
an_container = client1.containers.get(self.container.name)
an_migrated_container = an_container.migrate(client2, wait=True)

Expand Down

0 comments on commit e55031d

Please sign in to comment.