Skip to content

Commit 6e5ed83

Browse files
authored
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.
1 parent 602dcf1 commit 6e5ed83

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

cli/src/constants/ENV.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
# Device (Geny_SAAS)
3939
GENY_SAAS_USER = "GENY_SAAS_USER"
4040
GENY_SAAS_PASS = "GENY_SAAS_PASS"
41+
GENY_AUTH_TOKEN = "GENY_AUTH_TOKEN"
4142
GENY_SAAS_TEMPLATE_FILE_NAME = "saas.json"
4243

4344
# Device (Geny_AWS)

cli/src/device/geny_saas.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
import subprocess
34

45
from src.device import Genymotion, DeviceType
@@ -14,9 +15,13 @@ def __init__(self) -> None:
1415
self.created_devices = []
1516

1617
def login(self) -> None:
17-
user = get_env_value_or_raise(ENV.GENY_SAAS_USER)
18-
password = get_env_value_or_raise(ENV.GENY_SAAS_PASS)
19-
subprocess.check_call(f"gmsaas auth login {user} {password} > /dev/null 2>&1", shell=True)
18+
if os.getenv(ENV.GENY_AUTH_TOKEN):
19+
auth_token = get_env_value_or_raise(ENV.GENY_AUTH_TOKEN)
20+
subprocess.check_call(f"gmsaas auth token {auth_token} > /dev/null 2>&1", shell=True)
21+
else:
22+
user = get_env_value_or_raise(ENV.GENY_SAAS_USER)
23+
password = get_env_value_or_raise(ENV.GENY_SAAS_PASS)
24+
subprocess.check_call(f"gmsaas auth login {user} {password} > /dev/null 2>&1", shell=True)
2025
self.logger.info("successfully logged in!")
2126

2227
def create(self) -> None:
@@ -68,5 +73,8 @@ def shutdown_and_logout(self) -> None:
6873
for n, i in d.items():
6974
subprocess.check_call(f"gmsaas instances stop {i}", shell=True)
7075
self.logger.info(f"device '{n}' is successfully removed!")
71-
subprocess.check_call("gmsaas auth logout", shell=True)
76+
if os.getenv(ENV.GENY_AUTH_TOKEN):
77+
subprocess.check_call("gmsaas auth reset", shell=True)
78+
else:
79+
subprocess.check_call("gmsaas auth logout", shell=True)
7280
self.logger.info("successfully logged out!")

docker/genymotion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM budtmo/docker-android:base_${DOCKER_ANDROID_VERSION}
55
# Install Genymotion CLI
66
# (for user management and deployment on Geny Cloud)
77
#===================================================
8-
ENV GMSAAS_CLI_VERSION="1.7.1"
8+
ENV GMSAAS_CLI_VERSION="1.14.1"
99
RUN pip install gmsaas==${GMSAAS_CLI_VERSION}
1010

1111
#================

documentations/THIRD_PARTY_GENYMOTION.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
```
2+
export USER="xxx"
3+
export PASS="xxx"
4+
5+
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
6+
```
17
Genymotion Cloud
28
----------------
39

@@ -9,12 +15,13 @@ You can use Genymotion Android virtual devices in the cloud. They are available
915
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
1016

1117
```
12-
export USER="xxx"
13-
export PASS="xxx"
18+
export AUTH_TOKEN="xxx"
1419

15-
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
20+
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
1621
```
1722

23+
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}`.
24+
1825
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.
1926

2027
```

0 commit comments

Comments
 (0)