mirror of
https://github.com/budtmo/docker-android.git
synced 2025-12-08 18:25:50 +00:00
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:
parent
602dcf15a7
commit
6e5ed8386a
@ -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)
|
||||
|
||||
@ -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!")
|
||||
|
||||
@ -5,7 +5,7 @@ FROM budtmo/docker-android:base_${DOCKER_ANDROID_VERSION}
|
||||
# Install Genymotion CLI
|
||||
# (for user management and deployment on Geny Cloud)
|
||||
#===================================================
|
||||
ENV GMSAAS_CLI_VERSION="1.7.1"
|
||||
ENV GMSAAS_CLI_VERSION="1.14.1"
|
||||
RUN pip install gmsaas==${GMSAAS_CLI_VERSION}
|
||||
|
||||
#================
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
```
|
||||
export USER="xxx"
|
||||
export PASS="xxx"
|
||||
|
||||
docker run -d -p 4723:4723 -v ${PWD}/example/genycloud/saas.json:/home/androidusr/genymotion_template/saas.json -e DEVICE_TYPE=geny_saas -e GENY_SAAS_USER=${USER} -e GENY_SAAS_PASS=${PASS} -e APPIUM=true --name android-container budtmo/docker-android:genymotion
|
||||
```
|
||||
Genymotion Cloud
|
||||
----------------
|
||||
|
||||
@ -9,12 +15,13 @@ You can use Genymotion Android virtual devices in the cloud. They are available
|
||||
Use [saas.json](../example/genymotion/saas.json) to define the devices that you want to use. You can specify the port on which the device will start so you don't need to change the device name in your tests every time you need to run those tests. Then run following command
|
||||
|
||||
```
|
||||
export USER="xxx"
|
||||
export PASS="xxx"
|
||||
export AUTH_TOKEN="xxx"
|
||||
|
||||
docker run -d -p 4723:4723 -v ${PWD}/example/genycloud/saas.json:/home/androidusr/genymotion_template/saas.json -e DEVICE_TYPE=geny_saas -e GENY_SAAS_USER=${USER} -e GENY_SAAS_PASS=${PASS} -e APPIUM=true --name android-container budtmo/docker-android:genymotion
|
||||
docker run -d -p 4723:4723 -v ${PWD}/example/genycloud/saas.json:/home/androidusr/genymotion_template/saas.json -e DEVICE_TYPE=geny_saas -e GENY_AUTH_TOKEN=${AUTH_TOKEN} -e APPIUM=true --name android-container budtmo/docker-android:genymotion
|
||||
```
|
||||
|
||||
Genymotion has deprecated credential based login since gmsaas 1.10.0, but if necessary, you can still provide them using `-e GENY_SAAS_USER=${USER} -e GENY_SAAS_PASS=${PASS}` instead of `-e GENY_AUTH_TOKEN=${AUTH_TOKEN}`.
|
||||
|
||||
The deployed device(s) are automatically connected with adb inside docker container. Stopping the emulator will remove all deployed device(s) on Genymotion SaaS and user will be logged out at the end.
|
||||
|
||||
```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user