From 4b36169b6ef359b1b4ae4e62c5be4a42ce08b879 Mon Sep 17 00:00:00 2001 From: Paul Montgomery Date: Tue, 4 Aug 2020 17:40:58 -0700 Subject: [PATCH] Remove product init and add validation-type to test create (#5) * Remove az iot product init (#20) * Product (#21) * Remove most cases of product_id * Updated Swagger * Add validation-type and make product-id only required for Certification validation type * Fix CLI linter * Fix tests --- azext_iot/product/_help.py | 13 --- azext_iot/product/command_map.py | 3 - azext_iot/product/command_product.py | 102 ------------------ azext_iot/product/params.py | 12 --- azext_iot/product/shared.py | 5 + azext_iot/product/test/_help.py | 15 +++ azext_iot/product/test/command_tests.py | 13 ++- azext_iot/product/test/params.py | 11 +- azext_iot/sdk/product/models/__init__.py | 3 + ...rieve_model_reposistory_sas_token_error.py | 13 +-- ...e_model_reposistory_sas_token_error_py3.py | 15 +-- azext_iot/sdk/product/models/device_test.py | 2 +- .../models/device_test_not_exist_error.py | 13 +-- .../models/device_test_not_exist_error_py3.py | 15 +-- .../sdk/product/models/device_test_py3.py | 2 +- .../existing_task_running_conflict_error.py | 13 +-- ...xisting_task_running_conflict_error_py3.py | 15 +-- .../models/fail_to_queue_task_error.py | 13 +-- .../models/fail_to_queue_task_error_py3.py | 15 +-- .../models/model_resolution_failure_error.py | 13 +-- .../model_resolution_failure_error_py3.py | 15 +-- .../product/models/model_resolution_source.py | 33 ++++++ .../models/model_resolution_source_py3.py | 33 ++++++ .../pnp_certification_badge_configuration.py | 4 + ...p_certification_badge_configuration_py3.py | 6 +- .../models/pnp_certification_badge_result.py | 5 + .../pnp_certification_badge_result_py3.py | 7 +- azext_iot/sdk/product/models/system_error.py | 13 +-- .../sdk/product/models/system_error_py3.py | 15 +-- .../models/test_cases_not_exist_error.py | 13 +-- .../models/test_cases_not_exist_error_py3.py | 15 +-- .../models/test_run_not_exist_error.py | 13 +-- .../models/test_run_not_exist_error_py3.py | 15 +-- azext_iot/tests/product/test_aics_e2e_int.py | 29 ++--- .../product/test_command_test_create_int.py | 6 +- .../product/test_command_test_create_unit.py | 30 +++--- .../product/test_command_test_init_unit.py | 49 --------- .../product/test_command_test_show_int.py | 2 - .../product/test_device_test_tasks_int.py | 25 ++--- 39 files changed, 219 insertions(+), 415 deletions(-) delete mode 100644 azext_iot/product/command_product.py create mode 100644 azext_iot/sdk/product/models/model_resolution_source.py create mode 100644 azext_iot/sdk/product/models/model_resolution_source_py3.py delete mode 100644 azext_iot/tests/product/test_command_test_init_unit.py diff --git a/azext_iot/product/_help.py b/azext_iot/product/_help.py index 87059b50c..50e941768 100644 --- a/azext_iot/product/_help.py +++ b/azext_iot/product/_help.py @@ -34,16 +34,3 @@ def load_help(): text: > az iot product requirement list """ - helps[ - "iot product init" - ] = """ - type: command - short-summary: Used to initialize local workspace for a new product certification - examples: - - name: Use default working folder ('PnPCert') - text: > - az iot product init --product-name {product_name} - - name: Specify working folder - text: > - az iot product init --product-name {product_name} --working-folder {working_folder} - """ diff --git a/azext_iot/product/command_map.py b/azext_iot/product/command_map.py index 6066c1a0b..25dba78b7 100644 --- a/azext_iot/product/command_map.py +++ b/azext_iot/product/command_map.py @@ -19,9 +19,6 @@ def load_product_commands(self, _): - with self.command_group("iot product", command_type=product_ops) as g: - g.command("init", "initialize_workspace") - with self.command_group( "iot product requirement", command_type=requirements_ops ) as g: diff --git a/azext_iot/product/command_product.py b/azext_iot/product/command_product.py deleted file mode 100644 index 74391cf56..000000000 --- a/azext_iot/product/command_product.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -from uuid import uuid4 -from knack.log import get_logger -import os - -logger = get_logger(__name__) - - -def initialize_workspace(cmd, product_name, working_folder="PnPCert"): - id = uuid4() - if not os.path.exists(working_folder): - os.mkdir(working_folder) - - product_config = { - "id": str(id), - "name": product_name, - "industryTemplates": [ - "InstoreAnalytics |" - + " DigitalDistributionCenter |" - + " ConnectedLogistics |" - + " SmartInventoryManagement |" - + " ContinuousPatientMonitoring |" - + " SmartMeterAnalytics |" - + " SolarPowerMonitoring |" - + " WaterQualityMonitoring |" - + " WaterConsumptionMonitoring |" - + " ConnectedWasteManagement |" - + " ShelfAvailability" - ], - "shortDescription": "string - max length 100", - "longDescription": "string - max length 1200", - "dimensions": { - "length": {"value": 0, "displayUnit": "cm | @in"}, - "width": {"value": 0, "displayUnit": "cm | @in"}, - "height": {"value": 0, "displayUnit": "cm | @in"}, - }, - "weight": {"value": 0, "displayUnit": "g | lb"}, - "deviceType": "FinishedProduct | DevKit", - "geoAvailability": ["Worldwide | EMEA | APAC_Except_Japan | Americas | Japan"], - "marketingPage": "url", - "purchaseURL": "url", - "salesContact": "url", - "caseStudyURL": "url", - "languages": ["C | CSharp | Java | JavaScript | Python"], - "os": [""], - "cloudProtocols": ["AMQPS | AMQPS_Websockets | MQTT | MQTT_Websockets | HTTPS"], - "industrialProtocols": [ - "CAN_Bus | EtherCAT | Modbus | OPC_Classic | OPC_UA | PROFINET | ZigBee | PPMP | Others" - ], - "connectivity": ["Bluetooth | LAN | WIFI | LTE | ThreeG | Others"], - "hardwareInterfaces": ["GPIO | I2C_SPI | COM | USB | Others"], - "integratedSensors": [ - "GPS |" - + " Touch |" - + " LED |" - + " Light |" - + " Gas |" - + " Noise |" - + " Proximity |" - + " Temperature |" - + " Humidity |" - + " Pressure |" - + " Accelerometers |" - + " Weight |" - + " Soil_Alkalinity |" - + " Vibrations |" - + " Image_capture |" - + " Motion_Detection |" - + " Chemical_compound_presence |" - + " No_Sensors" - ], - "secureHardware": ["TPM | DICE | SIM_eSIM | Smartcard | Others"], - "numOfHardwareComponents": 1, - "componentType": "SoM_SoC | Carrier_Board", - "componentName": "Video_SoM | Audio_SoM | Video_Carrier_Board | Others", - "processorArchitecture": "arm | arm64 | x86 | amd64", - "processorManufacturer": "string", - "totalStorage": {"value": 0, "displayUnit": "b | kb | mb | gb"}, - "totalMemory": {"value": 0, "displayUnit": "b | kb | mb | gb"}, - "battery": {"value": 0, "displayUnit": "mwH"}, - "hardwareAcceleratorManufacturer": "string", - "hardwareAcceleratorName": "string", - "hardwareAcceleratorVersion": "string", - "industryCertifications": ["FCC | ISCC | Others"], - "industryCertificationExternalLink": "url", - "distributors": [{"name": "string", "purchaseUrl": "url"}], - "techSpecURL": "url", - "firmwareImageURL": "url", - } - - from json import dump - - with open( - file=os.path.join(working_folder, "product_configuration.json"), - mode="w+", - encoding="utf-8", - ) as f: - dump(obj=product_config, fp=f, indent=4, sort_keys=False) diff --git a/azext_iot/product/params.py b/azext_iot/product/params.py index 0c5db1fc9..e2d32bf5e 100644 --- a/azext_iot/product/params.py +++ b/azext_iot/product/params.py @@ -14,18 +14,6 @@ def load_product_params(self, _): with self.argument_context("iot product") as c: - c.argument( - "working_folder", - options_list=["--working-folder", "--wf"], - help="The folder to create in current path", - arg_group="IoT Device Certification", - ) - c.argument( - "product_name", - options_list=["--product-name"], - help="Product name to display in catalog", - arg_group="IoT Device Certification", - ) c.argument( "test_id", options_list=["--test-id", "-t"], diff --git a/azext_iot/product/shared.py b/azext_iot/product/shared.py index 8069258a2..603182820 100644 --- a/azext_iot/product/shared.py +++ b/azext_iot/product/shared.py @@ -39,4 +39,9 @@ class DeviceTestTaskStatus(Enum): cancelled = "Cancelled" +class ValidationType(Enum): + test = "Test" + certification = "Certification" + + BASE_URL = "https://certify.azureiotsolutions.com" diff --git a/azext_iot/product/test/_help.py b/azext_iot/product/test/_help.py index 8c19848f8..488faa9d0 100644 --- a/azext_iot/product/test/_help.py +++ b/azext_iot/product/test/_help.py @@ -30,6 +30,21 @@ def load_help(): - name: Do not have service create provisioning configuration text: > az iot product test create --configuration-file {configuration_file} --skip-provisioning + - name: Creating test with symmetric key attestation + text: > + az iot product test create --attestation-type SymmetricKey --device-type {device_type} + - name: Creating test with TPM attestation + text: > + az iot product test create --attestation-type TPM --device-type {device_type} --endorsement-key {endorsement_key} + - name: Creating test with x509 attestation + text: > + az iot product test create --attestation-type x509 --device-type {device_type} --certificate-path {certificate_path} + - name: Creating test for Edge module + text: > + az iot product test create --attestation-type ConnectionString --device-type {device_type} --badge-type IotEdgeCompatible --connection-string {connection_string} + - name: Creating test with symmetric key attestation and specified validation type + text: > + az iot product test create --attestation-type SymmetricKey --device-type {device_type} --validation-type Certification --product-id {product_id} """ helps[ "iot product test search" diff --git a/azext_iot/product/test/command_tests.py b/azext_iot/product/test/command_tests.py index eba5ae364..5284b8c22 100644 --- a/azext_iot/product/test/command_tests.py +++ b/azext_iot/product/test/command_tests.py @@ -6,7 +6,7 @@ from azext_iot.product.providers.aics import AICSProvider from azext_iot.sdk.product.models import DeviceTestSearchOptions -from azext_iot.product.shared import BadgeType, AttestationType +from azext_iot.product.shared import BadgeType, AttestationType, ValidationType from knack.log import get_logger from knack.util import CLIError import os @@ -24,6 +24,7 @@ def create( connection_string=None, endorsement_key=None, badge_type=BadgeType.IotDevice.value, + validation_type=ValidationType.test.value, models=None, skip_provisioning=False, base_url=None, @@ -46,10 +47,14 @@ def create( raise CLIError( "Connection string is only available for Edge Compatible modules testing" ) + if validation_type != ValidationType.test.value and not product_id: + raise CLIError( + "Product Id is required for validation type {}".format(validation_type) + ) if not any( [ configuration_file, - all([device_type, product_id, attestation_type, badge_type]), + all([device_type, attestation_type, badge_type]), ] ): raise CLIError( @@ -67,6 +72,7 @@ def create( badge_type=badge_type, connection_string=connection_string, models=models, + validation_type=validation_type ) ) @@ -210,9 +216,10 @@ def _build_test_configuration( connection_string, badge_type, models, + validation_type ): config = { - "validationType": "Certification", + "validationType": validation_type, "productId": product_id, "deviceType": device_type, "provisioningConfiguration": {"type": attestation_type}, diff --git a/azext_iot/product/test/params.py b/azext_iot/product/test/params.py index d419b373d..0a0c40cad 100644 --- a/azext_iot/product/test/params.py +++ b/azext_iot/product/test/params.py @@ -9,7 +9,7 @@ """ from azure.cli.core.commands.parameters import get_three_state_flag, get_enum_type -from azext_iot.product.shared import AttestationType, DeviceType, TaskType +from azext_iot.product.shared import AttestationType, DeviceType, TaskType, ValidationType def load_product_test_params(self, _): @@ -73,8 +73,15 @@ def load_product_test_params(self, _): c.argument( "product_id", options_list=["--product-id", "-p"], - help="The submitted product id", + help="The submitted product id. Required when validation-type is 'Certification'.", + arg_group="IoT Device Certification Device Definition", + ) + c.argument( + "validation_type", + options_list=["--validation-type", "--vt"], + help="The type of validations testing to be performed", arg_group="IoT Device Certification Device Definition", + arg_type=get_enum_type(ValidationType) ) with self.argument_context("iot product test search") as c: c.argument( diff --git a/azext_iot/sdk/product/models/__init__.py b/azext_iot/sdk/product/models/__init__.py index 6ca475dbb..609b4014d 100644 --- a/azext_iot/sdk/product/models/__init__.py +++ b/azext_iot/sdk/product/models/__init__.py @@ -22,6 +22,7 @@ from .provisioning_configuration_py3 import ProvisioningConfiguration from .iot_device_certification_badge_configuration_py3 import IotDeviceCertificationBadgeConfiguration from .iot_edge_compatible_certification_badge_configuration_py3 import IotEdgeCompatibleCertificationBadgeConfiguration + from .model_resolution_source_py3 import ModelResolutionSource from .pnp_certification_badge_configuration_py3 import PnpCertificationBadgeConfiguration from .device_test_py3 import DeviceTest from .device_test_search_options_py3 import DeviceTestSearchOptions @@ -79,6 +80,7 @@ from .provisioning_configuration import ProvisioningConfiguration from .iot_device_certification_badge_configuration import IotDeviceCertificationBadgeConfiguration from .iot_edge_compatible_certification_badge_configuration import IotEdgeCompatibleCertificationBadgeConfiguration + from .model_resolution_source import ModelResolutionSource from .pnp_certification_badge_configuration import PnpCertificationBadgeConfiguration from .device_test import DeviceTest from .device_test_search_options import DeviceTestSearchOptions @@ -137,6 +139,7 @@ 'ProvisioningConfiguration', 'IotDeviceCertificationBadgeConfiguration', 'IotEdgeCompatibleCertificationBadgeConfiguration', + 'ModelResolutionSource', 'PnpCertificationBadgeConfiguration', 'DeviceTest', 'DeviceTestSearchOptions', diff --git a/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error.py b/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error.py index 91d11e127..1ac686b6f 100644 --- a/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error.py +++ b/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error.py @@ -15,21 +15,14 @@ class CannotRetrieveModelReposistorySasTokenError(Model): """CannotRetrieveModelReposistorySasTokenError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(CannotRetrieveModelReposistorySasTokenError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error_py3.py b/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error_py3.py index 33138e5d1..8d27e0b0f 100644 --- a/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error_py3.py +++ b/azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error_py3.py @@ -15,29 +15,22 @@ class CannotRetrieveModelReposistorySasTokenError(Model): """CannotRetrieveModelReposistorySasTokenError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(CannotRetrieveModelReposistorySasTokenError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/sdk/product/models/device_test.py b/azext_iot/sdk/product/models/device_test.py index 32b37a0e7..ea38905f3 100644 --- a/azext_iot/sdk/product/models/device_test.py +++ b/azext_iot/sdk/product/models/device_test.py @@ -23,7 +23,7 @@ class DeviceTest(Model): :param validation_type: Microsoft.Azure.IoT.TestKit.Shared.Models.ValidationType of a Microsoft.Azure.IoT.TestKit.Models.DeviceTest. Possible values include: - 'Certification' + 'Certification', 'Test' :type validation_type: str or ~product.models.enum :param product_id: Product Id of the testing device in product service. In CLI scenario, this can be null. diff --git a/azext_iot/sdk/product/models/device_test_not_exist_error.py b/azext_iot/sdk/product/models/device_test_not_exist_error.py index 31b01ebf1..c7672afd9 100644 --- a/azext_iot/sdk/product/models/device_test_not_exist_error.py +++ b/azext_iot/sdk/product/models/device_test_not_exist_error.py @@ -15,21 +15,14 @@ class DeviceTestNotExistError(Model): """DeviceTestNotExistError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(DeviceTestNotExistError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/device_test_not_exist_error_py3.py b/azext_iot/sdk/product/models/device_test_not_exist_error_py3.py index 917bb5a77..4d1be9b1a 100644 --- a/azext_iot/sdk/product/models/device_test_not_exist_error_py3.py +++ b/azext_iot/sdk/product/models/device_test_not_exist_error_py3.py @@ -15,29 +15,22 @@ class DeviceTestNotExistError(Model): """DeviceTestNotExistError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(DeviceTestNotExistError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/sdk/product/models/device_test_py3.py b/azext_iot/sdk/product/models/device_test_py3.py index 09904cb8e..7ebef29ac 100644 --- a/azext_iot/sdk/product/models/device_test_py3.py +++ b/azext_iot/sdk/product/models/device_test_py3.py @@ -23,7 +23,7 @@ class DeviceTest(Model): :param validation_type: Microsoft.Azure.IoT.TestKit.Shared.Models.ValidationType of a Microsoft.Azure.IoT.TestKit.Models.DeviceTest. Possible values include: - 'Certification' + 'Certification', 'Test' :type validation_type: str or ~product.models.enum :param product_id: Product Id of the testing device in product service. In CLI scenario, this can be null. diff --git a/azext_iot/sdk/product/models/existing_task_running_conflict_error.py b/azext_iot/sdk/product/models/existing_task_running_conflict_error.py index 76203b485..1b0bcc535 100644 --- a/azext_iot/sdk/product/models/existing_task_running_conflict_error.py +++ b/azext_iot/sdk/product/models/existing_task_running_conflict_error.py @@ -15,21 +15,14 @@ class ExistingTaskRunningConflictError(Model): """ExistingTaskRunningConflictError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(ExistingTaskRunningConflictError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/existing_task_running_conflict_error_py3.py b/azext_iot/sdk/product/models/existing_task_running_conflict_error_py3.py index ad13ca100..c09f32b9a 100644 --- a/azext_iot/sdk/product/models/existing_task_running_conflict_error_py3.py +++ b/azext_iot/sdk/product/models/existing_task_running_conflict_error_py3.py @@ -15,29 +15,22 @@ class ExistingTaskRunningConflictError(Model): """ExistingTaskRunningConflictError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(ExistingTaskRunningConflictError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/sdk/product/models/fail_to_queue_task_error.py b/azext_iot/sdk/product/models/fail_to_queue_task_error.py index 0521d5ae0..e1fcaa373 100644 --- a/azext_iot/sdk/product/models/fail_to_queue_task_error.py +++ b/azext_iot/sdk/product/models/fail_to_queue_task_error.py @@ -15,21 +15,14 @@ class FailToQueueTaskError(Model): """FailToQueueTaskError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(FailToQueueTaskError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/fail_to_queue_task_error_py3.py b/azext_iot/sdk/product/models/fail_to_queue_task_error_py3.py index 1d38f7a21..b81c17a14 100644 --- a/azext_iot/sdk/product/models/fail_to_queue_task_error_py3.py +++ b/azext_iot/sdk/product/models/fail_to_queue_task_error_py3.py @@ -15,29 +15,22 @@ class FailToQueueTaskError(Model): """FailToQueueTaskError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(FailToQueueTaskError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/sdk/product/models/model_resolution_failure_error.py b/azext_iot/sdk/product/models/model_resolution_failure_error.py index 85dbe464e..cf6738ad6 100644 --- a/azext_iot/sdk/product/models/model_resolution_failure_error.py +++ b/azext_iot/sdk/product/models/model_resolution_failure_error.py @@ -15,21 +15,14 @@ class ModelResolutionFailureError(Model): """ModelResolutionFailureError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(ModelResolutionFailureError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/model_resolution_failure_error_py3.py b/azext_iot/sdk/product/models/model_resolution_failure_error_py3.py index 181c4e7d6..7ed5cfc5b 100644 --- a/azext_iot/sdk/product/models/model_resolution_failure_error_py3.py +++ b/azext_iot/sdk/product/models/model_resolution_failure_error_py3.py @@ -15,29 +15,22 @@ class ModelResolutionFailureError(Model): """ModelResolutionFailureError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(ModelResolutionFailureError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/sdk/product/models/model_resolution_source.py b/azext_iot/sdk/product/models/model_resolution_source.py new file mode 100644 index 000000000..a2ace37c4 --- /dev/null +++ b/azext_iot/sdk/product/models/model_resolution_source.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ModelResolutionSource(Model): + """ModelResolutionSource. + + :param priority: + :type priority: int + :param source_type: Possible values include: 'Unknown', + 'GlobalRepository', 'PrivateRepository', 'UserUploads' + :type source_type: str or ~product.models.enum + """ + + _attribute_map = { + 'priority': {'key': 'priority', 'type': 'int'}, + 'source_type': {'key': 'sourceType', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ModelResolutionSource, self).__init__(**kwargs) + self.priority = kwargs.get('priority', None) + self.source_type = kwargs.get('source_type', None) diff --git a/azext_iot/sdk/product/models/model_resolution_source_py3.py b/azext_iot/sdk/product/models/model_resolution_source_py3.py new file mode 100644 index 000000000..e556ef5af --- /dev/null +++ b/azext_iot/sdk/product/models/model_resolution_source_py3.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ModelResolutionSource(Model): + """ModelResolutionSource. + + :param priority: + :type priority: int + :param source_type: Possible values include: 'Unknown', + 'GlobalRepository', 'PrivateRepository', 'UserUploads' + :type source_type: str or ~product.models.enum + """ + + _attribute_map = { + 'priority': {'key': 'priority', 'type': 'int'}, + 'source_type': {'key': 'sourceType', 'type': 'str'}, + } + + def __init__(self, *, priority: int=None, source_type=None, **kwargs) -> None: + super(ModelResolutionSource, self).__init__(**kwargs) + self.priority = priority + self.source_type = source_type diff --git a/azext_iot/sdk/product/models/pnp_certification_badge_configuration.py b/azext_iot/sdk/product/models/pnp_certification_badge_configuration.py index d38f2e35c..a8b3b7087 100644 --- a/azext_iot/sdk/product/models/pnp_certification_badge_configuration.py +++ b/azext_iot/sdk/product/models/pnp_certification_badge_configuration.py @@ -17,6 +17,8 @@ class PnpCertificationBadgeConfiguration(Model): :param digital_twin_model_definitions: :type digital_twin_model_definitions: list[str] + :param resolution_sources: + :type resolution_sources: list[~product.models.ModelResolutionSource] :param type: Possible values include: 'IotDevice', 'Pnp', 'IotEdgeCompatible' :type type: str or ~product.models.enum @@ -24,10 +26,12 @@ class PnpCertificationBadgeConfiguration(Model): _attribute_map = { 'digital_twin_model_definitions': {'key': 'digitalTwinModelDefinitions', 'type': '[str]'}, + 'resolution_sources': {'key': 'resolutionSources', 'type': '[ModelResolutionSource]'}, 'type': {'key': 'type', 'type': 'str'}, } def __init__(self, **kwargs): super(PnpCertificationBadgeConfiguration, self).__init__(**kwargs) self.digital_twin_model_definitions = kwargs.get('digital_twin_model_definitions', None) + self.resolution_sources = kwargs.get('resolution_sources', None) self.type = kwargs.get('type', None) diff --git a/azext_iot/sdk/product/models/pnp_certification_badge_configuration_py3.py b/azext_iot/sdk/product/models/pnp_certification_badge_configuration_py3.py index f0517c54d..b18fad109 100644 --- a/azext_iot/sdk/product/models/pnp_certification_badge_configuration_py3.py +++ b/azext_iot/sdk/product/models/pnp_certification_badge_configuration_py3.py @@ -17,6 +17,8 @@ class PnpCertificationBadgeConfiguration(Model): :param digital_twin_model_definitions: :type digital_twin_model_definitions: list[str] + :param resolution_sources: + :type resolution_sources: list[~product.models.ModelResolutionSource] :param type: Possible values include: 'IotDevice', 'Pnp', 'IotEdgeCompatible' :type type: str or ~product.models.enum @@ -24,10 +26,12 @@ class PnpCertificationBadgeConfiguration(Model): _attribute_map = { 'digital_twin_model_definitions': {'key': 'digitalTwinModelDefinitions', 'type': '[str]'}, + 'resolution_sources': {'key': 'resolutionSources', 'type': '[ModelResolutionSource]'}, 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, digital_twin_model_definitions=None, type=None, **kwargs) -> None: + def __init__(self, *, digital_twin_model_definitions=None, resolution_sources=None, type=None, **kwargs) -> None: super(PnpCertificationBadgeConfiguration, self).__init__(**kwargs) self.digital_twin_model_definitions = digital_twin_model_definitions + self.resolution_sources = resolution_sources self.type = type diff --git a/azext_iot/sdk/product/models/pnp_certification_badge_result.py b/azext_iot/sdk/product/models/pnp_certification_badge_result.py index ca19c4e26..941ed3180 100644 --- a/azext_iot/sdk/product/models/pnp_certification_badge_result.py +++ b/azext_iot/sdk/product/models/pnp_certification_badge_result.py @@ -27,6 +27,9 @@ class PnpCertificationBadgeResult(Model): :ivar type: Possible values include: 'IotDevice', 'Pnp', 'IotEdgeCompatible' :vartype type: str or ~product.models.enum + :param resolution_source: Possible values include: 'Unknown', + 'GlobalRepository', 'PrivateRepository', 'UserUploads' + :type resolution_source: str or ~product.models.enum """ _validation = { @@ -39,6 +42,7 @@ class PnpCertificationBadgeResult(Model): 'validation_tasks': {'key': 'validationTasks', 'type': '[DigitalTwinValidationTaskResult]'}, 'pre_validation_tasks': {'key': 'preValidationTasks', 'type': '[PreValidationTaskResult]'}, 'type': {'key': 'type', 'type': 'str'}, + 'resolution_source': {'key': 'resolutionSource', 'type': 'str'}, } def __init__(self, **kwargs): @@ -46,3 +50,4 @@ def __init__(self, **kwargs): self.validation_tasks = None self.pre_validation_tasks = None self.type = None + self.resolution_source = kwargs.get('resolution_source', None) diff --git a/azext_iot/sdk/product/models/pnp_certification_badge_result_py3.py b/azext_iot/sdk/product/models/pnp_certification_badge_result_py3.py index 623f2d7b4..cf6668ecd 100644 --- a/azext_iot/sdk/product/models/pnp_certification_badge_result_py3.py +++ b/azext_iot/sdk/product/models/pnp_certification_badge_result_py3.py @@ -27,6 +27,9 @@ class PnpCertificationBadgeResult(Model): :ivar type: Possible values include: 'IotDevice', 'Pnp', 'IotEdgeCompatible' :vartype type: str or ~product.models.enum + :param resolution_source: Possible values include: 'Unknown', + 'GlobalRepository', 'PrivateRepository', 'UserUploads' + :type resolution_source: str or ~product.models.enum """ _validation = { @@ -39,10 +42,12 @@ class PnpCertificationBadgeResult(Model): 'validation_tasks': {'key': 'validationTasks', 'type': '[DigitalTwinValidationTaskResult]'}, 'pre_validation_tasks': {'key': 'preValidationTasks', 'type': '[PreValidationTaskResult]'}, 'type': {'key': 'type', 'type': 'str'}, + 'resolution_source': {'key': 'resolutionSource', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__(self, *, resolution_source=None, **kwargs) -> None: super(PnpCertificationBadgeResult, self).__init__(**kwargs) self.validation_tasks = None self.pre_validation_tasks = None self.type = None + self.resolution_source = resolution_source diff --git a/azext_iot/sdk/product/models/system_error.py b/azext_iot/sdk/product/models/system_error.py index bae632cc6..774f0ba92 100644 --- a/azext_iot/sdk/product/models/system_error.py +++ b/azext_iot/sdk/product/models/system_error.py @@ -15,21 +15,14 @@ class SystemError(Model): """SystemError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(SystemError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/system_error_py3.py b/azext_iot/sdk/product/models/system_error_py3.py index 6358e434f..7b9a097ba 100644 --- a/azext_iot/sdk/product/models/system_error_py3.py +++ b/azext_iot/sdk/product/models/system_error_py3.py @@ -15,29 +15,22 @@ class SystemError(Model): """SystemError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(SystemError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/sdk/product/models/test_cases_not_exist_error.py b/azext_iot/sdk/product/models/test_cases_not_exist_error.py index d68d8a662..67ae42a9a 100644 --- a/azext_iot/sdk/product/models/test_cases_not_exist_error.py +++ b/azext_iot/sdk/product/models/test_cases_not_exist_error.py @@ -15,21 +15,14 @@ class TestCasesNotExistError(Model): """TestCasesNotExistError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(TestCasesNotExistError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/test_cases_not_exist_error_py3.py b/azext_iot/sdk/product/models/test_cases_not_exist_error_py3.py index f84dde176..f032f60a2 100644 --- a/azext_iot/sdk/product/models/test_cases_not_exist_error_py3.py +++ b/azext_iot/sdk/product/models/test_cases_not_exist_error_py3.py @@ -15,29 +15,22 @@ class TestCasesNotExistError(Model): """TestCasesNotExistError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(TestCasesNotExistError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/sdk/product/models/test_run_not_exist_error.py b/azext_iot/sdk/product/models/test_run_not_exist_error.py index d65771e29..d8412548d 100644 --- a/azext_iot/sdk/product/models/test_run_not_exist_error.py +++ b/azext_iot/sdk/product/models/test_run_not_exist_error.py @@ -15,21 +15,14 @@ class TestRunNotExistError(Model): """TestRunNotExistError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, @@ -40,4 +33,4 @@ def __init__(self, **kwargs): super(TestRunNotExistError, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) - self.details = None + self.details = kwargs.get('details', None) diff --git a/azext_iot/sdk/product/models/test_run_not_exist_error_py3.py b/azext_iot/sdk/product/models/test_run_not_exist_error_py3.py index 2533c931f..476ba5421 100644 --- a/azext_iot/sdk/product/models/test_run_not_exist_error_py3.py +++ b/azext_iot/sdk/product/models/test_run_not_exist_error_py3.py @@ -15,29 +15,22 @@ class TestRunNotExistError(Model): """TestRunNotExistError. - Variables are only populated by the server, and will be ignored when - sending a request. - :param message: :type message: str :param code: :type code: int - :ivar details: - :vartype details: list[object] + :param details: + :type details: list[object] """ - _validation = { - 'details': {'readonly': True}, - } - _attribute_map = { 'message': {'key': 'message', 'type': 'str'}, 'code': {'key': 'code', 'type': 'int'}, 'details': {'key': 'details', 'type': '[object]'}, } - def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None: + def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None: super(TestRunNotExistError, self).__init__(**kwargs) self.message = message self.code = code - self.details = None + self.details = details diff --git a/azext_iot/tests/product/test_aics_e2e_int.py b/azext_iot/tests/product/test_aics_e2e_int.py index cbaa9e95c..d91a1a114 100644 --- a/azext_iot/tests/product/test_aics_e2e_int.py +++ b/azext_iot/tests/product/test_aics_e2e_int.py @@ -4,7 +4,6 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -import uuid import json from time import sleep from . import AICSLiveScenarioTest @@ -19,11 +18,8 @@ class TestProductDeviceTestTasks(AICSLiveScenarioTest): def __init__(self, test_case): super(TestProductDeviceTestTasks, self).__init__(test_case) - product_id = str(uuid.uuid4()) self.kwargs.update( { - "product_id": product_id, - "product_name": "IoTProduct", "generate_task": TaskType.GenerateTestCases.value, "queue_task": TaskType.QueueTestRun.value, } @@ -31,9 +27,6 @@ def __init__(self, test_case): def test_e2e(self): - # Test workspace init - self.cmd("iot product init --product-name {product_name}") - # Test requirement list self.cmd("iot product requirement list --base-url {BASE_URL}") @@ -53,9 +46,8 @@ def test_e2e(self): assert requirements_output == expected # Device test operations test = self.cmd( - "iot product test create --at SymmetricKey --dt DevKit -p {product_id} --base-url {BASE_URL}" + "iot product test create --at SymmetricKey --dt DevKit --base-url {BASE_URL}" ).get_output_in_json() - assert test["productId"] == self.kwargs["product_id"] assert test["deviceType"].lower() == "devkit" assert test["provisioningConfiguration"]["type"].lower() == "symmetrickey" assert test["provisioningConfiguration"]["symmetricKeyEnrollmentInformation"][ @@ -67,17 +59,8 @@ def test_e2e(self): test = self.cmd( "iot product test show -t {device_test_id} --base-url {BASE_URL}" ).get_output_in_json() - assert test["productId"] == self.kwargs["product_id"] assert test["id"] == self.kwargs["device_test_id"] - test = self.cmd( - "iot product test search -p {product_id} --base-url {BASE_URL}" - ).get_output_in_json()[0] - assert test["productId"] == self.kwargs["product_id"] - assert test["deviceTestLink"] == "/deviceTests/{}".format( - self.kwargs["device_test_id"] - ) - updated = self.cmd( "iot product test update -t {device_test_id} --at symmetricKey --base-url {BASE_URL}" ).get_output_in_json() @@ -181,8 +164,8 @@ def test_e2e(self): assert show["status"] == DeviceTestTaskStatus.cancelled.value - # Submit run - self.cmd( - "iot product test run submit -t {device_test_id} -r {run_id} --base-url {BASE_URL}", - expect_failure=True, - ) + # # Submit run + # self.cmd( + # "iot product test run submit -t {device_test_id} -r {run_id} --base-url {BASE_URL}", + # expect_failure=True, + # ) diff --git a/azext_iot/tests/product/test_command_test_create_int.py b/azext_iot/tests/product/test_command_test_create_int.py index 5aeb8543e..2991194ee 100644 --- a/azext_iot/tests/product/test_command_test_create_int.py +++ b/azext_iot/tests/product/test_command_test_create_int.py @@ -6,12 +6,10 @@ from . import AICSLiveScenarioTest from azext_iot.product.shared import AttestationType, BadgeType, DeviceType -from uuid import uuid4 class TestTestCreateInt(AICSLiveScenarioTest): def __init__(self, test_case): - self.product_id = str(uuid4()) super(TestTestCreateInt, self).__init__(test_case) def test_create_symmetric_key(self): @@ -21,8 +19,7 @@ def test_create_symmetric_key(self): # call the POST /deviceTest output = self.cmd( - "iot product test create -p {} --dt {} --at {} --bt {} --base-url {}".format( - self.product_id, + "iot product test create --dt {} --at {} --bt {} --base-url {}".format( device_type, attestation_type, badge_type, @@ -30,7 +27,6 @@ def test_create_symmetric_key(self): ) ).get_output_in_json() - assert output["productId"] == self.product_id assert output["deviceType"].lower() == device_type.lower() assert ( output["provisioningConfiguration"]["type"].lower() diff --git a/azext_iot/tests/product/test_command_test_create_unit.py b/azext_iot/tests/product/test_command_test_create_unit.py index d6318955d..5028e062c 100644 --- a/azext_iot/tests/product/test_command_test_create_unit.py +++ b/azext_iot/tests/product/test_command_test_create_unit.py @@ -8,12 +8,11 @@ import mock from knack.util import CLIError from azext_iot.product.test.command_tests import create -from azext_iot.product.shared import BadgeType, AttestationType, DeviceType +from azext_iot.product.shared import BadgeType, AttestationType, DeviceType, ValidationType class TestTestCreateUnit(unittest.TestCase): def __init__(self, test_case): - self.product_id = "b70a3805-5800-4272-93f2-1b4d0150f683" super(TestTestCreateUnit, self).__init__(test_case) def test_create_with_no_parameters_fails(self): @@ -87,7 +86,6 @@ def test_create_with_missing_device_type_fails(self): create( self, attestation_type=AttestationType.symmetricKey.value, - product_id=self.product_id, badge_type=BadgeType.Pnp.value, models="models_folder", ) @@ -97,7 +95,7 @@ def test_create_with_missing_device_type_fails(self): str(context.exception), ) - def test_create_with_missing_product_id_fails(self): + def test_create_certification_with_missing_product_id_fails(self): with self.assertRaises(CLIError) as context: create( self, @@ -105,10 +103,10 @@ def test_create_with_missing_product_id_fails(self): device_type=DeviceType.DevKit.value, badge_type=BadgeType.Pnp.value, models="models_folder", + validation_type=ValidationType.certification.value ) - self.assertEqual( - "If configuration file is not specified, attestation and device definition parameters must be specified", + "Product Id is required for validation type Certification", str(context.exception), ) @@ -120,7 +118,6 @@ def test_create_with_default_badge_type_doesnt_check_models( create( self, attestation_type=AttestationType.symmetricKey.value, - product_id=self.product_id, device_type=DeviceType.DevKit.value, models="models_folder", ) @@ -129,8 +126,8 @@ def test_create_with_default_badge_type_doesnt_check_models( mock_service.assert_called_with( provisioning=True, body={ - "validationType": "Certification", - "productId": self.product_id, + "validationType": "Test", + "productId": None, "deviceType": "DevKit", "provisioningConfiguration": { "type": "SymmetricKey", @@ -153,7 +150,6 @@ def test_create_with_pnp_badge_type_checks_models( create( self, attestation_type=AttestationType.symmetricKey.value, - product_id=self.product_id, device_type=DeviceType.DevKit.value, models="models_folder", badge_type=BadgeType.Pnp.value, @@ -163,8 +159,8 @@ def test_create_with_pnp_badge_type_checks_models( mock_service.assert_called_with( provisioning=True, body={ - "validationType": "Certification", - "productId": self.product_id, + "validationType": "Test", + "productId": None, "deviceType": "DevKit", "provisioningConfiguration": { "type": "SymmetricKey", @@ -198,11 +194,12 @@ def test_create_with_cert_auth_reads_cert_file( create( self, attestation_type=AttestationType.x509.value, - product_id=self.product_id, device_type=DeviceType.DevKit.value, models="models_folder", badge_type=BadgeType.Pnp.value, certificate_path="mycertificate.cer", + product_id="ABC123", + validation_type=ValidationType.certification.value ) mock_read_certificate.assert_called_with("mycertificate.cer") @@ -211,7 +208,7 @@ def test_create_with_cert_auth_reads_cert_file( provisioning=True, body={ "validationType": "Certification", - "productId": self.product_id, + "productId": "ABC123", "deviceType": "DevKit", "provisioningConfiguration": { "type": "X509", @@ -247,7 +244,6 @@ def test_create_with_tpm( self, attestation_type=AttestationType.tpm.value, endorsement_key="12345", - product_id=self.product_id, device_type=DeviceType.DevKit.value, models="models_folder", badge_type=BadgeType.Pnp.value, @@ -259,8 +255,8 @@ def test_create_with_tpm( mock_service.assert_called_with( provisioning=True, body={ - "validationType": "Certification", - "productId": self.product_id, + "validationType": "Test", + "productId": None, "deviceType": "DevKit", "provisioningConfiguration": { "type": "TPM", diff --git a/azext_iot/tests/product/test_command_test_init_unit.py b/azext_iot/tests/product/test_command_test_init_unit.py deleted file mode 100644 index 11afc280c..000000000 --- a/azext_iot/tests/product/test_command_test_init_unit.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -import unittest -import mock -from azext_iot.product.command_product import initialize_workspace - - -class InitClass(unittest.TestCase): - @mock.patch("os.path.exists") - @mock.patch("os.path.join") - @mock.patch("os.mkdir") - @mock.patch("builtins.open", create=True) - @mock.patch("json.dump") - def test_init_with_no_working_folder( - self, mock_dump, mock_open, mock_mkdir, mock_join, mock_exists - ): - mock_exists.return_value = False - mock_join.return_value = "filepath" - initialize_workspace(self, "My product") - mock_mkdir.assert_called_with("PnPCert") - mock_join.assert_called_with("PnPCert", "product_configuration.json") - mock_open.assert_called_with(file="filepath", mode="w+", encoding="utf-8") - mock_dump.assert_called() - call = mock_dump.call_args - call_kwargs = call[1] - self.assertTrue(call_kwargs["obj"]["name"] == "My product") - - @mock.patch("os.path.exists") - @mock.patch("os.path.join") - @mock.patch("os.mkdir") - @mock.patch("builtins.open", create=True) - @mock.patch("json.dump") - def test_init_with_working_folder( - self, mock_dump, mock_open, mock_mkdir, mock_join, mock_exists - ): - mock_exists.return_value = False - mock_join.return_value = "filepath" - initialize_workspace(self, "My product", "my folder") - mock_mkdir.assert_called_with("my folder") - mock_join.assert_called_with("my folder", "product_configuration.json") - mock_open.assert_called_with(file="filepath", mode="w+", encoding="utf-8") - mock_dump.assert_called() - call = mock_dump.call_args - call_kwargs = call[1] - self.assertTrue(call_kwargs["obj"]["name"] == "My product") diff --git a/azext_iot/tests/product/test_command_test_show_int.py b/azext_iot/tests/product/test_command_test_show_int.py index 66ceb6249..88d69ec04 100644 --- a/azext_iot/tests/product/test_command_test_show_int.py +++ b/azext_iot/tests/product/test_command_test_show_int.py @@ -10,7 +10,6 @@ class TestTestShowInt(AICSLiveScenarioTest): def __init__(self, test_case): self.test_id = "524ac74f-752b-4748-9667-45cd09e8a098" - self.product_id = "81cf6ae4-1702-4158-8abe-72473c9ae5ab" super(TestTestShowInt, self).__init__(test_case) def test_show_test(self): @@ -21,5 +20,4 @@ def test_show_test(self): ) ).get_output_in_json() - assert output["productId"] == self.product_id assert output["id"] == self.test_id diff --git a/azext_iot/tests/product/test_device_test_tasks_int.py b/azext_iot/tests/product/test_device_test_tasks_int.py index ef7caa2e2..8ca08d2b1 100644 --- a/azext_iot/tests/product/test_device_test_tasks_int.py +++ b/azext_iot/tests/product/test_device_test_tasks_int.py @@ -63,19 +63,20 @@ def test_product_device_test_tasks(self): "iot product test task show -t {device_test_id} --task-id {queue_task_id} --base-url {BASE_URL}" ).get_output_in_json() assert queue_task["type"] == TaskType.QueueTestRun.value - assert queue_task["status"] == DeviceTestTaskStatus.running.value + assert queue_task["status"] != DeviceTestTaskStatus.queued.value - # Cancel running test task - self.cmd( - "iot product test task delete -t {device_test_id} --task-id {queue_task_id} --base-url {BASE_URL}" - ) + if queue_task["status"] == DeviceTestTaskStatus.running: + # Cancel running test task + self.cmd( + "iot product test task delete -t {device_test_id} --task-id {queue_task_id} --base-url {BASE_URL}" + ) - # allow test to be cancelled - sleep(5) + # allow test to be cancelled + sleep(5) - # get cancelled test task - show = self.cmd( - "iot product test task show -t {device_test_id} --task-id {queue_task_id} --base-url {BASE_URL}" - ).get_output_in_json() + # get cancelled test task + show = self.cmd( + "iot product test task show -t {device_test_id} --task-id {queue_task_id} --base-url {BASE_URL}" + ).get_output_in_json() - assert show["status"] == DeviceTestTaskStatus.cancelled.value + assert show["status"] == DeviceTestTaskStatus.cancelled.value