From 93a1ed9de6f8361d07104b87997616ffe47c5727 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 4 Mar 2025 17:34:30 +0100 Subject: [PATCH 1/3] tests/ci.py: Increase test timeout. Signed-off-by: iabdalkader --- tests/ci.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ci.py b/tests/ci.py index bb090ad..c5c97df 100644 --- a/tests/ci.py +++ b/tests/ci.py @@ -25,7 +25,7 @@ def on_value_changed(client, value): def wdt_task(client, args, ts=[None]): if ts[0] is None: ts[0] = time.time() - if time.time() - ts[0] > 10: + if time.time() - ts[0] > 20: loop = asyncio.get_event_loop() loop.set_exception_handler(exception_handler) logging.error("Timeout waiting for variable") From 3289f4ebcfc171c601acb1a34fc1f5213bf5e5fc Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 4 Mar 2025 17:22:42 +0100 Subject: [PATCH 2/3] tests/ci.py: Add an option to use embedded CADATA. Signed-off-by: iabdalkader --- tests/ci.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/ci.py b/tests/ci.py index c5c97df..17892e2 100644 --- a/tests/ci.py +++ b/tests/ci.py @@ -8,6 +8,7 @@ import asyncio from arduino_iot_cloud import ArduinoCloudClient from arduino_iot_cloud import Task +from arduino_iot_cloud import CADATA # noqa import argparse @@ -47,6 +48,9 @@ def wdt_task(client, args, ts=[None]): parser.add_argument( "-f", "--file-auth", action="store_true", help="Use key/cert files" ) + parser.add_argument( + "-ca", "--ca-data", action="store_true", help="Use embedded CADATA" + ) parser.add_argument( "-s", "--sync", action="store_true", help="Run in synchronous mode" ) @@ -76,12 +80,14 @@ def wdt_task(client, args, ts=[None]): elif args.file_auth: import ssl fmt = "der" if sys.implementation.name == "micropython" else "pem" + ca_key = "cadata" if args.ca_data else "cafile" + ca_val = CADATA if args.ca_data else f"ca-root.{fmt}" client = ArduinoCloudClient( device_id=os.getenv("DEVICE_ID"), ssl_params={ "keyfile": f"key.{fmt}", "certfile": f"cert.{fmt}", - "ca_certs": f"ca-root.{fmt}", + ca_key: ca_val, "cert_reqs": ssl.CERT_REQUIRED, }, sync_mode=args.sync, @@ -95,7 +101,7 @@ def wdt_task(client, args, ts=[None]): "use_hsm": True, "keyfile": "pkcs11:token=arduino", "certfile": "pkcs11:token=arduino", - "ca_certs": "ca-root.pem", + "cafile": "ca-root.pem", "cert_reqs": ssl.CERT_REQUIRED, "engine_path": "/lib/x86_64-linux-gnu/engines-3/libpkcs11.so", "module_path": "/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so", From 659b673b1ff38c0d7ac1c512ac1016a3dec1443b Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 4 Mar 2025 17:33:48 +0100 Subject: [PATCH 3/3] github/workflows: Update client test workflow. - Remove key from tests that don't use it. - Add a test that uses the embedded CADATA. - Run workflow on schedule. Signed-off-by: iabdalkader --- .github/workflows/client-test.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/client-test.yml b/.github/workflows/client-test.yml index 9bba477..571dafc 100644 --- a/.github/workflows/client-test.yml +++ b/.github/workflows/client-test.yml @@ -2,7 +2,7 @@ name: '🧪 Test Cloud Client' on: push: - branches: + branches: - 'main' paths: - '**.py' @@ -16,7 +16,7 @@ on: - edited - reopened - synchronize - branches: + branches: - 'main' paths: - '**.py' @@ -24,6 +24,9 @@ on: - '.github/workflows/*.json' - '!**/README.md' + schedule: + - cron: '0 12 * * *' # Runs every day at 12 PM UTC + jobs: build: runs-on: ubuntu-latest @@ -89,14 +92,18 @@ jobs: - name: '☁️ Connect to IoT cloud (CPython / Key-Cert Auth / Async)' env: DEVICE_ID: ${{ secrets.DEVICE_ID2 }} - SECRET_KEY: ${{ secrets.SECRET_KEY }} run: | python tests/ci.py --file-auth + - name: '☁️ Connect to IoT cloud (CPython / Key-Cert Auth / CADATA / Async)' + env: + DEVICE_ID: ${{ secrets.DEVICE_ID2 }} + run: | + python tests/ci.py --file-auth --ca-data + - name: '☁️ Connect to IoT cloud (CPython / Crypto Auth / Async)' env: DEVICE_ID: ${{ secrets.DEVICE_ID2 }} - SECRET_KEY: ${{ secrets.SECRET_KEY }} run: | export SOFTHSM2_CONF="${HOME}/softhsm/tokens/softhsm2.conf" python tests/ci.py --crypto-device @@ -122,7 +129,6 @@ jobs: - name: '☁️ Connect to IoT cloud (MicroPython / Key-Cert Auth / Async)' env: DEVICE_ID: ${{ secrets.DEVICE_ID2 }} - SECRET_KEY: ${{ secrets.SECRET_KEY }} run: | export PATH="${HOME}/cache/bin:${PATH}" micropython -c "import sys; print(sys.path)"