Skip to content

Commit 9b8d600

Browse files
committed
Allow reading API key from MBED_CLOUD_SDK_API_KEY variable
1 parent b62cafe commit 9b8d600

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

TESTS/pelion_helper.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# pylint: disable=line-too-long,method-hidden
1818

1919
import json
20+
import os
2021
import uuid
2122
import requests
2223
from mbed_cloud import AccountManagementAPI
@@ -49,8 +50,15 @@ def __init__(self, **kwargs):
4950
self.notified_value = ""
5051

5152
def setup(self):
53+
# Check if API key is in environmental vars
54+
if os.environ['MBED_CLOUD_SDK_API_KEY']:
55+
api_key = (os.environ[str('MBED_CLOUD_SDK_API_KEY')])
56+
print("Reading api-key from environtment %", api_key)
57+
else:
58+
api_key = self.config.get("api_key")
59+
print("Reading api-key from config %", api_key)
60+
5261
self.device_id = self.config.get("device_id")
53-
api_key = self.config.get("api_key")
5462
host = self.config.get("host")
5563
self.test_config = {"api_key": api_key, "host": host}
5664
self.account_api = AccountManagementAPI(self.test_config)

0 commit comments

Comments
 (0)