Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iot: add mqtt gateway samples to GA #1169

Merged
merged 7 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions iot/manager/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,10 +1381,10 @@ require(`yargs`) // eslint-disable-line
`Creates a device with the given public key. Public key can be ommitted and added later on.`,
{
publicKeyFormat: {
default: 'RS256_X509_PEM',
default: 'RSA_X509_PEM',
description: 'Public key format for devices.',
requiresArg: true,
choices: ['RS256_PEM', 'RS256_X509_PEM', 'ES256_PEM', 'ES256_X509_PEM'],
choices: ['RSA_PEM', 'RSA_X509_PEM', 'ES256_PEM', 'ES256_X509_PEM'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. We should probably add these options to the other samples.

type: 'string',
},
publicKeyFile: {
Expand Down Expand Up @@ -1671,7 +1671,21 @@ require(`yargs`) // eslint-disable-line
.command(
`createGateway <registryId> <gatewayId>`,
`Creates a gateway`,
{},
{
publicKeyFormat: {
default: 'RSA_X509_PEM',
description: 'Public key format for devices.',
requiresArg: true,
choices: ['RSA_PEM', 'RSA_X509_PEM', 'ES256_PEM', 'ES256_X509_PEM'],
type: 'string',
},
publicKeyFile: {
description:
'Path to the public key file used for device authentication.',
requiresArg: true,
type: 'string',
},
},
opts => {
const cb = function(client) {
createGateway(
Expand All @@ -1680,8 +1694,8 @@ require(`yargs`) // eslint-disable-line
opts.cloudRegion,
opts.registryId,
opts.gatewayId,
opts.publicKeyFile,
opts.publicKeyFormat
opts.publicKeyFormat,
opts.publicKeyFile
);
};
getClient(opts.serviceAccount, cb);
Expand Down
12 changes: 6 additions & 6 deletions iot/manager/system-test/manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ test(`should send command message to device`, async t => {
);

tools.runAsync(
`node cloudiot_mqtt_example_nodejs.js --deviceId=${deviceId} --registryId=${registryName} --privateKeyFile=${rsaPrivateKey} --algorithm=RS256 --numMessages=20 --mqttBridgePort=443`,
`node cloudiot_mqtt_example_nodejs.js mqttDeviceDemo --deviceId=${deviceId} --registryId=${registryName} --privateKeyFile=${rsaPrivateKey} --algorithm=RS256 --numMessages=20 --mqttBridgePort=443`,
path.join(__dirname, '../../mqtt_example')
);

Expand All @@ -283,7 +283,7 @@ test(`should send command message to device`, async t => {
test(`should create a new gateway`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
let gatewayOut = await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// test no error on create gateway.
Expand All @@ -297,7 +297,7 @@ test(`should create a new gateway`, async t => {
test(`should list gateways`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// look for output in list gateway
Expand All @@ -312,7 +312,7 @@ test(`should list gateways`, async t => {
test(`should bind existing device to gateway`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// create device
Expand Down Expand Up @@ -350,7 +350,7 @@ test(`should bind existing device to gateway`, async t => {
test(`should list devices bound to gateway`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

const deviceId = `nodejs-test-device-iot-${uuid.v4()}`;
Expand Down Expand Up @@ -389,7 +389,7 @@ test(`should list devices bound to gateway`, async t => {
test(`should list gateways for bound device`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// create device
Expand Down
Loading