diff --git a/.kokoro/secrets-example.sh b/.kokoro/secrets-example.sh index 173d9aa062..2c5baeb92b 100644 --- a/.kokoro/secrets-example.sh +++ b/.kokoro/secrets-example.sh @@ -89,9 +89,6 @@ export IAP_URL= # IAM export GOOGLE_IAM_USER= -# IOT -export GOOGLE_IOT_DEVICE_CERTIFICATE_B64= - # KMS export GOOGLE_KMS_KEYRING= export GOOGLE_KMS_CRYPTOKEY= diff --git a/.kokoro/secrets.sh.enc b/.kokoro/secrets.sh.enc index 8bb4b60e69..674eb36e25 100644 Binary files a/.kokoro/secrets.sh.enc and b/.kokoro/secrets.sh.enc differ diff --git a/iot/composer.json b/iot/composer.json deleted file mode 100644 index 01dc46a43f..0000000000 --- a/iot/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "google/iot-sample", - "type": "project", - "require": { - "google/cloud-iot": "^1.0.0" - } -} diff --git a/iot/phpunit.xml.dist.deprecated b/iot/phpunit.xml.dist.deprecated deleted file mode 100644 index b4718b587d..0000000000 --- a/iot/phpunit.xml.dist.deprecated +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - test - - - - - - - - ./src - - ./vendor - - - - - - - diff --git a/iot/src/bind_device_to_gateway.php b/iot/src/bind_device_to_gateway.php deleted file mode 100644 index d9fcfbed0e..0000000000 --- a/iot/src/bind_device_to_gateway.php +++ /dev/null @@ -1,53 +0,0 @@ -registryName($projectId, $location, $registryId); - - $result = $deviceManager->bindDeviceToGateway($registryName, $gatewayId, $deviceId); - - print('Device bound'); -} -# [END iot_bind_device_to_gateway] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/create_es_device.php b/iot/src/create_es_device.php deleted file mode 100644 index e35829b52d..0000000000 --- a/iot/src/create_es_device.php +++ /dev/null @@ -1,71 +0,0 @@ -registryName($projectId, $location, $registryId); - - $publicKey = (new PublicKeyCredential()) - ->setFormat(PublicKeyFormat::ES256_PEM) - ->setKey(file_get_contents($publicKeyFile)); - - $credential = (new DeviceCredential()) - ->setPublicKey($publicKey); - - $device = (new Device()) - ->setId($deviceId) - ->setCredentials([$credential]); - - $device = $deviceManager->createDevice($registryName, $device); - - printf('Device: %s : %s' . PHP_EOL, - $device->getNumId(), - $device->getId()); -} -# [END iot_create_es_device] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/create_gateway.php b/iot/src/create_gateway.php deleted file mode 100644 index 4779be53a7..0000000000 --- a/iot/src/create_gateway.php +++ /dev/null @@ -1,85 +0,0 @@ -registryName($projectId, $location, $registryId); - - $publicKeyFormat = PublicKeyFormat::ES256_PEM; - if ($algorithm == 'RS256') { - $publicKeyFormat = PublicKeyFormat::RSA_X509_PEM; - } - - $gatewayConfig = (new GatewayConfig()) - ->setGatewayType(GatewayType::GATEWAY) - ->setGatewayAuthMethod(GatewayAuthMethod::ASSOCIATION_ONLY); - - $publicKey = (new PublicKeyCredential()) - ->setFormat($publicKeyFormat) - ->setKey(file_get_contents($certificateFile)); - - $credential = (new DeviceCredential()) - ->setPublicKey($publicKey); - - $device = (new Device()) - ->setId($gatewayId) - ->setGatewayConfig($gatewayConfig) - ->setCredentials([$credential]); - - $gateway = $deviceManager->createDevice($registryName, $device); - - printf('Gateway: %s : %s' . PHP_EOL, - $gateway->getNumId(), - $gateway->getId()); -} -# [END iot_create_gateway] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/create_registry.php b/iot/src/create_registry.php deleted file mode 100644 index 0e022b5bc2..0000000000 --- a/iot/src/create_registry.php +++ /dev/null @@ -1,68 +0,0 @@ -locationName($projectId, $location); - - $pubsubTopicPath = sprintf('projects/%s/topics/%s', $projectId, $pubsubTopic); - $eventNotificationConfig = (new EventNotificationConfig) - ->setPubsubTopicName($pubsubTopicPath); - - $registry = (new DeviceRegistry) - ->setId($registryId) - ->setEventNotificationConfigs([$eventNotificationConfig]); - - $registry = $deviceManager->createDeviceRegistry($locationName, $registry); - - printf('Id: %s, Name: %s' . PHP_EOL, - $registry->getId(), - $registry->getName()); -} -# [END iot_create_registry] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/create_rsa_device.php b/iot/src/create_rsa_device.php deleted file mode 100644 index 47bd109155..0000000000 --- a/iot/src/create_rsa_device.php +++ /dev/null @@ -1,71 +0,0 @@ -registryName($projectId, $location, $registryId); - - $publicKey = (new PublicKeyCredential()) - ->setFormat(PublicKeyFormat::RSA_X509_PEM) - ->setKey(file_get_contents($certificateFile)); - - $credential = (new DeviceCredential()) - ->setPublicKey($publicKey); - - $device = (new Device()) - ->setId($deviceId) - ->setCredentials([$credential]); - - $device = $deviceManager->createDevice($registryName, $device); - - printf('Device: %s : %s' . PHP_EOL, - $device->getNumId(), - $device->getId()); -} -# [END iot_create_rsa_device] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/create_unauth_device.php b/iot/src/create_unauth_device.php deleted file mode 100644 index 2347a67814..0000000000 --- a/iot/src/create_unauth_device.php +++ /dev/null @@ -1,57 +0,0 @@ -registryName($projectId, $location, $registryId); - - $device = (new Device()) - ->setId($deviceId); - - $device = $deviceManager->createDevice($registryName, $device); - - printf('Device: %s : %s' . PHP_EOL, - $device->getNumId(), - $device->getId()); -} -# [END iot_create_unauth_device] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/delete_device.php b/iot/src/delete_device.php deleted file mode 100644 index 8965a7868a..0000000000 --- a/iot/src/delete_device.php +++ /dev/null @@ -1,51 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - $response = $deviceManager->deleteDevice($deviceName); - - printf('Deleted %s' . PHP_EOL, $deviceName); -} -# [END iot_delete_device] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/delete_gateway.php b/iot/src/delete_gateway.php deleted file mode 100644 index b38d6ba862..0000000000 --- a/iot/src/delete_gateway.php +++ /dev/null @@ -1,53 +0,0 @@ -deviceName($projectId, $location, $registryId, $gatewayId); - - // TODO: unbind all bound devices when list_devices_for_gateway - // is working - $response = $deviceManager->deleteDevice($gatewayName); - - printf('Deleted %s' . PHP_EOL, $gatewayName); -} -# [END iot_delete_gateway] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/delete_registry.php b/iot/src/delete_registry.php deleted file mode 100644 index 6e8715f9eb..0000000000 --- a/iot/src/delete_registry.php +++ /dev/null @@ -1,49 +0,0 @@ -registryName($projectId, $location, $registryId); - - $deviceManager->deleteDeviceRegistry($registryName); - - printf('Deleted Registry %s' . PHP_EOL, $registryId); -} -# [END iot_delete_registry] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/get_device.php b/iot/src/get_device.php deleted file mode 100644 index 3818c5048b..0000000000 --- a/iot/src/get_device.php +++ /dev/null @@ -1,72 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - $device = $deviceManager->getDevice($deviceName); - - $formats = [ - PublicKeyFormat::UNSPECIFIED_PUBLIC_KEY_FORMAT => 'unspecified', - PublicKeyFormat::RSA_X509_PEM => 'RSA_X509_PEM', - PublicKeyFormat::ES256_PEM => 'ES256_PEM', - PublicKeyFormat::RSA_PEM => 'RSA_PEM', - PublicKeyFormat::ES256_X509_PEM => 'ES256_X509_PEM', - ]; - - printf('ID: %s' . PHP_EOL, $device->getId()); - printf('Name: %s' . PHP_EOL, $device->getName()); - foreach ($device->getCredentials() as $credential) { - print('Certificate:' . PHP_EOL); - printf(' Format: %s' . PHP_EOL, - $formats[$credential->getPublicKey()->getFormat()]); - printf(' Expiration: %s' . PHP_EOL, - $credential->getExpirationTime()->toDateTime()->format('Y-m-d H:i:s')); - } - printf('Data: %s' . PHP_EOL, $device->getConfig()->getBinaryData()); - printf('Version: %s' . PHP_EOL, $device->getConfig()->getVersion()); - printf('Update Time: %s' . PHP_EOL, - $device->getConfig()->getCloudUpdateTime()->toDateTime()->format('Y-m-d H:i:s')); -} -# [END iot_get_device] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/get_device_configs.php b/iot/src/get_device_configs.php deleted file mode 100644 index 10a63833bc..0000000000 --- a/iot/src/get_device_configs.php +++ /dev/null @@ -1,57 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - $configs = $deviceManager->listDeviceConfigVersions($deviceName); - - foreach ($configs->getDeviceConfigs() as $config) { - print('Config:' . PHP_EOL); - printf(' Version: %s' . PHP_EOL, $config->getVersion()); - printf(' Data: %s' . PHP_EOL, $config->getBinaryData()); - printf(' Update Time: %s' . PHP_EOL, - $config->getCloudUpdateTime()->toDateTime()->format('Y-m-d H:i:s')); - } -} -# [END iot_get_device_configs] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/get_device_state.php b/iot/src/get_device_state.php deleted file mode 100644 index 6d502e0dec..0000000000 --- a/iot/src/get_device_state.php +++ /dev/null @@ -1,56 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - $response = $deviceManager->listDeviceStates($deviceName); - - foreach ($response->getDeviceStates() as $state) { - print('State:' . PHP_EOL); - printf(' Data: %s' . PHP_EOL, $state->getBinaryData()); - printf(' Update Time: %s' . PHP_EOL, - $state->getUpdateTime()->toDateTime()->format('Y-m-d H:i:s')); - } -} -# [END iot_get_device_state] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/get_iam_policy.php b/iot/src/get_iam_policy.php deleted file mode 100644 index 66437d550c..0000000000 --- a/iot/src/get_iam_policy.php +++ /dev/null @@ -1,51 +0,0 @@ -registryName($projectId, $location, $registryId); - - $policy = $deviceManager->getIamPolicy($registryName); - - print($policy->serializeToJsonString() . PHP_EOL); -} -# [END iot_get_iam_policy] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/get_registry.php b/iot/src/get_registry.php deleted file mode 100644 index 45690a880d..0000000000 --- a/iot/src/get_registry.php +++ /dev/null @@ -1,51 +0,0 @@ -registryName($projectId, $location, $registryId); - - $registry = $deviceManager->getDeviceRegistry($registryName); - - printf('Id: %s, Name: %s' . PHP_EOL, - $registry->getId(), - $registry->getName()); -} -# [END iot_get_registry] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/list_devices.php b/iot/src/list_devices.php deleted file mode 100644 index 8a3cb2e682..0000000000 --- a/iot/src/list_devices.php +++ /dev/null @@ -1,57 +0,0 @@ -registryName($projectId, $location, $registryId); - - // Call the API - $devices = $deviceManager->listDevices($registryName); - - // Print the result - foreach ($devices->iterateAllElements() as $device) { - printf('Device: %s : %s' . PHP_EOL, - $device->getNumId(), - $device->getId()); - } -} -# [END iot_list_devices] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/list_devices_for_gateway.php b/iot/src/list_devices_for_gateway.php deleted file mode 100644 index 7b1abb78c6..0000000000 --- a/iot/src/list_devices_for_gateway.php +++ /dev/null @@ -1,63 +0,0 @@ -registryName($projectId, $location, $registryId); - - // Configure the list options for the gateway - $gatewayListOptions = (new GatewayListOptions())->setAssociationsGatewayId($gatewayId); - - // Call the API - $devices = $deviceManager->listDevices($registryName, - ['gatewayListOptions' => $gatewayListOptions] - ); - - // Print the result - foreach ($devices->iterateAllElements() as $device) { - printf('Bound Device: %s' . PHP_EOL, $device->getId()); - } -} -# [END iot_list_devices_for_gateway] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/list_gateways.php b/iot/src/list_gateways.php deleted file mode 100644 index a773988cb3..0000000000 --- a/iot/src/list_gateways.php +++ /dev/null @@ -1,77 +0,0 @@ -registryName($projectId, $location, $registryId); - - // Pass field mask to retrieve the gateway configuration fields - $fieldMask = (new FieldMask())->setPaths(['config', 'gateway_config']); - - // Call the API - $devices = $deviceManager->listDevices($registryName, [ - 'fieldMask' => $fieldMask - ]); - - // Print the result - $foundGateway = false; - foreach ($devices->iterateAllElements() as $device) { - $gatewayConfig = $device->getGatewayConfig(); - $gatewayType = null; - if ($gatewayConfig != null) { - $gatewayType = $gatewayConfig->getGatewayType(); - } - - if ($gatewayType == GatewayType::GATEWAY) { - $foundGateway = true; - printf('Device: %s : %s' . PHP_EOL, - $device->getNumId(), - $device->getId()); - } - } - if (!$foundGateway) { - printf('Registry %s has no gateways' . PHP_EOL, $registryId); - } -} -# [END iot_list_gateways] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/list_registries.php b/iot/src/list_registries.php deleted file mode 100644 index 7299ee9ce8..0000000000 --- a/iot/src/list_registries.php +++ /dev/null @@ -1,56 +0,0 @@ -locationName($projectId, $location); - - $response = $deviceManager->listDeviceRegistries($locationName); - - foreach ($response->iterateAllElements() as $registry) { - printf(' - Id: %s, Name: %s' . PHP_EOL, - $registry->getId(), - $registry->getName()); - } -} -# [END iot_list_registries] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/patch_es.php b/iot/src/patch_es.php deleted file mode 100644 index 544246cf0a..0000000000 --- a/iot/src/patch_es.php +++ /dev/null @@ -1,71 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - $publicKey = (new PublicKeyCredential()) - ->setFormat(PublicKeyFormat::ES256_PEM) - ->setKey(file_get_contents($publicKeyFile)); - - $credential = (new DeviceCredential()) - ->setPublicKey($publicKey); - - $device = (new Device()) - ->setName($deviceName) - ->setCredentials([$credential]); - - $updateMask = (new FieldMask()) - ->setPaths(['credentials']); - - $device = $deviceManager->updateDevice($device, $updateMask); - printf('Updated device %s' . PHP_EOL, $device->getName()); -} -# [END iot_patch_es] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/patch_rsa.php b/iot/src/patch_rsa.php deleted file mode 100644 index 633e3b0d51..0000000000 --- a/iot/src/patch_rsa.php +++ /dev/null @@ -1,71 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - $publicKey = (new PublicKeyCredential()) - ->setFormat(PublicKeyFormat::RSA_X509_PEM) - ->setKey(file_get_contents($certificateFile)); - - $credential = (new DeviceCredential()) - ->setPublicKey($publicKey); - - $device = (new Device()) - ->setName($deviceName) - ->setCredentials([$credential]); - - $updateMask = (new FieldMask()) - ->setPaths(['credentials']); - - $device = $deviceManager->updateDevice($device, $updateMask); - printf('Updated device %s' . PHP_EOL, $device->getName()); -} -# [END iot_patch_rsa] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/send_command_to_device.php b/iot/src/send_command_to_device.php deleted file mode 100644 index 3ad6b83fbd..0000000000 --- a/iot/src/send_command_to_device.php +++ /dev/null @@ -1,54 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - // Response empty on success - $deviceManager->sendCommandToDevice($deviceName, $command); - - printf('Command sent' . PHP_EOL); -} -# [END iot_send_command_to_device] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/set_device_config.php b/iot/src/set_device_config.php deleted file mode 100644 index 0ae2d8be85..0000000000 --- a/iot/src/set_device_config.php +++ /dev/null @@ -1,60 +0,0 @@ -deviceName($projectId, $location, $registryId, $deviceId); - - $config = $deviceManager->modifyCloudToDeviceConfig($deviceName, $config, [ - 'versionToUpdate' => $version, - ]); - - printf('Version: %s' . PHP_EOL, $config->getVersion()); - printf('Data: %s' . PHP_EOL, $config->getBinaryData()); - printf('Update Time: %s' . PHP_EOL, - $config->getCloudUpdateTime()->toDateTime()->format('Y-m-d H:i:s')); -} -# [END iot_set_device_config] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/set_device_state.php b/iot/src/set_device_state.php deleted file mode 100644 index aca79d572a..0000000000 --- a/iot/src/set_device_state.php +++ /dev/null @@ -1,79 +0,0 @@ - $projectId, 'iat' => time(), 'exp' => time() + 3600], - file_get_contents($certificateFile), - 'RS256' - ); - - // Format the device's URL - $deviceName = sprintf('projects/%s/locations/%s/registries/%s/devices/%s', - $projectId, $location, $registryId, $deviceId); - - $url = sprintf('https://cloudiotdevice.googleapis.com/v1/%s:setState', $deviceName); - - // Make the HTTP request - $response = $httpClient->post($url, [ - 'json' => [ - 'state' => [ - 'binaryData' => base64_encode($stateData) - ] - ], - 'headers' => [ - 'Authorization' => sprintf('Bearer %s', $jwt) - ] - ]); - - print('Updated device State' . PHP_EOL); -} -# [END iot_set_device_state] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/set_iam_policy.php b/iot/src/set_iam_policy.php deleted file mode 100644 index a83df09aff..0000000000 --- a/iot/src/set_iam_policy.php +++ /dev/null @@ -1,62 +0,0 @@ -registryName($projectId, $location, $registryId); - - $binding = (new Binding()) - ->setMembers([$member]) - ->setRole($role); - - $policy = (new Policy()) - ->setBindings([$binding]); - - $policy = $deviceManager->setIamPolicy($registryName, $policy); - - print($policy->serializeToJsonString() . PHP_EOL); -} -# [END iot_set_iam_policy] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/src/unbind_device_from_gateway.php b/iot/src/unbind_device_from_gateway.php deleted file mode 100644 index fb28a723e4..0000000000 --- a/iot/src/unbind_device_from_gateway.php +++ /dev/null @@ -1,53 +0,0 @@ -registryName($projectId, $location, $registryId); - - $result = $deviceManager->unbindDeviceFromGateway($registryName, $gatewayId, $deviceId); - - print('Device unbound'); -} -# [END iot_unbind_device_from_gateway] - -// The following 2 lines are only needed to run the samples -require_once __DIR__ . '/../../testing/sample_helpers.php'; -\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/iot/test/data/ec_public.pem b/iot/test/data/ec_public.pem deleted file mode 100644 index 3b61697ab7..0000000000 --- a/iot/test/data/ec_public.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhbN0N+3JH+3VBR/Xex4b1JzeJZgG -SUeTFIUpg/svqd+B4tYZySSYOccVJFUyL805mSgUMQ84/bYAIVybWZqvAQ== ------END PUBLIC KEY----- diff --git a/iot/test/data/rsa_cert.pem b/iot/test/data/rsa_cert.pem deleted file mode 100644 index aad6a4919e..0000000000 --- a/iot/test/data/rsa_cert.pem +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICoDCCAYgCCQDO3ocXJemE7jANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDDAZ1 -bnVzZWQwIBcNMTgwNDI0MTg0NDUwWhgPNDc1NjAzMjExODQ0NTBaMBExDzANBgNV -BAMMBnVudXNlZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9UwSZa -YwZh6GXkbiHkICmtn8Xf6fpte+nwaG/YNASzt+QP0gzV83DE6b6vBH5Jgz96kOr9 -SlQP4AekGyI4devubUEEkd+GnAkrin2dfUkpRNDgKSY9do9yEHnXo8af0C7xsjOn -BCqYgSJ+oeqvDNPcMp552lmpwOBx+xrpoSi0EwXcgRY51lNiGw37UWmny1QrWMmX -mG/Id0Tu9gPpjf/k5GQjaRtoZrHHMviZCUpoEpqn3Ru69zBXfpDY9oPrG8WdG7mN -YlWWMBQb7tfO75I8F1h90qdw6aw81G6l/wJJO3nW65gbuBVobMrnkYj6LV5bjjkW -slJ5vG0TlVaYZ80CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAWi1aN1sSerlk5Gev -nQFm0bRQVXYD8TIGDPubtKGMTuelAcH/o5frNhxgxj3hf+0h/+/tmJ7Y7B+q2zCw -b4rUc13ffhZFyO0F7oPUXHMvg415MN4YM64T8WZ4vAG4BKGKKBBo9C8PwMd0IhSk -xsevPfYls38LRIWTX1uE8E3MJh4CWfKImp/4ayj3m3vlGWktGHrK2DdQNZZTbiVv -EHjz/m6RPeG/BSlNFs/BvCf5gHLDoDVK3x2WPVVDJ/iNTmpgePj22az46Ed2KH6m -XDkPgJduTygnxgz6LY3D5rhcEf5QTQ7OSNcOpLvarnNi3bm/qOLWVrw+bsPLhnON -2c1PTA== ------END CERTIFICATE----- diff --git a/iot/test/iotTest.php.deprecated b/iot/test/iotTest.php.deprecated deleted file mode 100644 index 3c52639f14..0000000000 --- a/iot/test/iotTest.php.deprecated +++ /dev/null @@ -1,440 +0,0 @@ -requireEnv('GOOGLE_PUBSUB_TOPIC'); - - $registryId = 'test-registry-' . self::$testId; - - $output = $this->runFunctionSnippet('create_registry', [ - $registryId, - $topic, - self::$projectId, - self::LOCATION, - ]); - self::$registryId = $registryId; - $this->assertStringContainsString('Id: ' . $registryId, $output); - } - - /** @depends testCreateRegistry */ - public function testListRegistries() - { - $output = $this->runFunctionSnippet('list_registries', [ - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString(self::$registryId, $output); - } - - /** @depends testCreateRegistry */ - public function testGetRegistry() - { - $output = $this->runFunctionSnippet('get_registry', [ - self::$registryId, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString(self::$registryId, $output); - } - - /** @depends testCreateRegistry */ - public function testIamPolicy() - { - $email = 'betterbrent@google.com'; - $output = $this->runFunctionSnippet('set_iam_policy', [ - self::$registryId, - 'roles/viewer', - 'user:' . $email, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString($email, $output); - - $output = $this->runFunctionSnippet('get_iam_policy', [ - self::$registryId, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString($email, $output); - } - - /** @depends testCreateRegistry */ - public function testCreateRsaDevice() - { - $deviceId = 'test-rsa_device-' . self::$testId; - - $output = $this->runFunctionSnippet('create_rsa_device', [ - self::$registryId, - $deviceId, - __DIR__ . '/data/rsa_cert.pem', - self::$projectId, - self::LOCATION, - ]); - self::$devices[] = $deviceId; - $this->assertStringContainsString($deviceId, $output); - } - - /** @depends testCreateRsaDevice */ - public function testSetDeviceState() - { - $certB64 = $this->requireEnv('GOOGLE_IOT_DEVICE_CERTIFICATE_B64'); - $iotCert = base64_decode($certB64); - $iotCertFile = tempnam(sys_get_temp_dir(), 'iot-cert'); - file_put_contents($iotCertFile, $iotCert); - - $data = '{"data":"example of state data"}'; - $output = $this->runFunctionSnippet('set_device_state', [ - self::$registryId, - self::$devices[0], - $iotCertFile, - $data, - self::$projectId, - self::LOCATION, - ]); - - $output = $this->runFunctionSnippet('get_device_state', [ - self::$registryId, - self::$devices[0], - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString('Data: ' . $data, $output); - } - - /** @depends testCreateRsaDevice */ - public function testListDevices() - { - $output = $this->runFunctionSnippet('list_devices', [ - self::$registryId, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString(self::$devices[0], $output); - } - - /** @depends testCreateRsaDevice */ - public function testGetDevice() - { - $output = $this->runFunctionSnippet('get_device', [ - self::$registryId, - self::$devices[0], - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString(self::$devices[0], $output); - } - - /** @depends testCreateRsaDevice */ - public function testSetDeviceConfig() - { - $config = '{"data":"example of config data"}'; - $output = $this->runFunctionSnippet('set_device_config', [ - self::$registryId, - self::$devices[0], - $config, - null, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString('Version: 2', $output); - $this->assertStringContainsString('Data: ' . $config, $output); - } - - /** @depends testCreateRsaDevice */ - public function testSendCommandToDevice() - { - $command = '{"data":"example of command data"}'; - $output = $this->runFunctionSnippet('send_command_to_device', [ - self::$registryId, - self::$devices[0], - $command, - self::$projectId, - self::LOCATION, - ]); - print($output); - $this->assertStringContainsString('Sending command to', $output); - } - - /** @depends testSetDeviceConfig */ - public function testGetDeviceConfigs() - { - $output = $this->runFunctionSnippet('get_device_configs', [ - self::$registryId, - self::$devices[0], - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString('Version: 2', $output); - } - - /** @depends testCreateRegistry */ - public function testCreateEsDevice() - { - $deviceId = 'test-es_device-' . self::$testId; - - $output = $this->runFunctionSnippet('create_es_device', [ - self::$registryId, - $deviceId, - __DIR__ . '/data/ec_public.pem', - self::$projectId, - self::LOCATION, - ]); - self::$devices[] = $deviceId; - $this->assertStringContainsString($deviceId, $output); - } - - /** @depends testCreateRegistry */ - public function testCreateUnauthDevice() - { - $deviceId = 'test-unauth_device-' . self::$testId; - - $output = $this->runFunctionSnippet('create_unauth_device', [ - self::$registryId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - self::$devices[] = $deviceId; - $this->assertStringContainsString($deviceId, $output); - } - - /** @depends testCreateUnauthDevice */ - public function testPatchEs() - { - $deviceId = 'test-es_device_to_patch' . self::$testId; - - $this->runFunctionSnippet('create_unauth_device', [ - self::$registryId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - self::$devices[] = $deviceId; - - $output = $this->runFunctionSnippet('patch_es', [ - self::$registryId, - $deviceId, - __DIR__ . '/data/ec_public.pem', - self::$projectId, - self::LOCATION, - ]); - - $this->assertStringContainsString('Updated device', $output); - } - - /** @depends testCreateRegistry */ - public function testPatchRsa() - { - $deviceId = 'test-rsa_device_to_patch' . self::$testId; - - $this->runFunctionSnippet('create_unauth_device', [ - self::$registryId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - self::$devices[] = $deviceId; - - $output = $this->runFunctionSnippet('patch_rsa', [ - self::$registryId, - $deviceId, - __DIR__ . '/data/rsa_cert.pem', - self::$projectId, - self::LOCATION, - ]); - - $this->assertStringContainsString('Updated device', $output); - } - - /** @depends testCreateRegistry */ - public function testCreateGateway() - { - $gatewayId = 'test-rsa-gateway' . self::$testId; - - $output = $this->runFunctionSnippet('create_gateway', [ - self::$registryId, - $gatewayId, - __DIR__ . '/data/rsa_cert.pem', - 'RS256', - self::$projectId, - self::LOCATION, - ]); - self::$gateways[] = $gatewayId; - $this->assertStringContainsString('Gateway: ', $output); - - $output = $this->runFunctionSnippet('list_gateways', [ - self::$registryId, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString($gatewayId, $output); - } - - /** - * @depends testCreateGateway - * @retryAttempts 3 - */ - public function testBindUnbindDevice() - { - $deviceId = 'test_device_to_bind' . self::$testId; - $gatewayId = 'test-bindunbind-gateway' . self::$testId; - - $this->runFunctionSnippet('create_gateway', [ - self::$registryId, - $gatewayId, - __DIR__ . '/data/rsa_cert.pem', - 'RS256', - self::$projectId, - self::LOCATION, - ]); - self::$gateways[] = $gatewayId; - - $this->runFunctionSnippet('create_unauth_device', [ - self::$registryId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - self::$devices[] = $deviceId; - - $output = $this->runFunctionSnippet('bind_device_to_gateway', [ - self::$registryId, - $gatewayId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString('Device bound', $output); - - $output = $this->runFunctionSnippet('unbind_device_from_gateway', [ - self::$registryId, - $gatewayId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString('Device unbound', $output); - } - - /** @depends testBindUnbindDevice */ - public function testListDevicesForGateway() - { - $deviceId = 'php-bind-and-list' . self::$testId; - $gatewayId = 'php-bal-gateway' . self::$testId; - - $this->runFunctionSnippet('create_unauth_device', [ - self::$registryId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - self::$devices[] = $deviceId; - - $this->runFunctionSnippet('create_gateway', [ - self::$registryId, - $gatewayId, - __DIR__ . '/data/rsa_cert.pem', - 'RS256', - self::$projectId, - self::LOCATION, - ]); - self::$gateways[] = $gatewayId; - - $this->runFunctionSnippet('bind_device_to_gateway', [ - self::$registryId, - $gatewayId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - - $output = $this->runFunctionSnippet('list_devices_for_gateway', [ - self::$registryId, - $gatewayId, - self::$projectId, - self::LOCATION, - ]); - $this->assertStringContainsString($deviceId, $output); - - $this->runFunctionSnippet('unbind_device_from_gateway', [ - self::$registryId, - $gatewayId, - $deviceId, - self::$projectId, - self::LOCATION, - ]); - } -} diff --git a/testing/run_staticanalysis_check.sh b/testing/run_staticanalysis_check.sh index 0dd02ceaff..4f2d2aae39 100644 --- a/testing/run_staticanalysis_check.sh +++ b/testing/run_staticanalysis_check.sh @@ -19,7 +19,6 @@ fi SKIP_DIRS=( dialogflow - iot ) TMP_REPORT_DIR=$(mktemp -d) diff --git a/testing/run_test_suite.sh b/testing/run_test_suite.sh index 27bef996ab..5134301628 100755 --- a/testing/run_test_suite.sh +++ b/testing/run_test_suite.sh @@ -37,7 +37,6 @@ REST_TESTS=( dialogflow dlp error_reporting - iot monitoring speech video @@ -56,7 +55,6 @@ ALT_PROJECT_TESTS=( dialogflow dlp error_reporting - iot kms logging monitoring