From 6cf96a989a083ab94461ffe6171be4e5cffd1bf2 Mon Sep 17 00:00:00 2001 From: Kai Hudalla Date: Thu, 19 Oct 2023 12:10:12 +0200 Subject: [PATCH] Small fixes * Use appropriate protocol for registering default tenant The device registry only exposes the management API via http if the insecure endpoint is being enabled explicitly. Otherwise, https needs to be used for registering default data with the device registry. --- .../hono/example/add_example_data_device_registry.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/charts/hono/example/add_example_data_device_registry.sh b/charts/hono/example/add_example_data_device_registry.sh index c74ef4dd..ea617477 100755 --- a/charts/hono/example/add_example_data_device_registry.sh +++ b/charts/hono/example/add_example_data_device_registry.sh @@ -11,7 +11,9 @@ # # SPDX-License-Identifier: EPL-2.0 #******************************************************************************* -HTTP_BASE_URL="http://{{ include "hono.fullname" . }}-service-device-registry:8080/v1" +URL_SCHEME="{{- if ( eq .Values.deviceRegistryExample.hono.registry.http.insecurePortEnabled true ) }}http{{ else }}https{{ end }}" +URL_PORT=$([ "${URL_SCHEME}" = "http" ] && echo "8080" || echo "8443") +HTTP_BASE_URL="${URL_SCHEME}://{{ include "hono.fullname" . }}-service-device-registry:${URL_PORT}/v1" check_status() { EXIT_STATUS=$1 @@ -35,7 +37,7 @@ add_tenant(){ HTTP_REQUEST_BODY=$2 echo "Adding tenant [$TENANT_ID]" - HTTP_RESPONSE=$(curl -o /dev/null -sw "%{http_code}" \ + HTTP_RESPONSE=$(curl -o /dev/null -sw "%{http_code}" -k \ -X POST "$HTTP_BASE_URL/tenants/$TENANT_ID" \ --header 'Content-Type: application/json' \ --data-raw "$HTTP_REQUEST_BODY") @@ -49,7 +51,7 @@ register_device(){ HTTP_REQUEST_BODY=$3 echo "Registering device [$TENANT_ID:$DEVICE_ID]" - HTTP_RESPONSE=$(curl -o /dev/null -sw "%{http_code}" \ + HTTP_RESPONSE=$(curl -o /dev/null -sw "%{http_code}" -k \ -X POST "$HTTP_BASE_URL/devices/$TENANT_ID/$DEVICE_ID" \ --header 'Content-Type: application/json' \ --data-raw "$HTTP_REQUEST_BODY") @@ -64,7 +66,7 @@ add_credentials(){ HTTP_REQUEST_BODY=$3 echo "Adding credentials [$TENANT_ID:$DEVICE_ID]" - HTTP_RESPONSE=$(curl -o /dev/null -sw "%{http_code}" \ + HTTP_RESPONSE=$(curl -o /dev/null -sw "%{http_code}" -k \ -X PUT "$HTTP_BASE_URL/credentials/$TENANT_ID/$DEVICE_ID" \ --header 'Content-Type: application/json' \ --data-raw "$HTTP_REQUEST_BODY")