Add Genymotion auth tokens (#512)

As described in #511, Genymotion has deprecated credential based
login. This adds support for passing in an auth token instead.

This could also check for the GENYMOTION_API_TOKEN env variable being
set and skipping the login entirely, but I haven't added that in favor
of keeping the explicit token check during login.

This also updates the default version of the gmsaas package to the
latest release.
This commit is contained in:
Dave Golombek
2025-06-20 08:42:58 +02:00
committed by GitHub
parent 602dcf15a7
commit 6e5ed8386a
4 changed files with 24 additions and 8 deletions
+1
View File
@@ -38,6 +38,7 @@ GENYMOTION_TEMPLATE_PATH = "GENYMOTION_TEMPLATE_PATH"
# Device (Geny_SAAS)
GENY_SAAS_USER = "GENY_SAAS_USER"
GENY_SAAS_PASS = "GENY_SAAS_PASS"
GENY_AUTH_TOKEN = "GENY_AUTH_TOKEN"
GENY_SAAS_TEMPLATE_FILE_NAME = "saas.json"
# Device (Geny_AWS)
+12 -4
View File
@@ -1,4 +1,5 @@
import logging
import os
import subprocess
from src.device import Genymotion, DeviceType
@@ -14,9 +15,13 @@ class GenySAAS(Genymotion):
self.created_devices = []
def login(self) -> None:
user = get_env_value_or_raise(ENV.GENY_SAAS_USER)
password = get_env_value_or_raise(ENV.GENY_SAAS_PASS)
subprocess.check_call(f"gmsaas auth login {user} {password} > /dev/null 2>&1", shell=True)
if os.getenv(ENV.GENY_AUTH_TOKEN):
auth_token = get_env_value_or_raise(ENV.GENY_AUTH_TOKEN)
subprocess.check_call(f"gmsaas auth token {auth_token} > /dev/null 2>&1", shell=True)
else:
user = get_env_value_or_raise(ENV.GENY_SAAS_USER)
password = get_env_value_or_raise(ENV.GENY_SAAS_PASS)
subprocess.check_call(f"gmsaas auth login {user} {password} > /dev/null 2>&1", shell=True)
self.logger.info("successfully logged in!")
def create(self) -> None:
@@ -68,5 +73,8 @@ class GenySAAS(Genymotion):
for n, i in d.items():
subprocess.check_call(f"gmsaas instances stop {i}", shell=True)
self.logger.info(f"device '{n}' is successfully removed!")
subprocess.check_call("gmsaas auth logout", shell=True)
if os.getenv(ENV.GENY_AUTH_TOKEN):
subprocess.check_call("gmsaas auth reset", shell=True)
else:
subprocess.check_call("gmsaas auth logout", shell=True)
self.logger.info("successfully logged out!")