diff --git a/.github/workflows/client-test.yml b/.github/workflows/client-test.yml index e838988..18118c4 100644 --- a/.github/workflows/client-test.yml +++ b/.github/workflows/client-test.yml @@ -76,7 +76,15 @@ jobs: DEVICE_ID: ${{ secrets.DEVICE_ID1 }} SECRET_KEY: ${{ secrets.SECRET_KEY }} run: | - python tests/ci.py + python tests/ci.py --basic-auth + + - name: '☁️ Connect to IoT cloud (CPython / Key/Cert Auth)' + env: + DEVICE_ID: ${{ secrets.DEVICE_ID2 }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} + run: | + python tests/ci.py --file-auth + - name: '☁️ Connect to IoT cloud (CPython / Crypto Auth)' env: @@ -93,4 +101,4 @@ jobs: run: | export PATH="${HOME}/cache/bin:${PATH}" micropython -c "import sys; print(sys.path)" - micropython tests/ci.py + micropython tests/ci.py --basic-auth diff --git a/tests/ci.py b/tests/ci.py index 45c277e..9bf3288 100644 --- a/tests/ci.py +++ b/tests/ci.py @@ -27,7 +27,13 @@ def on_value_changed(client, value): "-d", "--debug", action="store_true", help="Enable debugging messages" ) parser.add_argument( - "-c", "--crypto-device", action="store_true", help="Use crypto device" + "-b", "--basic-auth", action="store_true", help="Username and password auth", + ) + parser.add_argument( + "-c", "--crypto-device", action="store_true", help="Use soft-hsm/crypto device", + ) + parser.add_argument( + "-f", "--file-auth", action="store_true", help="Use key/cert files" ) args = parser.parse_args() @@ -45,8 +51,25 @@ def on_value_changed(client, value): # the CA certificate (if any) in "ssl_params". Alternatively, a username and password can # be used to authenticate, for example: # client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY) - if args.crypto_device: - import arduino_iot_cloud.ussl as ssl + if args.basic_auth: + client = ArduinoCloudClient( + device_id=os.getenv("DEVICE_ID"), + username=os.getenv("DEVICE_ID"), + password=os.getenv("SECRET_KEY"), + ) + elif args.file_auth: + import ssl + client = ArduinoCloudClient( + device_id=os.getenv("DEVICE_ID"), + ssl_params={ + "keyfile": "key.pem", + "certfile": "cert.pem", + "ca_certs": "ca-root.pem", + "cert_reqs": ssl.CERT_REQUIRED, + }, + ) + elif args.crypto_device: + import ssl client = ArduinoCloudClient( device_id=os.getenv("DEVICE_ID"), ssl_params={ @@ -60,11 +83,8 @@ def on_value_changed(client, value): }, ) else: - client = ArduinoCloudClient( - device_id=os.getenv("DEVICE_ID"), - username=os.getenv("DEVICE_ID"), - password=os.getenv("SECRET_KEY"), - ) + parser.print_help() + sys.exit(1) # Register cloud objects. # Note: The following objects must be created first in the dashboard and linked to the device. diff --git a/tests/ci.sh b/tests/ci.sh index b300947..b1bdbc5 100755 --- a/tests/ci.sh +++ b/tests/ci.sh @@ -6,11 +6,10 @@ ci_install_micropython() { sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi - git clone --depth=1 https://github.com/micropython/micropython.git + git clone --branch v1.20.0 --depth=1 https://github.com/micropython/micropython.git cat > micropython/ports/unix/manifest.py <<-EOF include("\$(PORT_DIR)/variants/manifest.py") - include("\$(MPY_DIR)/extmod/asyncio") require("bundle-networking") require("time") require("senml")