From f2feb8f84ded6585db56689b6bbe8fb287a8f3eb Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 9 Aug 2022 16:42:48 -0400 Subject: [PATCH 1/6] Commit to test CI without any changes --- device/lib/ws.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/device/lib/ws.js b/device/lib/ws.js index 18043d0..23cd57b 100644 --- a/device/lib/ws.js +++ b/device/lib/ws.js @@ -25,3 +25,5 @@ function buildBuilder(client, opts) { } module.exports = buildBuilder; + +// Comment for bumping CI From 6d63cf8cad2b647f3ec1df6e36a2580e17cdcce9 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 11 Aug 2022 13:58:12 -0400 Subject: [PATCH 2/6] Use a non gamma endpoint for testing custom auth --- .../device-integration-test.js | 22 ++++++++--- .../run-device-integration-test.sh | 7 ++-- .../run-offline-publishing-test.sh | 7 ++-- .../run-thing-integration-test.sh | 7 ++-- integration-testing/run-tests.sh | 37 +++++++++++-------- 5 files changed, 49 insertions(+), 31 deletions(-) diff --git a/integration-testing/integration-tests/device-integration-test.js b/integration-testing/integration-tests/device-integration-test.js index 23c6207..0ed17e0 100644 --- a/integration-testing/integration-tests/device-integration-test.js +++ b/integration-testing/integration-tests/device-integration-test.js @@ -39,10 +39,17 @@ if (!isUndefined(topicPrefix)) { var customAuthHeaders; var region = args.region; +var customAuthUsername; +var customAuthPassword; + +var enableMetrics = true; if(args.Protocol === 'wss-custom-auth') { customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS); - region = 'us-west-2'; + region = 'us-east-1'; + customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_USERNAME; + customAuthPassword = process.env.CUSTOM_AUTH_PASSWORD; + enableMetrics = false; } // @@ -62,7 +69,10 @@ const device = deviceModule({ port: args.Port, host: args.Host, debug: args.Debug, - customAuthHeaders: customAuthHeaders + customAuthHeaders: customAuthHeaders, + username: customAuthUsername, + password: customAuthPassword, + enableMetrics: enableMetrics, }); var timeout; @@ -127,17 +137,17 @@ device }, Math.max(args.delay,minimumDelay) ); // clip to minimum } }); -device +device .on('close', function() { console.log('close'); process.exit(1); }); -device +device .on('reconnect', function() { console.log('reconnect'); process.exit(1); }); -device +device .on('offline', function() { console.log('offline'); process.exit(1); @@ -149,7 +159,7 @@ device }); device .on('message', function(topic, payload) { - + var stateObject = JSON.parse( payload.toString() ); console.log('received on \''+topic+'\': '+payload.toString()); if (!isUndefined( stateObject.value )) diff --git a/integration-testing/integration-tests/run-device-integration-test.sh b/integration-testing/integration-tests/run-device-integration-test.sh index ec4dafc..52cd193 100755 --- a/integration-testing/integration-tests/run-device-integration-test.sh +++ b/integration-testing/integration-tests/run-device-integration-test.sh @@ -5,7 +5,7 @@ # # Check to make sure the top-level test directory is defined. # -if [ $NPMTEST_DIR"" = "" ] +if [ $NPMTEST_DIR"" = "" ] then echo ${0##*/}": NPMTEST_DIR must be defined!" exit 1 @@ -33,7 +33,8 @@ set -o pipefail RECEIVES_REQUIRED=46 TRANSMITS_TOTAL=48 export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" -export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" +# export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" +export CUSTOM_AUTH_HOST=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Process output will be captured in these files. # @@ -93,7 +94,7 @@ if [ $COMBINED_EXIT_CODE"" = "0" ] then numReceived=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $1}'` receiveMask=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $4}'|sed -e 's/.*=//'` - + echo $numReceived" messages received, receive mask ["$receiveMask"]" if [ $numReceived"" -gt $RECEIVES_REQUIRED"" ] diff --git a/integration-testing/integration-tests/run-offline-publishing-test.sh b/integration-testing/integration-tests/run-offline-publishing-test.sh index 978676a..fa95e73 100755 --- a/integration-testing/integration-tests/run-offline-publishing-test.sh +++ b/integration-testing/integration-tests/run-offline-publishing-test.sh @@ -5,7 +5,7 @@ # # Check to make sure the top-level test directory is defined. # -if [ $NPMTEST_DIR"" = "" ] +if [ $NPMTEST_DIR"" = "" ] then echo ${0##*/}": NPMTEST_DIR must be defined!" exit 1 @@ -21,7 +21,8 @@ NODE=node # TEST_TAG="test-"$RANDOM export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" -export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" +# export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" +export CUSTOM_AUTH_HOST=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Capture the exit code of the first command which fails in a pipeline. # @@ -120,7 +121,7 @@ then # cat $PROC1_OUTFILE | grep -E '^quality' |awk '{print $NF}' receiveQuality=`cat $PROC1_OUTFILE | grep -E '^quality' |awk '{print $NF}'` - + # # We should receive all of these; allow only a very small error margin. # diff --git a/integration-testing/integration-tests/run-thing-integration-test.sh b/integration-testing/integration-tests/run-thing-integration-test.sh index 983ac2c..adbbaac 100755 --- a/integration-testing/integration-tests/run-thing-integration-test.sh +++ b/integration-testing/integration-tests/run-thing-integration-test.sh @@ -5,7 +5,7 @@ # # Check to make sure the top-level test directory is defined. # -if [ $NPMTEST_DIR"" = "" ] +if [ $NPMTEST_DIR"" = "" ] then echo ${0##*/}": NPMTEST_DIR must be defined!" exit 1 @@ -21,7 +21,8 @@ NODE=node # TEST_TAG="test-"$RANDOM export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" -export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" +# export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" +export CUSTOM_AUTH_HOST=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Capture the exit code of the first command which fails in a pipeline. # @@ -95,7 +96,7 @@ then receiveMask1=`cat $PROC1_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $4}'|sed -e 's/.*=//'` numReceived2=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $1}'` receiveMask2=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $4}'|sed -e 's/.*=//'` - + echo "proc 1: "$numReceived1" messages received, receive mask ["$receiveMask1"]" echo "proc 2: "$numReceived2" messages received, receive mask ["$receiveMask2"]" diff --git a/integration-testing/run-tests.sh b/integration-testing/run-tests.sh index 7450dc9..a2be7ca 100755 --- a/integration-testing/run-tests.sh +++ b/integration-testing/run-tests.sh @@ -1,20 +1,20 @@ #!/bin/bash # -# Master integration test runner for the AWS IoT Node.js device SDK. +# Master integration test runner for the AWS IoT Node.js device SDK. # # USAGE # # run-tests.sh # -# PARAMETERS +# PARAMETERS # # : [websocket|certificate|custom-auth] # # This program will first validate the given parameters, then attempt to # retrieve required secrets from AWS secrets manager; if both are successful, it -# will execute all of the scripts under the 'integration-tests' directory -# until either one of them exits with a non-zero status, or they have all -# been executed. If this program exits with a zero status, that indicates +# will execute all of the scripts under the 'integration-tests' directory +# until either one of them exits with a non-zero status, or they have all +# been executed. If this program exits with a zero status, that indicates # that both the test setup and the test execution was successful. # # RETURNS @@ -24,9 +24,9 @@ # SECRET HANDLING # # This script handles retrieving secrets from AWS secrets manager; for -# websocket authentication, it will place the appropriate values in the AWS_ACCESS_KEY_ID +# websocket authentication, it will place the appropriate values in the AWS_ACCESS_KEY_ID # and AWS_SECRET_ACCESS_KEY environment variables used by the SDK. For -# certificate authentication, the certificate and private key will be stored +# certificate authentication, the certificate and private key will be stored # in PEM-format temporary files, along with the root CA certificate; # the files are named according to the default naming convention # specified in the README.md, and the following environment variable points @@ -54,12 +54,12 @@ then if [ $AUTHENTICATION_TYPE"" != "websocket" ] && \ [ $AUTHENTICATION_TYPE"" != "certificate" ] && \ - [ $AUTHENTICATION_TYPE"" != "custom-auth" ] + [ $AUTHENTICATION_TYPE"" != "custom-auth" ] then echo ${0##*/}": authentication-type must be one of [websocket|certificate|custom-auth]" exit 2 fi - export LONG_RUNNING_TEST="" + export LONG_RUNNING_TEST="" else echo ${0##*/}" " exit 1 @@ -103,7 +103,7 @@ then echo "###################################################################" echo ${0##*/}": unable to copy iot sdk to test directory!" echo "###################################################################" - exit 4 + exit 4 fi # @@ -129,7 +129,7 @@ then echo ${0##*/}": unable to npm install aws iot device sdk!" echo "###################################################################" exit 4 -fi +fi # # The SDK installed without errors; now, retrieve credentials @@ -157,7 +157,7 @@ else exit 6 fi -case $AUTHENTICATION_TYPE"" in +case $AUTHENTICATION_TYPE"" in websocket) export AWS_ACCESS_KEY_ID=$principal @@ -172,15 +172,20 @@ case $AUTHENTICATION_TYPE"" in echo ${0##*/}": setting custom-auth credentials" echo "###################################################################" - export CUSTOM_AUTH_HEADERS="{ \"X-Amz-CustomAuthorizer-Name\": \"SDKTestAuthorizer\", \"X-Amz-CustomAuthorizer-Signature\": \"vHPdrbNsr24wR+OcR45el1xh14MtJu5zLPp5ZhoJo9mGCmWQcFj9wPhgYWmgX/900T3NFhB+c7fN8Cln7r6ZszMQP48fjFiF95FmqlXPENlEDWuLN8kCVE3BRr12fcvXDNo9gPEWYE71KkWDLTrqtuOIDFAp39zduEPhzN3bj0yn+0RCMA7X9Q3BNxJji+Rq1U68jCWTjGay9cz3P+PnxfL5zqnoeJhg7baJG+xf7b1kmDw9lMzUSXNGs6FTxO66TzOscZ6I8oOWrMUvTSe24j4POs00bROOTWc0XXoCvX/v4W+TI/Oe3jnJXfXcmOqLXLPqapgWL2XobiOnFjl0PA==\", \"SDKTestAuthorizerToken\": \"abc123\" }" + # export CUSTOM_AUTH_HEADERS="{ \"X-Amz-CustomAuthorizer-Name\": \"SDKTestAuthorizer\", \"X-Amz-CustomAuthorizer-Signature\": \"vHPdrbNsr24wR+OcR45el1xh14MtJu5zLPp5ZhoJo9mGCmWQcFj9wPhgYWmgX/900T3NFhB+c7fN8Cln7r6ZszMQP48fjFiF95FmqlXPENlEDWuLN8kCVE3BRr12fcvXDNo9gPEWYE71KkWDLTrqtuOIDFAp39zduEPhzN3bj0yn+0RCMA7X9Q3BNxJji+Rq1U68jCWTjGay9cz3P+PnxfL5zqnoeJhg7baJG+xf7b1kmDw9lMzUSXNGs6FTxO66TzOscZ6I8oOWrMUvTSe24j4POs00bROOTWc0XXoCvX/v4W+TI/Oe3jnJXfXcmOqLXLPqapgWL2XobiOnFjl0PA==\", \"SDKTestAuthorizerToken\": \"abc123\" }" + + # We need the custom authorization headers to use custom authorization, but we will verify via username and password + export CUSTOM_AUTH_HEADERS="{}" + export CUSTOM_AUTH_NAME=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/authorizer-name" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') + export CUSTOM_AUTH_PASSWORD=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/authorizer-password" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # Make sure it won't reject the internal cert used by Gamma PDX. Once we switch to prod, remove this line - export NODE_TLS_REJECT_UNAUTHORIZED=0 + # export NODE_TLS_REJECT_UNAUTHORIZED=0 $RUN_INTEGRATION_TESTS exit $? ;; - + certificate) export JOBS_AWS_ACCESS_KEY_ID=$principal export JOBS_AWS_SECRET_ACCESS_KEY=$credential @@ -212,7 +217,7 @@ case $AUTHENTICATION_TYPE"" in echo ${0##*/}": couldn't retrieve Private Key!" exit 6 fi - + # # Retrieve the root CA certificate # From f3e6e01e0f42f3cf0b4d3973291732325d814ac2 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 11 Aug 2022 14:08:51 -0400 Subject: [PATCH 3/6] Add the region when accessing secrets --- .../integration-tests/run-device-integration-test.sh | 2 +- .../integration-tests/run-offline-publishing-test.sh | 2 +- .../integration-tests/run-thing-integration-test.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integration-testing/integration-tests/run-device-integration-test.sh b/integration-testing/integration-tests/run-device-integration-test.sh index 52cd193..ade2626 100755 --- a/integration-testing/integration-tests/run-device-integration-test.sh +++ b/integration-testing/integration-tests/run-device-integration-test.sh @@ -34,7 +34,7 @@ RECEIVES_REQUIRED=46 TRANSMITS_TOTAL=48 export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" # export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" -export CUSTOM_AUTH_HOST=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') +export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Process output will be captured in these files. # diff --git a/integration-testing/integration-tests/run-offline-publishing-test.sh b/integration-testing/integration-tests/run-offline-publishing-test.sh index fa95e73..38a0d7e 100755 --- a/integration-testing/integration-tests/run-offline-publishing-test.sh +++ b/integration-testing/integration-tests/run-offline-publishing-test.sh @@ -22,7 +22,7 @@ NODE=node TEST_TAG="test-"$RANDOM export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" # export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" -export CUSTOM_AUTH_HOST=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') +export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Capture the exit code of the first command which fails in a pipeline. # diff --git a/integration-testing/integration-tests/run-thing-integration-test.sh b/integration-testing/integration-tests/run-thing-integration-test.sh index adbbaac..bbc6ffc 100755 --- a/integration-testing/integration-tests/run-thing-integration-test.sh +++ b/integration-testing/integration-tests/run-thing-integration-test.sh @@ -22,7 +22,7 @@ NODE=node TEST_TAG="test-"$RANDOM export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" # export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" -export CUSTOM_AUTH_HOST=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') +export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Capture the exit code of the first command which fails in a pipeline. # From 92b63fbdda04f5b12dc8d9a645dea07c06319474 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 11 Aug 2022 14:13:46 -0400 Subject: [PATCH 4/6] Use correct system environment variable --- .../integration-tests/device-integration-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-testing/integration-tests/device-integration-test.js b/integration-testing/integration-tests/device-integration-test.js index 0ed17e0..fd08380 100644 --- a/integration-testing/integration-tests/device-integration-test.js +++ b/integration-testing/integration-tests/device-integration-test.js @@ -47,7 +47,7 @@ var enableMetrics = true; if(args.Protocol === 'wss-custom-auth') { customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS); region = 'us-east-1'; - customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_USERNAME; + customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_NAME; customAuthPassword = process.env.CUSTOM_AUTH_PASSWORD; enableMetrics = false; } From dc2c9f369b46f961400aa1a468990aac8be9e606 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 11 Aug 2022 14:24:07 -0400 Subject: [PATCH 5/6] Cleanup and add correct custom auth processing to all CI tests --- .../offline-publishing-test.js | 14 ++++++- .../run-device-integration-test.sh | 1 - .../run-offline-publishing-test.sh | 1 - .../run-thing-integration-test.sh | 1 - .../thing-integration-test.js | 42 ++++++++++++------- integration-testing/run-tests.sh | 5 --- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/integration-testing/integration-tests/offline-publishing-test.js b/integration-testing/integration-tests/offline-publishing-test.js index d46f2c9..6f854b7 100644 --- a/integration-testing/integration-tests/offline-publishing-test.js +++ b/integration-testing/integration-tests/offline-publishing-test.js @@ -43,10 +43,17 @@ function processTest(args) { var customAuthHeaders; var region = args.region; + var customAuthUsername; + var customAuthPassword; + + var enableMetrics = true; if(args.Protocol === 'wss-custom-auth') { customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS); - region = 'us-west-2'; + region = 'us-east-1'; + customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_NAME; + customAuthPassword = process.env.CUSTOM_AUTH_PASSWORD; + enableMetrics = false; } // @@ -69,7 +76,10 @@ function processTest(args) { port: args.Port, host: args.Host, debug: args.Debug, - customAuthHeaders: customAuthHeaders + customAuthHeaders: customAuthHeaders, + username: customAuthUsername, + password: customAuthPassword, + enableMetrics: enableMetrics, }); var receiveCount = 0; var outOfOrderCount = 0; diff --git a/integration-testing/integration-tests/run-device-integration-test.sh b/integration-testing/integration-tests/run-device-integration-test.sh index ade2626..ff09f57 100755 --- a/integration-testing/integration-tests/run-device-integration-test.sh +++ b/integration-testing/integration-tests/run-device-integration-test.sh @@ -33,7 +33,6 @@ set -o pipefail RECEIVES_REQUIRED=46 TRANSMITS_TOTAL=48 export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" -# export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Process output will be captured in these files. diff --git a/integration-testing/integration-tests/run-offline-publishing-test.sh b/integration-testing/integration-tests/run-offline-publishing-test.sh index 38a0d7e..abfc7f6 100755 --- a/integration-testing/integration-tests/run-offline-publishing-test.sh +++ b/integration-testing/integration-tests/run-offline-publishing-test.sh @@ -21,7 +21,6 @@ NODE=node # TEST_TAG="test-"$RANDOM export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" -# export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Capture the exit code of the first command which fails in a pipeline. diff --git a/integration-testing/integration-tests/run-thing-integration-test.sh b/integration-testing/integration-tests/run-thing-integration-test.sh index bbc6ffc..7bdd7e0 100755 --- a/integration-testing/integration-tests/run-thing-integration-test.sh +++ b/integration-testing/integration-tests/run-thing-integration-test.sh @@ -21,7 +21,6 @@ NODE=node # TEST_TAG="test-"$RANDOM export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" -# export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com" export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') # # Capture the exit code of the first command which fails in a pipeline. diff --git a/integration-testing/integration-tests/thing-integration-test.js b/integration-testing/integration-tests/thing-integration-test.js index 5103720..9d2ef02 100644 --- a/integration-testing/integration-tests/thing-integration-test.js +++ b/integration-testing/integration-tests/thing-integration-test.js @@ -30,13 +30,13 @@ const isUndefined = require('../common/lib/is-undefined.js'); // and subscribes to an MQTT topic; the other (-t 2) listens to deltas on the thing // shadow and publishes to the MQTT topic. The mode 1 process sends a value with // each update and doubles it afterwards; the mode 2 process publishes this value -// back to the mode 1 process. Each process adds the value received in an +// back to the mode 1 process. Each process adds the value received in an // accumulator. After the mode 1 process has sent 48 messages, it prepares to exit -// and sends a 'quit' command on the thing shadow which forces the mode 2 process +// and sends a 'quit' command on the thing shadow which forces the mode 2 process // to enter its exit logic. As both processes exit, they count the number of bits // set in their accumulators. This test verifies that thing shadow update and // deltas are working as well as non-thing publish and subscribe. Since actual -// values are used in the test, it verifies that simple state objects are +// values are used in the test, it verifies that simple state objects are // transferred correctly, and because it maintains a bitmask of received values it // allows for some messages to be lost due to QOS:0. A passing integration test // here should probably expect >90% of the messages to be received on both sides. @@ -69,10 +69,17 @@ if (!isUndefined(topicPrefix)) { var customAuthHeaders; var region = args.region; +var customAuthUsername; +var customAuthPassword; + +var enableMetrics = true; if(args.Protocol === 'wss-custom-auth') { customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS); - region = 'us-west-2'; + region = 'us-east-1'; + customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_NAME; + customAuthPassword = process.env.CUSTOM_AUTH_PASSWORD; + enableMetrics = false; } // @@ -89,7 +96,10 @@ const thingShadows = thingShadow({ port: args.Port, host: args.Host, debug: args.Debug, - customAuthHeaders: customAuthHeaders + customAuthHeaders: customAuthHeaders, + username: customAuthUsername, + password: customAuthPassword, + enableMetrics: enableMetrics, }); var value=1; @@ -118,7 +128,7 @@ function checkAccumulator() } // -// This test demonstrates the use of thing shadows along with +// This test demonstrates the use of thing shadows along with // non-thing topics. One process updates a thing shadow and // subscribes to a non-thing topic; the other receives delta // updates on the thing shadow on publishes to the non-thing @@ -129,7 +139,7 @@ function updateThingShadow( ) if (count < 48) { console.log('updating thing shadow...'); - clientToken = thingShadows.update( integrationTestShadow, + clientToken = thingShadows.update( integrationTestShadow, { state: { desired: { value: value, quit: 0 }}} ); value = value*2; count++; @@ -140,7 +150,7 @@ function updateThingShadow( ) // // Tell the partner to exit. // - clientToken = thingShadows.update( integrationTestShadow, + clientToken = thingShadows.update( integrationTestShadow, { state: { desired: { value: value, quit: 1 }}} ); setTimeout( function() { process.exit(0); }, 500 ); } @@ -169,23 +179,23 @@ thingShadows else { // -// This process will listen to deltas on a thing shadow and publish to a +// This process will listen to deltas on a thing shadow and publish to a // non-thing topic. // thingShadows.register( integrationTestShadow ); } }); -thingShadows +thingShadows .on('close', function() { console.log('close'); process.exit(1); }); -thingShadows +thingShadows .on('reconnect', function() { console.log('reconnect'); process.exit(1); }); -thingShadows +thingShadows .on('offline', function() { console.log('offline'); process.exit(1); @@ -201,7 +211,7 @@ thingShadows accumulator += JSON.parse( payload.toString() ).value; clearInterval( timer ); // -// After a few seconds, update the thing shadow and if no message has +// After a few seconds, update the thing shadow and if no message has // been received after 10 seconds, try again. // setTimeout( function() { @@ -219,7 +229,7 @@ if (args.testMode===2) { thingShadows .on('delta', function(thingName, stateObject) { - + console.log('received delta, state='+JSON.stringify( stateObject.state)); if (!stateObject.state.quit) @@ -234,8 +244,8 @@ if (args.testMode===2) // Our partner has told us the test has ended; it's our responsibility to delete // the shadow afterwards and then exit ourselves. // - setTimeout( function() { - thingShadows.delete( integrationTestShadow ); + setTimeout( function() { + thingShadows.delete( integrationTestShadow ); setTimeout( function() { process.exit(0); }, 500 ); }, 500 ); } }); diff --git a/integration-testing/run-tests.sh b/integration-testing/run-tests.sh index a2be7ca..50c7839 100755 --- a/integration-testing/run-tests.sh +++ b/integration-testing/run-tests.sh @@ -172,16 +172,11 @@ case $AUTHENTICATION_TYPE"" in echo ${0##*/}": setting custom-auth credentials" echo "###################################################################" - # export CUSTOM_AUTH_HEADERS="{ \"X-Amz-CustomAuthorizer-Name\": \"SDKTestAuthorizer\", \"X-Amz-CustomAuthorizer-Signature\": \"vHPdrbNsr24wR+OcR45el1xh14MtJu5zLPp5ZhoJo9mGCmWQcFj9wPhgYWmgX/900T3NFhB+c7fN8Cln7r6ZszMQP48fjFiF95FmqlXPENlEDWuLN8kCVE3BRr12fcvXDNo9gPEWYE71KkWDLTrqtuOIDFAp39zduEPhzN3bj0yn+0RCMA7X9Q3BNxJji+Rq1U68jCWTjGay9cz3P+PnxfL5zqnoeJhg7baJG+xf7b1kmDw9lMzUSXNGs6FTxO66TzOscZ6I8oOWrMUvTSe24j4POs00bROOTWc0XXoCvX/v4W+TI/Oe3jnJXfXcmOqLXLPqapgWL2XobiOnFjl0PA==\", \"SDKTestAuthorizerToken\": \"abc123\" }" - # We need the custom authorization headers to use custom authorization, but we will verify via username and password export CUSTOM_AUTH_HEADERS="{}" export CUSTOM_AUTH_NAME=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/authorizer-name" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') export CUSTOM_AUTH_PASSWORD=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/authorizer-password" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') - # Make sure it won't reject the internal cert used by Gamma PDX. Once we switch to prod, remove this line - # export NODE_TLS_REJECT_UNAUTHORIZED=0 - $RUN_INTEGRATION_TESTS exit $? ;; From 11149229b7db957d8d3fde60bb104295938a19de Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 11 Aug 2022 14:55:58 -0400 Subject: [PATCH 6/6] Remove useless comment for testing CI --- device/lib/ws.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/device/lib/ws.js b/device/lib/ws.js index 23cd57b..18043d0 100644 --- a/device/lib/ws.js +++ b/device/lib/ws.js @@ -25,5 +25,3 @@ function buildBuilder(client, opts) { } module.exports = buildBuilder; - -// Comment for bumping CI