From 821d10ac3499c4452ac23e931f224a7f23048ac6 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Mon, 11 Dec 2017 16:46:34 -0800 Subject: [PATCH 1/6] Adds tests for HTTP device sample --- ...ple_nodejs.js => cloudiot_http_example.js} | 32 ++++- iot/http_example/package.json | 13 +- iot/http_example/resources/README.md | 4 + iot/http_example/resources/rsa_cert.pem | 18 +++ iot/http_example/resources/rsa_private.pem | 28 +++++ .../system-test/cloudiot_http_example_test.js | 118 ++++++++++++++++++ 6 files changed, 211 insertions(+), 2 deletions(-) rename iot/http_example/{cloudiot_http_example_nodejs.js => cloudiot_http_example.js} (87%) create mode 100644 iot/http_example/resources/README.md create mode 100644 iot/http_example/resources/rsa_cert.pem create mode 100644 iot/http_example/resources/rsa_private.pem create mode 100644 iot/http_example/system-test/cloudiot_http_example_test.js diff --git a/iot/http_example/cloudiot_http_example_nodejs.js b/iot/http_example/cloudiot_http_example.js similarity index 87% rename from iot/http_example/cloudiot_http_example_nodejs.js rename to iot/http_example/cloudiot_http_example.js index 50a88b4288..3752a4acae 100644 --- a/iot/http_example/cloudiot_http_example_nodejs.js +++ b/iot/http_example/cloudiot_http_example.js @@ -166,6 +166,32 @@ function publishAsync (messageCount, numMessages) { } // [END iot_http_publish] +// [START iot_http_getconfig] +function getConfig (version) { + console.log('Getting config:'); + console.log(urlBase); + const options = { + url: urlBase + '/config?local_version=' + version, + headers: { + 'authorization': 'Bearer ' + authToken, + 'content-type': 'application/json', + 'cache-control': 'no-cache' + + }, + json: true + }; + request.get(options, function (error, response, body) { + if (error) { + console.error('Received error: ', error); + } else if (response.body.error) { + console.error('Received error: ' + JSON.stringify(response.body.error)); + } else { + console.log('Received config', JSON.stringify(body)); + } + }); +} +// [END iot_http_getconfig] + // [START iot_run_http] // A unique string that identifies this device. For Google Cloud IoT Core, it // must be in the format below. @@ -174,10 +200,14 @@ const devicePath = `projects/${argv.project_id}/locations/${argv.cloud_region}/r // The request path, set accordingly depending on the message type. const pathSuffix = argv.message_type === 'events' ? ':publishEvent' : ':setState'; -const url = `https://${argv.http_bridge_address}/v1beta1/${devicePath}${pathSuffix}`; +const urlBase = `https://${argv.http_bridge_address}/v1beta1/${devicePath}`; +const url = `${urlBase}${pathSuffix}`; let iatTime = parseInt(Date.now() / 1000); let authToken = createJwt(argv.project_id, argv.private_key_file, argv.algorithm); +// Print latest configuration +getConfig(0); + // Publish messages. publishAsync(1, argv.num_messages); // [END iot_run_http] diff --git a/iot/http_example/package.json b/iot/http_example/package.json index 89c6b77985..a1aab57597 100644 --- a/iot/http_example/package.json +++ b/iot/http_example/package.json @@ -5,10 +5,21 @@ "license": "Apache-2.0", "author": "Google Inc.", "main": "cloudiot_http_example_nodejs.js", + "scripts": { + "lint": "samples lint", + "pretest": "npm run lint", + "test": "samples test run --cmd ava -- -T 3m --verbose system-test/*.test.js" + }, "dependencies": { + "@google-cloud/pubsub": "0.13.2", + "@google-cloud/nodejs-repo-tools": "1.4.17", + "ava": "0.22.0", "yargs": "8.0.2", "jsonwebtoken": "7.4.1", - "request": "2.82.0" + "request": "2.82.0", + "uuid": "3.1.0" + }, + "testDependencies": { }, "devDependencies": {} } diff --git a/iot/http_example/resources/README.md b/iot/http_example/resources/README.md new file mode 100644 index 0000000000..ba272ccaf7 --- /dev/null +++ b/iot/http_example/resources/README.md @@ -0,0 +1,4 @@ +# Test public certificate files + +The public certificates in this folder are only provided for testing and should +not be used for registering your devices. diff --git a/iot/http_example/resources/rsa_cert.pem b/iot/http_example/resources/rsa_cert.pem new file mode 100644 index 0000000000..d81ae7c4f4 --- /dev/null +++ b/iot/http_example/resources/rsa_cert.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC9TCCAd2gAwIBAgIJALM44e3ivEWkMA0GCSqGSIb3DQEBCwUAMBExDzANBgNV +BAMMBnVudXNlZDAeFw0xNzEyMDcwMDQ1MjdaFw0yNzEyMDUwMDQ1MjdaMBExDzAN +BgNVBAMMBnVudXNlZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL4w +BxHuEyYdbiwKiD8yXY7vYpcygeOQ4/ZdEg3wCB2OuYcaFRcCuqLcTLMnuzdcL+y3 +HBjWkrRW658cg3NG93Vj0iwSrga6u24CGBNYV+h8MBvwaDxk+uubnd5M/Q2OyL1J +GiMxQ1blR/71Hr5hhqaQZ2+qOF6kuf1m9rLUtMUJwOKp/PjPDmy654ZGsFWFSZmy +eRpNzmGU+KJg0o+Qf+sm75a8gQZ8AsrqveW0S/8o+zAjD0SkPcd01QBmYzQhjbi/ +LGGITrzbaB3ld9umJBIcXfnYPYisJfwSsT/jFwiXhrhpxNNaIaKlTzlQIt5l8bSs +HXzJBbuIg5Jb/SyIEpkCAwEAAaNQME4wHQYDVR0OBBYEFOfaQTUVAoNb6fc7qzzl +uKyHGrCYMB8GA1UdIwQYMBaAFOfaQTUVAoNb6fc7qzzluKyHGrCYMAwGA1UdEwQF +MAMBAf8wDQYJKoZIhvcNAQELBQADggEBALKKDtiV1YV8k0YsNdiIXRlS3jsuoGuI +VVBrvDGz5Hel0rH9YmmfPS/Yn08kk3DF8Uynr4Xo1Zt9hmhgoq3ZoWm7MIP1+a9s +WyACyEMhVQSCzQrexRvG5ElpHx/vNjbcwiBkE5urlIvMBVt+BRRNKMNWq6F9ae63 +FxRp7CtNFSbibtLJuPgCs6qoNs0nlt2FPsNvs7jpPipj69o+egVckvQjAyppirWO ++jO5hCLy7EahLz2wCn90z0Xf9lhOZni9meaV1Vy3CHHg6jwIB8/XlRaHFrOGMGXg +h8eQqsmpk9/3o8pv00yj6Hkq+swVg7Rg9FZaUiOv/HO/J7stWU7qPbI= +-----END CERTIFICATE----- diff --git a/iot/http_example/resources/rsa_private.pem b/iot/http_example/resources/rsa_private.pem new file mode 100644 index 0000000000..06a66e3d40 --- /dev/null +++ b/iot/http_example/resources/rsa_private.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCB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EQKBgDFrGId19AWD+z0xNWEHJjJB8CJFvHANvAzVHLOYXuEvzTvMs5qw +/N8tHHzsftO+lUPB6XOqJrCSlGhRYtPx//8FcPpS3Ru6rAerKKlXIB3buPqSsv9a +55s72DdmmvhayysLs8LSclOpY5vXGCsHLqGwMw6Zlm+zNyFOXAX5GspRAoGAaJMx +W68ABK8OM0OzhGQm9kriKTzIg5yjXspyQBzQo0HJ6B8kBgHgk8rPO68mOPsgYlPl +qogp/OgHjv9ahFJRwzLslckJM7g628loYfYAew+zrZrG4dsDjNG0Sw3zlAgeUAbQ +D+2iVhZf61josFiRuMP3t9paEi+vAFk4C3KSz/ECgYBpi1akpIzsYehW5uOL7Jhw +Hay5eshQ4vmHYuhDnn3gtT3h6J7TMwWs9pOygBG1I1b7GJ+tp4BZWJ2PmI7P8s45 +jdI99WODHwv03lAzjLwigoqDUDduaYqXcGghcGht5Sknkl2uYDChwLtI5JdBZ9/x +8h9dE9oAiH/KTzhPmK1E1Q== +-----END PRIVATE KEY----- diff --git a/iot/http_example/system-test/cloudiot_http_example_test.js b/iot/http_example/system-test/cloudiot_http_example_test.js new file mode 100644 index 0000000000..f20ece831d --- /dev/null +++ b/iot/http_example/system-test/cloudiot_http_example_test.js @@ -0,0 +1,118 @@ +/** + * Copyright 2017, Google, Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +const path = require(`path`); +const PubSub = require(`@google-cloud/pubsub`); +const test = require(`ava`); +const tools = require(`@google-cloud/nodejs-repo-tools`); +const uuid = require(`uuid`); + +const deviceId = `test-node-device`; +const topicName = `nodejs-docs-samples-test-iot-${uuid.v4()}`; +const registryName = `nodejs-test-registry-iot-${uuid.v4()}`; +const helper = `node ../manager/manager.js`; +const cmd = `node cloudiot_http_example.js --registry_id="${registryName}" --device_id="${deviceId}" `; +const cwd = path.join(__dirname, `..`); + +test.before(tools.checkCredentials); +test.before(async () => { + const pubsub = PubSub(); + return pubsub.createTopic(topicName) + .then((results) => { + const topic = results[0]; + console.log(`Topic ${topic.name} created.`); + return topic; + }); +}); + +test.after.always(async () => { + const pubsub = PubSub(); + const topic = pubsub.topic(topicName); + return topic.delete() + .then(() => { + console.log(`Topic ${topic.name} deleted.`); + }); +}); + +test(`should receive configuration message`, async (t) => { + const localDevice = `test-rsa-device`; + const localRegName = `${registryName}-rsa256`; + let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRegistry ${localRegName} ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); + t.regex(output, new RegExp(`Created device`)); + + output = await tools.runAsync( + `${cmd} --message_type=events --num_messages=1 --private_key_file=resources/rsa_private.pem --algorithm=RS256`, cwd); + + t.regex(output, new RegExp(`Getting config`)); + + // Check / cleanup + output = await tools.runAsync( + `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); + t.regex(output, new RegExp(`State`)); + output = await tools.runAsync( + `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); + t.regex(output, new RegExp(`Successfully deleted device`)); + output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); +}); + +test(`should send event message`, async (t) => { + const localDevice = `test-rsa-device`; + const localRegName = `${registryName}-rsa256`; + let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRegistry ${localRegName} ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); + + output = await tools.runAsync( + `${cmd} --message_type=events --num_messages=1 --private_key_file=resources/rsa_private.pem --algorithm=RS256`, cwd); + + t.regex(output, new RegExp(`Publishing message`)); + + // Check / cleanup + output = await tools.runAsync( + `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync( + `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); +}); + +test(`should send event message`, async (t) => { + const localDevice = `test-rsa-device`; + const localRegName = `${registryName}-rsa256`; + let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRegistry ${localRegName} ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); + + output = await tools.runAsync( + `${cmd} --message_type=state --num_messages=1 --private_key_file=resources/rsa_private.pem --algorithm=RS256`, cwd); + + t.regex(output, new RegExp(`Publishing message`)); + + // Check / cleanup + output = await tools.runAsync( + `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync( + `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); +}); From a6f8b43111c7866683effcf4c53f92c981510bce Mon Sep 17 00:00:00 2001 From: Gus Class Date: Thu, 14 Dec 2017 13:47:37 -0800 Subject: [PATCH 2/6] Adds tests for MQTT sample --- .../cloudiot_mqtt_example_nodejs.js | 45 +++++-- iot/mqtt_example/package.json | 8 +- iot/mqtt_example/resources/README.md | 4 + iot/mqtt_example/resources/rsa_cert.pem | 18 +++ iot/mqtt_example/resources/rsa_private.pem | 28 ++++ .../system-test/cloudiot_http_example_test.js | 121 ++++++++++++++++++ 6 files changed, 208 insertions(+), 16 deletions(-) create mode 100644 iot/mqtt_example/resources/README.md create mode 100644 iot/mqtt_example/resources/rsa_cert.pem create mode 100644 iot/mqtt_example/resources/rsa_private.pem create mode 100644 iot/mqtt_example/system-test/cloudiot_http_example_test.js diff --git a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js index a2ac0bdda9..3d5bace315 100644 --- a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js +++ b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js @@ -142,20 +142,29 @@ function publishAsync (messageCount, numMessages) { connectionArgs.password = createJwt(argv.project_id, argv.private_key_file, argv.algorithm); client = mqtt.connect(connectionArgs); - client.on('connect', () => { - console.log('connect', arguments); + client.on('connect', (success) => { + console.log('connect'); + if (success) { + publishAsync(1, argv.num_messages); + } else { + console.log('Client not connected...'); + } }); client.on('close', () => { - console.log('close', arguments); + console.log('close'); }); - client.on('error', () => { - console.log('error', arguments); + client.on('error', (err) => { + console.log('error', err); + }); + + client.on('message', (topic, message, packet) => { + console.log('message received: ', new Buffer(message, 'base64').toString('ascii')); }); client.on('packetsend', () => { - // Too verbose to log here + // Note: logging packet send is very verbose }); } publishAsync(messageCount + 1, numMessages); @@ -191,25 +200,33 @@ let connectionArgs = { let iatTime = parseInt(Date.now() / 1000); let client = mqtt.connect(connectionArgs); +client.subscribe(`/devices/${argv.device_id}/config`); + // The MQTT topic that this device will publish data to. The MQTT // topic name is required to be in the format below. The topic name must end in // 'state' to publish state and 'events' to publish telemetry. Note that this is // not the same as the device registry's Cloud Pub/Sub topic. const mqttTopic = `/devices/${argv.device_id}/${argv.message_type}`; -client.on('connect', () => { - console.log('connect', arguments); - // After connecting, publish 'num_messages' messagse asynchronously, at a rate - // of 1 per second for telemetry events and 1 every 2 seconds for states. - publishAsync(1, argv.num_messages); +client.on('connect', (success) => { + console.log('connect'); + if (success) { + publishAsync(1, argv.num_messages); + } else { + console.log('Client not connected...'); + } }); client.on('close', () => { - console.log('close', arguments); + console.log('close'); +}); + +client.on('error', (err) => { + console.log('error', err); }); -client.on('error', () => { - console.log('error', arguments); +client.on('message', (topic, message, packet) => { + console.log('message received: ', new Buffer(message, 'base64').toString('ascii')); }); client.on('packetsend', () => { diff --git a/iot/mqtt_example/package.json b/iot/mqtt_example/package.json index 6a8c79eaf5..ea886891a8 100644 --- a/iot/mqtt_example/package.json +++ b/iot/mqtt_example/package.json @@ -6,9 +6,13 @@ "license": "Apache-2.0", "author": "Google Inc.", "dependencies": { - "yargs": "8.0.2", + "@google-cloud/pubsub": "0.13.2", + "@google-cloud/nodejs-repo-tools": "1.4.17", + "ava": "0.22.0", "jsonwebtoken": "7.4.1", - "mqtt": "2.7.2" + "mqtt": "2.7.2", + "uuid": "3.1.0", + "yargs": "8.0.2" }, "devDependencies": {} } diff --git a/iot/mqtt_example/resources/README.md b/iot/mqtt_example/resources/README.md new file mode 100644 index 0000000000..29a1f453ee --- /dev/null +++ b/iot/mqtt_example/resources/README.md @@ -0,0 +1,4 @@ +# Test public certificate files + +The certificates in this folder are only provided for testing and should not be +used for registering or connecting your devices. diff --git a/iot/mqtt_example/resources/rsa_cert.pem b/iot/mqtt_example/resources/rsa_cert.pem new file mode 100644 index 0000000000..d81ae7c4f4 --- /dev/null +++ b/iot/mqtt_example/resources/rsa_cert.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC9TCCAd2gAwIBAgIJALM44e3ivEWkMA0GCSqGSIb3DQEBCwUAMBExDzANBgNV +BAMMBnVudXNlZDAeFw0xNzEyMDcwMDQ1MjdaFw0yNzEyMDUwMDQ1MjdaMBExDzAN +BgNVBAMMBnVudXNlZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL4w +BxHuEyYdbiwKiD8yXY7vYpcygeOQ4/ZdEg3wCB2OuYcaFRcCuqLcTLMnuzdcL+y3 +HBjWkrRW658cg3NG93Vj0iwSrga6u24CGBNYV+h8MBvwaDxk+uubnd5M/Q2OyL1J +GiMxQ1blR/71Hr5hhqaQZ2+qOF6kuf1m9rLUtMUJwOKp/PjPDmy654ZGsFWFSZmy +eRpNzmGU+KJg0o+Qf+sm75a8gQZ8AsrqveW0S/8o+zAjD0SkPcd01QBmYzQhjbi/ +LGGITrzbaB3ld9umJBIcXfnYPYisJfwSsT/jFwiXhrhpxNNaIaKlTzlQIt5l8bSs +HXzJBbuIg5Jb/SyIEpkCAwEAAaNQME4wHQYDVR0OBBYEFOfaQTUVAoNb6fc7qzzl +uKyHGrCYMB8GA1UdIwQYMBaAFOfaQTUVAoNb6fc7qzzluKyHGrCYMAwGA1UdEwQF +MAMBAf8wDQYJKoZIhvcNAQELBQADggEBALKKDtiV1YV8k0YsNdiIXRlS3jsuoGuI +VVBrvDGz5Hel0rH9YmmfPS/Yn08kk3DF8Uynr4Xo1Zt9hmhgoq3ZoWm7MIP1+a9s +WyACyEMhVQSCzQrexRvG5ElpHx/vNjbcwiBkE5urlIvMBVt+BRRNKMNWq6F9ae63 +FxRp7CtNFSbibtLJuPgCs6qoNs0nlt2FPsNvs7jpPipj69o+egVckvQjAyppirWO ++jO5hCLy7EahLz2wCn90z0Xf9lhOZni9meaV1Vy3CHHg6jwIB8/XlRaHFrOGMGXg +h8eQqsmpk9/3o8pv00yj6Hkq+swVg7Rg9FZaUiOv/HO/J7stWU7qPbI= +-----END CERTIFICATE----- diff --git a/iot/mqtt_example/resources/rsa_private.pem b/iot/mqtt_example/resources/rsa_private.pem new file mode 100644 index 0000000000..06a66e3d40 --- /dev/null +++ b/iot/mqtt_example/resources/rsa_private.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC+MAcR7hMmHW4s +Cog/Ml2O72KXMoHjkOP2XRIN8AgdjrmHGhUXArqi3EyzJ7s3XC/stxwY1pK0Vuuf +HINzRvd1Y9IsEq4GurtuAhgTWFfofDAb8Gg8ZPrrm53eTP0Njsi9SRojMUNW5Uf+ +9R6+YYamkGdvqjhepLn9Zvay1LTFCcDiqfz4zw5suueGRrBVhUmZsnkaTc5hlPii +YNKPkH/rJu+WvIEGfALK6r3ltEv/KPswIw9EpD3HdNUAZmM0IY24vyxhiE6822gd +5XfbpiQS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AgeUAbQ +D+2iVhZf61josFiRuMP3t9paEi+vAFk4C3KSz/ECgYBpi1akpIzsYehW5uOL7Jhw +Hay5eshQ4vmHYuhDnn3gtT3h6J7TMwWs9pOygBG1I1b7GJ+tp4BZWJ2PmI7P8s45 +jdI99WODHwv03lAzjLwigoqDUDduaYqXcGghcGht5Sknkl2uYDChwLtI5JdBZ9/x +8h9dE9oAiH/KTzhPmK1E1Q== +-----END PRIVATE KEY----- diff --git a/iot/mqtt_example/system-test/cloudiot_http_example_test.js b/iot/mqtt_example/system-test/cloudiot_http_example_test.js new file mode 100644 index 0000000000..bb844769e6 --- /dev/null +++ b/iot/mqtt_example/system-test/cloudiot_http_example_test.js @@ -0,0 +1,121 @@ +/** + * Copyright 2017, Google, Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +const path = require(`path`); +const PubSub = require(`@google-cloud/pubsub`); +const test = require(`ava`); +const tools = require(`@google-cloud/nodejs-repo-tools`); +const uuid = require(`uuid`); + +const deviceId = `test-node-device`; +const topicName = `nodejs-docs-samples-test-iot-${uuid.v4()}`; +const registryName = `nodejs-test-registry-iot-${uuid.v4()}`; +const helper = `node ../manager/manager.js`; +const cmd = `node cloudiot_mqtt_example_nodejs.js `; +const cmdSuffix = ` --num_messages=1 --private_key_file=resources/rsa_private.pem --algorithm=RS256`; +const cwd = path.join(__dirname, `..`); + + +test.before(tools.checkCredentials); +test.before(async () => { + const pubsub = PubSub(); + return pubsub.createTopic(topicName) + .then((results) => { + const topic = results[0]; + console.log(`Topic ${topic.name} created.`); + return topic; + }); +}); + +test.after.always(async () => { + const pubsub = PubSub(); + const topic = pubsub.topic(topicName); + return topic.delete() + .then(() => { + console.log(`Topic ${topic.name} deleted.`); + }); +}); + +test(`should receive configuration message`, async (t) => { + const localDevice = `test-rsa-device`; + const localRegName = `${registryName}-rsa256`; + + let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRegistry ${localRegName} ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); + t.regex(output, new RegExp(`Created device`)); + + output = await tools.runAsync( + `${cmd} --message_type=events --registry_id="${localRegName}" --device_id="${localDevice}" ${cmdSuffix}`, + cwd); + t.regex(output, new RegExp(`message received`)); + + // Check / cleanup + output = await tools.runAsync( + `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); + t.regex(output, new RegExp(`State`)); + output = await tools.runAsync( + `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); + t.regex(output, new RegExp(`Successfully deleted device`)); + output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); +}); + +test(`should send event message`, async (t) => { + const localDevice = `test-rsa-device`; + const localRegName = `${registryName}-rsa256`; + let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRegistry ${localRegName} ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); + + output = await tools.runAsync( + `${cmd} --message_type=events --registry_id="${localRegName}" --device_id="${localDevice}" ${cmdSuffix}`, + cwd); + t.regex(output, new RegExp(`Publishing message:`)); + + // Check / cleanup + output = await tools.runAsync( + `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync( + `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); +}); + +test(`should send event message`, async (t) => { + const localDevice = `test-rsa-device`; + const localRegName = `${registryName}-rsa256`; + let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRegistry ${localRegName} ${topicName}`, cwd); + output = await tools.runAsync( + `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); + + output = await tools.runAsync( + `${cmd} --message_type=state --registry_id="${localRegName}" --device_id="${localDevice}" ${cmdSuffix}`, + cwd); + t.regex(output, new RegExp(`Publishing message:`)); + + // Check / cleanup + output = await tools.runAsync( + `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync( + `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); + output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); +}); From aa3cf91672aa564f2ad90e1ac3406eb797be6adb Mon Sep 17 00:00:00 2001 From: Gus Class Date: Thu, 14 Dec 2017 13:53:06 -0800 Subject: [PATCH 3/6] A few nits from semistandard. --- iot/mqtt_example/cloudiot_mqtt_example_nodejs.js | 4 ++-- iot/mqtt_example/system-test/cloudiot_http_example_test.js | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js index 3d5bace315..8179551fb0 100644 --- a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js +++ b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js @@ -160,7 +160,7 @@ function publishAsync (messageCount, numMessages) { }); client.on('message', (topic, message, packet) => { - console.log('message received: ', new Buffer(message, 'base64').toString('ascii')); + console.log('message received: ', Buffer.from(message, 'base64').toString('ascii')); }); client.on('packetsend', () => { @@ -226,7 +226,7 @@ client.on('error', (err) => { }); client.on('message', (topic, message, packet) => { - console.log('message received: ', new Buffer(message, 'base64').toString('ascii')); + console.log('message received: ', Buffer.from(message, 'base64').toString('ascii')); }); client.on('packetsend', () => { diff --git a/iot/mqtt_example/system-test/cloudiot_http_example_test.js b/iot/mqtt_example/system-test/cloudiot_http_example_test.js index bb844769e6..23bf6fb2b2 100644 --- a/iot/mqtt_example/system-test/cloudiot_http_example_test.js +++ b/iot/mqtt_example/system-test/cloudiot_http_example_test.js @@ -21,7 +21,6 @@ const test = require(`ava`); const tools = require(`@google-cloud/nodejs-repo-tools`); const uuid = require(`uuid`); -const deviceId = `test-node-device`; const topicName = `nodejs-docs-samples-test-iot-${uuid.v4()}`; const registryName = `nodejs-test-registry-iot-${uuid.v4()}`; const helper = `node ../manager/manager.js`; @@ -29,7 +28,6 @@ const cmd = `node cloudiot_mqtt_example_nodejs.js `; const cmdSuffix = ` --num_messages=1 --private_key_file=resources/rsa_private.pem --algorithm=RS256`; const cwd = path.join(__dirname, `..`); - test.before(tools.checkCredentials); test.before(async () => { const pubsub = PubSub(); From e0379ee7a74e051157c416e776360098c410a868 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Tue, 19 Dec 2017 22:39:27 -0800 Subject: [PATCH 4/6] Adds setting device configuration to manager. --- iot/manager/README.md | 26 +++++++++++++---------- iot/manager/manager.js | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/iot/manager/README.md b/iot/manager/README.md index 2738227ad5..eda812987b 100644 --- a/iot/manager/README.md +++ b/iot/manager/README.md @@ -30,6 +30,7 @@ Run the following command to install the library dependencies for NodeJS: listDevices Lists the devices in a given registry. patchEs256 Patches a device with ES256 authorization credentials. patchRsa256 Patches a device with RSA256 authentication credentials. + setConfig Sets a devices configuration to the specified data. Options: --projectId, -p The Project ID to use. Defaults to the value of the GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT @@ -39,18 +40,21 @@ Run the following command to install the library dependencies for NodeJS: --cloudRegion, -c [string] [default: "us-central1"] Examples: - node manager.js createEs256Device my-es-device my-registry ../ec_public.pem --serviceAccount=$HOME/creds_iot.json + node manager.js createEs256Device my-es-device my-registry ../ec_public.pem node manager.js createRegistry my-registry my-iot-topic --serviceAccount=$HOME/creds_iot.json - --api_key=abc123zz --project_id=my-project-id - node manager.js createRsa256Device my-rsa-device my-registry ../rsa_cert.pem --serviceAccount=$HOME/creds_iot.json - node manager.js createUnauthDevice my-device my-registry --serviceAccount=$HOME/creds_iot.json - node manager.js deleteDevice my-device my-registry --serviceAccount=$HOME/creds_iot.json - node manager.js deleteRegistry my-device my-registry --serviceAccount=$HOME/creds_iot.json - node manager.js getDevice my-device my-registry --serviceAccount=$HOME/creds_iot.json - node manager.js listDevices my-node-registry --serviceAccount=$HOME/creds_iot.json - node manager.js patchRsa256 my-device my-registry ../rsa_cert.pem --serviceAccount=$HOME/creds_iot.json - node manager.js patchEs256 my-device my-registry ../ec_public.pem --serviceAccount=$HOME/creds_iot.json - node manager.js setupTopic my-iot-topic --serviceAccount=$HOME/creds_iot.json --project_id=my-project-id + node manager.js createRsa256Device my-rsa-device my-registry ../rsa_cert.pem + node manager.js createUnauthDevice my-device my-registry + node manager.js deleteDevice my-device my-registry + node manager.js deleteRegistry my-device my-registry + node manager.js getDevice my-device my-registry + node manager.js getDeviceState my-device my-registry + node manager.js getRegistry my-registry + node manager.js listDevices my-node-registry + node manager.js listRegistries + node manager.js patchRsa256 my-device my-registry ../rsa_cert.pem + node manager.js patchEs256 my-device my-registry ../ec_public.pem + node manager.js setConfig my-device my-registry "test" 0 + node manager.js setupTopic my-iot-topic --serviceAccount=$HOME/creds_iot.json --projectId=my-project-id For more information, see https://cloud.google.com/iot-core/docs diff --git a/iot/manager/manager.js b/iot/manager/manager.js index a4da810365..1ed24e8d46 100644 --- a/iot/manager/manager.js +++ b/iot/manager/manager.js @@ -573,6 +573,40 @@ function getDeviceState (client, deviceId, registryId, projectId, // [END iot_get_device_state] } +// Retrieve the given device's state from the registry. +function setDeviceConfig (client, deviceId, registryId, projectId, + cloudRegion, data, version) { + // [START iot_get_device_state] + // Client retrieved in callback + // getClient(serviceAccountJson, function(client) {...}); + // const cloudRegion = 'us-central1'; + // const deviceId = 'my-device'; + // const projectId = 'adjective-noun-123'; + // const registryId = 'my-registry'; + // const data = 'test-data'; + // const version = 0; + const parentName = `projects/${projectId}/locations/${cloudRegion}`; + const registryName = `${parentName}/registries/${registryId}`; + + const binaryData = Buffer.from(data).toString('base64'); + const request = { + name: `${registryName}/devices/${deviceId}`, + versionToUpdate: version, + binaryData: binaryData + }; + + client.projects.locations.registries.devices.modifyCloudToDeviceConfig(request, + (err, data) => { + if (err) { + console.log('Could not update config:', deviceId); + console.log('Message: ', err); + } else { + console.log('Success :', data); + } + }); + // [END iot_get_device_state] +} + // Retrieve the given device from the registry. function getRegistry (client, registryId, projectId, cloudRegion) { // [START iot_get_registry] @@ -823,6 +857,19 @@ require(`yargs`) // eslint-disable-line getClient(opts.serviceAccount, cb); } ) + .command( + `setConfig `, + `Sets a devices configuration to the specified data.`, + {}, + (opts) => { + const cb = function (client) { + setDeviceConfig(client, opts.deviceId, opts.registryId, + opts.projectId, opts.cloudRegion, opts.configuration, + opts.version || 0); + }; + getClient(opts.serviceAccount, cb); + } + ) .example(`node $0 createEs256Device my-es-device my-registry ../ec_public.pem`) .example(`node $0 createRegistry my-registry my-iot-topic --serviceAccount=$HOME/creds_iot.json --project_id=my-project-id`) .example(`node $0 createRsa256Device my-rsa-device my-registry ../rsa_cert.pem`) @@ -836,6 +883,7 @@ require(`yargs`) // eslint-disable-line .example(`node $0 listRegistries`) .example(`node $0 patchRsa256 my-device my-registry ../rsa_cert.pem`) .example(`node $0 patchEs256 my-device my-registry ../ec_public.pem`) + .example(`node $0 setConfig my-device my-registry "test" 0`) .example(`node $0 setupTopic my-iot-topic --serviceAccount=$HOME/creds_iot.json --projectId=my-project-id`) .wrap(120) .recommendCommands() From 08da05c292760b5de5463746f30002715489092e Mon Sep 17 00:00:00 2001 From: Gus Class Date: Wed, 20 Dec 2017 01:37:37 -0800 Subject: [PATCH 5/6] Fixes from http in tests / naming --- iot/manager/manager.js | 4 +- .../cloudiot_mqtt_example_nodejs.js | 46 ++++++++--------- ..._test.js => cloudiot_mqtt_example_test.js} | 49 +++++++++---------- 3 files changed, 48 insertions(+), 51 deletions(-) rename iot/mqtt_example/system-test/{cloudiot_http_example_test.js => cloudiot_mqtt_example_test.js} (69%) diff --git a/iot/manager/manager.js b/iot/manager/manager.js index 1ed24e8d46..9394a68e17 100644 --- a/iot/manager/manager.js +++ b/iot/manager/manager.js @@ -576,7 +576,7 @@ function getDeviceState (client, deviceId, registryId, projectId, // Retrieve the given device's state from the registry. function setDeviceConfig (client, deviceId, registryId, projectId, cloudRegion, data, version) { - // [START iot_get_device_state] + // [START iot_set_device_config] // Client retrieved in callback // getClient(serviceAccountJson, function(client) {...}); // const cloudRegion = 'us-central1'; @@ -604,7 +604,7 @@ function setDeviceConfig (client, deviceId, registryId, projectId, console.log('Success :', data); } }); - // [END iot_get_device_state] + // [END iot_set_device_config] } // Retrieve the given device from the registry. diff --git a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js index 8179551fb0..0e2040300d 100644 --- a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js +++ b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js @@ -24,31 +24,31 @@ const mqtt = require('mqtt'); console.log('Google Cloud IoT Core MQTT example.'); var argv = require(`yargs`) .options({ - project_id: { + projectId: { default: process.env.GCLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT, description: 'The Project ID to use. Defaults to the value of the GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variables.', requiresArg: true, type: 'string' }, - cloud_region: { + cloudRegion: { default: 'us-central1', description: 'GCP cloud region.', requiresArg: true, type: 'string' }, - registry_id: { + registryId: { description: 'Cloud IoT registry ID.', requiresArg: true, demandOption: true, type: 'string' }, - device_id: { + deviceId: { description: 'Cloud IoT device ID.', requiresArg: true, demandOption: true, type: 'string' }, - private_key_file: { + privateKeyFile: { description: 'Path to private key file.', requiresArg: true, demandOption: true, @@ -61,31 +61,31 @@ var argv = require(`yargs`) choices: ['RS256', 'ES256'], type: 'string' }, - num_messages: { + numMessages: { default: 100, description: 'Number of messages to publish.', requiresArg: true, type: 'number' }, - token_exp_mins: { + tokenExpMins: { default: 20, description: 'Minutes to JWT token expiration.', requiresArg: true, type: 'number' }, - mqtt_bridge_hostname: { + mqttBridgeHostname: { default: 'mqtt.googleapis.com', description: 'MQTT bridge hostname.', requiresArg: true, type: 'string' }, - mqtt_bridge_port: { + mqttBridgePort: { default: 8883, description: 'MQTT bridge port.', requiresArg: true, type: 'number' }, - message_type: { + messageType: { default: 'events', description: 'Message type to publish.', requiresArg: true, @@ -93,7 +93,7 @@ var argv = require(`yargs`) type: 'string' } }) - .example(`node $0 cloudiot_mqtt_example_nodejs.js --project_id=blue-jet-123 --registry_id=my-registry --device_id=my-node-device --private_key_file=../rsa_private.pem --algorithm=RS256`) + .example(`node $0 cloudiot_mqtt_example_nodejs.js --projectId=blue-jet-123 --registryId=my-registry --deviceId=my-node-device --privateKeyFile=../rsa_private.pem --algorithm=RS256`) .wrap(120) .recommendCommands() .epilogue(`For more information, see https://cloud.google.com/iot-core/docs`) @@ -122,30 +122,30 @@ function createJwt (projectId, privateKeyFile, algorithm) { // messageCount. // [START iot_mqtt_publish] function publishAsync (messageCount, numMessages) { - const payload = `${argv.registry_id}/${argv.device_id}-payload-${messageCount}`; + const payload = `${argv.registryId}/${argv.deviceId}-payload-${messageCount}`; // Publish "payload" to the MQTT topic. qos=1 means at least once delivery. // Cloud IoT Core also supports qos=0 for at most once delivery. console.log('Publishing message:', payload); client.publish(mqttTopic, payload, { qos: 1 }); - const delayMs = argv.message_type === 'events' ? 1000 : 2000; + const delayMs = argv.messageType === 'events' ? 1000 : 2000; if (messageCount < numMessages) { // If we have published fewer than numMessage messages, publish payload // messageCount + 1 in 1 second. setTimeout(function () { let secsFromIssue = parseInt(Date.now() / 1000) - iatTime; - if (secsFromIssue > argv.token_exp_mins * 60) { + if (secsFromIssue > argv.tokenExpMins * 60) { iatTime = parseInt(Date.now() / 1000); console.log(`\tRefreshing token after ${secsFromIssue} seconds.`); client.end(); - connectionArgs.password = createJwt(argv.project_id, argv.private_key_file, argv.algorithm); + connectionArgs.password = createJwt(argv.projectId, argv.privateKeyFile, argv.algorithm); client = mqtt.connect(connectionArgs); client.on('connect', (success) => { console.log('connect'); if (success) { - publishAsync(1, argv.num_messages); + publishAsync(1, argv.numMessages); } else { console.log('Client not connected...'); } @@ -180,18 +180,18 @@ function publishAsync (messageCount, numMessages) { // [START iot_mqtt_run] // The mqttClientId is a unique string that identifies this device. For Google // Cloud IoT Core, it must be in the format below. -const mqttClientId = `projects/${argv.project_id}/locations/${argv.cloud_region}/registries/${argv.registry_id}/devices/${argv.device_id}`; +const mqttClientId = `projects/${argv.projectId}/locations/${argv.cloudRegion}/registries/${argv.registryId}/devices/${argv.deviceId}`; // With Google Cloud IoT Core, the username field is ignored, however it must be // non-empty. The password field is used to transmit a JWT to authorize the // device. The "mqtts" protocol causes the library to connect using SSL, which // is required for Cloud IoT Core. let connectionArgs = { - host: argv.mqtt_bridge_hostname, - port: argv.mqtt_bridge_port, + host: argv.mqttBridgeHostname, + port: argv.mqttBridgePort, clientId: mqttClientId, username: 'unused', - password: createJwt(argv.project_id, argv.private_key_file, argv.algorithm), + password: createJwt(argv.projectId, argv.privateKeyFile, argv.algorithm), protocol: 'mqtts', secureProtocol: 'TLSv1_2_method' }; @@ -200,18 +200,18 @@ let connectionArgs = { let iatTime = parseInt(Date.now() / 1000); let client = mqtt.connect(connectionArgs); -client.subscribe(`/devices/${argv.device_id}/config`); +client.subscribe(`/devices/${argv.deviceId}/config`); // The MQTT topic that this device will publish data to. The MQTT // topic name is required to be in the format below. The topic name must end in // 'state' to publish state and 'events' to publish telemetry. Note that this is // not the same as the device registry's Cloud Pub/Sub topic. -const mqttTopic = `/devices/${argv.device_id}/${argv.message_type}`; +const mqttTopic = `/devices/${argv.deviceId}/${argv.messageType}`; client.on('connect', (success) => { console.log('connect'); if (success) { - publishAsync(1, argv.num_messages); + publishAsync(1, argv.numMessages); } else { console.log('Client not connected...'); } diff --git a/iot/mqtt_example/system-test/cloudiot_http_example_test.js b/iot/mqtt_example/system-test/cloudiot_mqtt_example_test.js similarity index 69% rename from iot/mqtt_example/system-test/cloudiot_http_example_test.js rename to iot/mqtt_example/system-test/cloudiot_mqtt_example_test.js index 23bf6fb2b2..f901807648 100644 --- a/iot/mqtt_example/system-test/cloudiot_http_example_test.js +++ b/iot/mqtt_example/system-test/cloudiot_mqtt_example_test.js @@ -25,7 +25,7 @@ const topicName = `nodejs-docs-samples-test-iot-${uuid.v4()}`; const registryName = `nodejs-test-registry-iot-${uuid.v4()}`; const helper = `node ../manager/manager.js`; const cmd = `node cloudiot_mqtt_example_nodejs.js `; -const cmdSuffix = ` --num_messages=1 --private_key_file=resources/rsa_private.pem --algorithm=RS256`; +const cmdSuffix = ` --numMessages=1 --privateKeyFile=resources/rsa_private.pem --algorithm=RS256`; const cwd = path.join(__dirname, `..`); test.before(tools.checkCredentials); @@ -53,67 +53,64 @@ test(`should receive configuration message`, async (t) => { const localRegName = `${registryName}-rsa256`; let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - output = await tools.runAsync( + await tools.runAsync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd); - output = await tools.runAsync( + await tools.runAsync( `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); - t.regex(output, new RegExp(`Created device`)); output = await tools.runAsync( - `${cmd} --message_type=events --registry_id="${localRegName}" --device_id="${localDevice}" ${cmdSuffix}`, + `${cmd} --messageType=events --registryId="${localRegName}" --deviceId="${localDevice}" ${cmdSuffix}`, cwd); t.regex(output, new RegExp(`message received`)); // Check / cleanup - output = await tools.runAsync( + await tools.runAsync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); - t.regex(output, new RegExp(`State`)); - output = await tools.runAsync( + await tools.runAsync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); - t.regex(output, new RegExp(`Successfully deleted device`)); - output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); }); test(`should send event message`, async (t) => { const localDevice = `test-rsa-device`; const localRegName = `${registryName}-rsa256`; - let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - output = await tools.runAsync( + await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + await tools.runAsync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd); - output = await tools.runAsync( + await tools.runAsync( `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); - output = await tools.runAsync( - `${cmd} --message_type=events --registry_id="${localRegName}" --device_id="${localDevice}" ${cmdSuffix}`, + const output = await tools.runAsync( + `${cmd} --messageType=events --registryId="${localRegName}" --deviceId="${localDevice}" ${cmdSuffix}`, cwd); t.regex(output, new RegExp(`Publishing message:`)); // Check / cleanup - output = await tools.runAsync( + await tools.runAsync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); - output = await tools.runAsync( + await tools.runAsync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); - output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); }); test(`should send event message`, async (t) => { const localDevice = `test-rsa-device`; const localRegName = `${registryName}-rsa256`; - let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - output = await tools.runAsync( + await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + await tools.runAsync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd); - output = await tools.runAsync( + await tools.runAsync( `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd); - output = await tools.runAsync( - `${cmd} --message_type=state --registry_id="${localRegName}" --device_id="${localDevice}" ${cmdSuffix}`, + const output = await tools.runAsync( + `${cmd} --messageType=state --registryId="${localRegName}" --deviceId="${localDevice}" ${cmdSuffix}`, cwd); t.regex(output, new RegExp(`Publishing message:`)); // Check / cleanup - output = await tools.runAsync( + await tools.runAsync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd); - output = await tools.runAsync( + await tools.runAsync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd); - output = await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); }); From f3a5414fb0e4dd488da7fdf2a2050cc8051fe733 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Wed, 20 Dec 2017 10:56:30 -0800 Subject: [PATCH 6/6] Changes RSA certs to not expire. --- iot/http_example/resources/rsa_cert.pem | 32 ++++++------- iot/http_example/resources/rsa_private.pem | 52 +++++++++++----------- iot/manager/resources/rsa_cert.pem | 33 +++++++------- iot/mqtt_example/resources/rsa_cert.pem | 32 ++++++------- iot/mqtt_example/resources/rsa_private.pem | 52 +++++++++++----------- 5 files changed, 100 insertions(+), 101 deletions(-) diff --git a/iot/http_example/resources/rsa_cert.pem b/iot/http_example/resources/rsa_cert.pem index d81ae7c4f4..db7c7fa344 100644 --- a/iot/http_example/resources/rsa_cert.pem +++ b/iot/http_example/resources/rsa_cert.pem @@ -1,18 +1,18 @@ -----BEGIN CERTIFICATE----- -MIIC9TCCAd2gAwIBAgIJALM44e3ivEWkMA0GCSqGSIb3DQEBCwUAMBExDzANBgNV -BAMMBnVudXNlZDAeFw0xNzEyMDcwMDQ1MjdaFw0yNzEyMDUwMDQ1MjdaMBExDzAN -BgNVBAMMBnVudXNlZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL4w -BxHuEyYdbiwKiD8yXY7vYpcygeOQ4/ZdEg3wCB2OuYcaFRcCuqLcTLMnuzdcL+y3 -HBjWkrRW658cg3NG93Vj0iwSrga6u24CGBNYV+h8MBvwaDxk+uubnd5M/Q2OyL1J -GiMxQ1blR/71Hr5hhqaQZ2+qOF6kuf1m9rLUtMUJwOKp/PjPDmy654ZGsFWFSZmy -eRpNzmGU+KJg0o+Qf+sm75a8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iZa02GJ2K +NBiwQa3LmHmcoaru2yTB9OTf1wGRY/QETrkmA+7enq7p2RQSe6uXu97k9UgV1Wes +c4QcJ/BAsLbaWB/f2h8CAwEAAaNTMFEwHQYDVR0OBBYEFCeNUvOsKm+BB9VgO1l1 +QlwS5rIEMB8GA1UdIwQYMBaAFCeNUvOsKm+BB9VgO1l1QlwS5rIEMA8GA1UdEwEB +/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAG/40RXw9lojT7aTJq7f196cL1v +qYiVNeZFE2Ki0iVjzDOk1SOXRqy8v8N4ay32gD+TZOg1Yy8loscKhGCnWIRepQC8 +1pyh2ZGHysICfHyxaKQgIMUzINSRI0E4bYt7kro497AodKN4P3QBH5Q6U7Ra3hG2 +b1dXOBVL0kUCKOnFuByEF2Zhytyhl3bTrm/W6dvhHBGTpB2RXwnldPnyEA4rmdyk +Ui9LYmEhWeizlBpw6jcXcd9qABrUMlxBt24DB3nKo/b8h6K4gXYfgO8yYbgsB+E6 +5wZGLi6nP5O98M+VmQZ5CBZSZid+sfK6eoT+Ca5vn7jSTQGzAIapc57dJEQ= -----END CERTIFICATE----- diff --git a/iot/http_example/resources/rsa_private.pem b/iot/http_example/resources/rsa_private.pem index 06a66e3d40..d627d8a8c5 100644 --- a/iot/http_example/resources/rsa_private.pem +++ b/iot/http_example/resources/rsa_private.pem @@ -1,28 +1,28 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC+MAcR7hMmHW4s -Cog/Ml2O72KXMoHjkOP2XRIN8AgdjrmHGhUXArqi3EyzJ7s3XC/stxwY1pK0Vuuf -HINzRvd1Y9IsEq4GurtuAhgTWFfofDAb8Gg8ZPrrm53eTP0Njsi9SRojMUNW5Uf+ -9R6+YYamkGdvqjhepLn9Zvay1LTFCcDiqfz4zw5suueGRrBVhUmZsnkaTc5hlPii -YNKPkH/rJu+WvIEGfALK6r3ltEv/KPswIw9EpD3HdNU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yo0vK2byMQdhaSfweB +eT7sD/TSmT7jqGEqW+jtf8mNQpAeQhJJKJ8AbERF5heKcMwk6CbFAUipc1TgCiuZ +335SyJRLUU1yUSvGqbMevUKAJQKBgQDZKAuyItjZFlyU2dVXYC8tALWjIaLwSsXw +SbCfhlMLUt7DTb8+V834ygPtEKagcaw4QwcB+brH6dO1vwL3KQWMOeZcUkXg8NCW +F71J84LLmUsZQkHx8HqLG6o/DUq+M1SuklMROAI14ZKtL0xMW/lIgICngENanUS8 +m/kT+zIr8wKBgQCAkBgQDybICellf+/vdvNNm7/rbE1vekxpxieQx2IKDOtsWqpv +2R91D+j6pIUjb4MqhJi0QHD8oPjIZ9wPB/XnOvD2nUftTw8qJjiEU7FdsHO+7MKf +5CnvDFXvwf9fHVLUXXZj4MkLYoSzRT4LNWstHHr6JF72VvNVBS92g3s1NQKBgQDN +Rw3HVymmDX13OHR0JHh0Ejeh/ioI/KYgf4h3RIM8MRpjhRtD07zhchZEA3mAMfSb +OsFlHK10TZXUOLyU6DJWXGVm4F8uRHbpa4eEYK1DyaU0O24bRziQR5aoA+ij4+Ip +JCliHY/5X0NIc22swUTlRJRZwuXowsI3iTnrqYnEAQKBgQC9AhF+S6d7uIsEOg7I +Kv8ndASx7Nfsy6OQfOltgLArV4w2POQjbPYsLLrz4s82mSpS205w2OzCfcUXKLxD +mswC0Bs/U3UmJW0d1oWfUm28FjGbzGYGfOLm1dPuyNW32FbZXvO4+jaIemjtg2U7 +avJDFdpNwVz/bVg0HWQWNP/C0A== -----END PRIVATE KEY----- diff --git a/iot/manager/resources/rsa_cert.pem b/iot/manager/resources/rsa_cert.pem index b41020505d..db7c7fa344 100644 --- a/iot/manager/resources/rsa_cert.pem +++ b/iot/manager/resources/rsa_cert.pem @@ -1,19 +1,18 @@ -----BEGIN CERTIFICATE----- -MIIDFzCCAf+gAwIBAgIJAP2XoKtudrz5MA0GCSqGSIb3DQEBBQUAMBExDzANBgNV -BAMTBnVudXNlZDAeFw0xNzA3MTEx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lZDAeFw0xNzEyMjAxODU0MzRaFw0yMDA5MTUxODU0MzRaMBExDzAN +BgNVBAMMBnVudXNlZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMc2 +pktp/RV1g7omV5CyNi1pQugZvxn6TciLqcjHP1XYfU6mnl7ySvH1xbkzaAlL/8Y8 +IqSFF4eI14qI71OT+7eLq6Ljj8j3XTqAtSANMSpi5KIRVQsa0h0rbRt7Xt1TeEd1 +ErVdzdRKrKvn7wM6UID0QGxC+1gpHGo3Aaz9Q4tVxAeWM6skCDh9WHea0HNj8MPA +hS4fc83PitfITOR9eCP2HW83HXu32yFpCU96WIQGSDfHfN7vD7mDXN+iZa02GJ2K +NBiwQa3LmHmcoaru2yTB9OTf1wGRY/QETrkmA+7enq7p2RQSe6uXu97k9UgV1Wes +c4QcJ/BAsLbaWB/f2h8CAwEAAaNTMFEwHQYDVR0OBBYEFCeNUvOsKm+BB9VgO1l1 +QlwS5rIEMB8GA1UdIwQYMBaAFCeNUvOsKm+BB9VgO1l1QlwS5rIEMA8GA1UdEwEB +/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAG/40RXw9lojT7aTJq7f196cL1v +qYiVNeZFE2Ki0iVjzDOk1SOXRqy8v8N4ay32gD+TZOg1Yy8loscKhGCnWIRepQC8 +1pyh2ZGHysICfHyxaKQgIMUzINSRI0E4bYt7kro497AodKN4P3QBH5Q6U7Ra3hG2 +b1dXOBVL0kUCKOnFuByEF2Zhytyhl3bTrm/W6dvhHBGTpB2RXwnldPnyEA4rmdyk +Ui9LYmEhWeizlBpw6jcXcd9qABrUMlxBt24DB3nKo/b8h6K4gXYfgO8yYbgsB+E6 +5wZGLi6nP5O98M+VmQZ5CBZSZid+sfK6eoT+Ca5vn7jSTQGzAIapc57dJEQ= -----END CERTIFICATE----- diff --git a/iot/mqtt_example/resources/rsa_cert.pem b/iot/mqtt_example/resources/rsa_cert.pem index d81ae7c4f4..db7c7fa344 100644 --- a/iot/mqtt_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T+Ca5vn7jSTQGzAIapc57dJEQ= -----END CERTIFICATE----- diff --git a/iot/mqtt_example/resources/rsa_private.pem b/iot/mqtt_example/resources/rsa_private.pem index 06a66e3d40..d627d8a8c5 100644 --- a/iot/mqtt_example/resources/rsa_private.pem +++ b/iot/mqtt_example/resources/rsa_private.pem @@ -1,28 +1,28 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC+MAcR7hMmHW4s -Cog/Ml2O72KXMoHjkOP2XRIN8AgdjrmHGhUXArqi3EyzJ7s3XC/stxwY1pK0Vuuf -HINzRvd1Y9IsEq4GurtuAhgTWFfofDAb8Gg8ZPrrm53eTP0Njsi9SRojMUNW5Uf+ -9R6+YYamkGdvqjhepLn9Zvay1LTFCcDiqfz4zw5suueGRrBVhUmZsnkaTc5hlPii -YNKPkH/rJu+WvIEGfALK6r3ltEv/KPswIw9EpD3HdNUAZmM0IY24vyxhiE6822gd -5XfbpiQSHF352D2IrCX8ErE/4xcIl4a4acTTWiGipU85UCLeZfG0rB18yQW7iIOS -W/0siBKZAgMBAAECggEAfwLmBdRfl2m6JNFX0hSZpJY72kuRsN8XTnUzVHmDgfHJ -9u61POvGpnLHCjIzdjIrk0NqETBjQup1aooJQ1gWdKAYQPSsobPc7geZ+nlaI9mj -61Su1/58EBKZ6Faz/HTpnHeQbAY/OW3fmeYrBOtumBgB6/HauWH7D77Oa/lfS+Ij -4f6OVAxevsi6PUtNmNtBwk5S0lZl9SFcKeHurVindquX9vWZjBEEFtNXazJttIJS -z9KX29VYwoLfflIKaUKckn8X+wYc+3u3BvH8zJpd60yQ6MSo7Sb1XkxT9549m+JW -Cb+i1K7MC/yQo4mvDtAQIVBh8p8qpd4VjpBwMuUbgQKBgQDexuAaLO3adSYFXGwW -nom6Mz/ImYcpxYo0ouAR1talbmF5/oKl9Tcwh7l1eDHfe70gfeP+g4uwAcc1hx3a -ZtXusrJFBktFezlFQnZXaE5ppryrF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