Skip to content

Commit cdcba22

Browse files
authored
Merge branch 'main' into ct/py-overhaul
2 parents 67be29c + 141d007 commit cdcba22

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

‎credscan_suppression.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@
4040
{
4141
"file": "\\tests\\unit\\iothub\\aio\\test_async_clients.py",
4242
"_justification": "Test containing fake signed data"
43+
},
44+
{
45+
"file": "\\tests\\unit\\iothub\\pipeline\\test_pipeline_stages_iothub.py",
46+
"_justification": "Test containing fake keys"
47+
},
48+
{
49+
"file": "\\tests\\unit\\provisioning\\shared_client_tests.py",
50+
"_justification": "Test containing fake keys"
51+
},
52+
{
53+
"file": "\\tests\\unit\\provisioning\\pipeline\\test_pipeline_stages_provisioning.py",
54+
"_justification": "Test containing fake keys"
55+
},
56+
{
57+
"file": "\\tests\\unit\\common\\pipeline\\test_pipeline_stages_base.py",
58+
"_justification": "Test containing fake signed data"
4359
}
4460
]
4561

‎sdklab/meantimerecovery/README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ dead_duration : the amount of time the MQTT broker will be taken down for.
4646

4747
Before running the the `mean_time_recover_with_docker.py` script make sure your docker engine is running.
4848

49+
#### Connection string
50+
51+
Both `mean_time_recover_with_docker.py` and `simple_send_message.py` read the device connection
52+
string from the `IOTHUB_DEVICE_CONNECTION_STRING` environment variable; neither script contains a
53+
connection string or key of its own. The local `aedes` broker does not verify the key, so any
54+
base64 value works, for example:
55+
56+
`export IOTHUB_DEVICE_CONNECTION_STRING="HostName=localhost;DeviceId=devicemtr;SharedAccessKey=<base64 key>"`
57+
58+
Use a throwaway value here. Never place a real IoT Hub device key in a shell history or a file
59+
that can be committed.
60+
4961
#### Certificate creation
5062

5163
There is another script which will create some self signed certificates for use in the `aedes` server.

‎sdklab/meantimerecovery/mean_time_recover_with_docker.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# --------------------------------------------------------------------------
66
import docker
77
import asyncio
8+
import os
89
import uuid
910
from azure.iot.device.aio import IoTHubDeviceClient
1011
from azure.iot.device import Message
@@ -124,6 +125,14 @@ def timer_done():
124125

125126
async def main():
126127

128+
conn_str = os.getenv("IOTHUB_DEVICE_CONNECTION_STRING")
129+
if not conn_str:
130+
raise RuntimeError(
131+
"Set the IOTHUB_DEVICE_CONNECTION_STRING environment variable to the connection "
132+
"string of the device used against the local test broker, e.g. "
133+
"HostName=localhost;DeviceId=devicemtr;SharedAccessKey=<base64 key>"
134+
)
135+
127136
ca_cert = "self_cert_localhost.pem"
128137
certfile = open(ca_cert)
129138
root_ca_cert = certfile.read()
@@ -140,7 +149,6 @@ async def main():
140149

141150
# Do not delete sleep from here. Server needs some time to start.
142151
await asyncio.sleep(5)
143-
conn_str = "HostName=localhost;DeviceId=devicemtr;SharedAccessKey=Zm9vYmFy"
144152
device_client = IoTHubDeviceClient.create_from_connection_string(
145153
conn_str, keep_alive=KEEP_ALIVE, server_verification_cert=root_ca_cert
146154
)

‎sdklab/meantimerecovery/simple_send_message.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# license information.
55
# --------------------------------------------------------------------------
66
import asyncio
7+
import os
78
import uuid
89
from azure.iot.device.aio import IoTHubDeviceClient
910
from azure.iot.device import Message
@@ -41,7 +42,13 @@ async def main():
4142
# Scenario based values
4243
keep_alive = 15
4344

44-
conn_str = "HostName=localhost;DeviceId=devicemtr;SharedAccessKey=Zm9vYmFy"
45+
conn_str = os.getenv("IOTHUB_DEVICE_CONNECTION_STRING")
46+
if not conn_str:
47+
raise RuntimeError(
48+
"Set the IOTHUB_DEVICE_CONNECTION_STRING environment variable to the connection "
49+
"string of the device used against the local test broker, e.g. "
50+
"HostName=localhost;DeviceId=devicemtr;SharedAccessKey=<base64 key>"
51+
)
4552
device_client = IoTHubDeviceClient.create_from_connection_string(
4653
conn_str, keep_alive=keep_alive
4754
)

0 commit comments

Comments
 (0)