Skip to content

Commit

Permalink
Merge branch 'dev' into ado_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
c-ryan-k authored Jun 6, 2024
2 parents 4068ec0 + 6a3d8b8 commit c1545cb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
8 changes: 2 additions & 6 deletions azext_iot/deviceupdate/commands_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def manifest_init_v5(
):
from datetime import datetime
from pathlib import PurePath
from azure.cli.core.azclierror import ArgumentUsageError, InvalidArgumentValueError
from azext_iot.deviceupdate.common import FP_HANDLERS, FP_HANDLERS_REQUIRE_CRITERIA
from azure.cli.core.azclierror import ArgumentUsageError
from azext_iot.deviceupdate.common import FP_HANDLERS_REQUIRE_CRITERIA
from azext_iot.deviceupdate.providers.utility import parse_manifest_json

def _sanitize_safe_params(safe_params: list, keep: list) -> list:
Expand Down Expand Up @@ -323,10 +323,6 @@ def _associate_related(sanitized_params: list, key: str) -> dict:
"handler": assembled_step["handler"],
}

if step["handler"].lower().startswith("microsoft") and step["handler"] not in FP_HANDLERS:
if not no_validation:
raise InvalidArgumentValueError(f"Valid Microsoft handlers: {', '.join(FP_HANDLERS)}")

step["files"] = (
list(set([f.strip() for f in assembled_step["files"].split(",")])) if "files" in assembled_step else []
)
Expand Down
56 changes: 40 additions & 16 deletions azext_iot/tests/deviceupdate/test_adu_manifest_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,46 @@
"manifestVersion": "5.0",
},
),
(
"--update-provider digimaun0 --update-name customhandler --update-version 0.1 "
"--compat manufacturer=Contoso model=Vacuum "
"--compat ring=0 tier=test "
"--step handler=microsoft/customhandler:2 "
f"--file path=\"{get_context_path(__file__, 'manifests', 'libcurl4-doc-apt-manifest.json')}\" "
f"--related-file path=\"{get_context_path(__file__, 'manifests', 'surface15', 'parent.importmanifest.json')}\" ",
{
"updateId": {"provider": "digimaun0", "name": "customhandler", "version": "0.1"},
"compatibility": [
{"manufacturer": "Contoso", "model": "Vacuum"},
{"ring": "0", "tier": "test"},
],
"instructions": {
# no first party handler validation
"steps": [
{
"handler": "microsoft/customhandler:2",
"files": ["libcurl4-doc-apt-manifest.json"],
"type": "inline",
},
]
},
"files": [
{
"filename": "libcurl4-doc-apt-manifest.json",
"sizeInBytes": 163,
"hashes": {"sha256": "iFWTIaxp33tf5BR1w0fMmnnHpjsUjLRQ9eZFjw74LbU="},
"relatedFiles": [
{
"filename": "parent.importmanifest.json",
"sizeInBytes": 1390,
"hashes": {"sha256": "hos1UvCk66WmtL/SPNUmub+k302BM4gtWYtAF7tOCb4="},
}
],
}
],
"manifestVersion": "5.0",
},
),
],
)
def test_adu_manifest_init_v5(options, expected):
Expand Down Expand Up @@ -514,22 +554,6 @@ def test_adu_manifest_init_v5_invalid_path_required(options):
"downloadHandler=abc",
True,
),
(
# If content handler starts with microsoft (case-insensitive) enforce valid value.
"--update-provider digimaun --update-name invalid --update-version 1.0 "
"--compat deviceManufacturer=Contoso deviceModel=Vacuum "
"--step handler=microsoft/fake:1 "
f"--file path=\"{get_context_path(__file__, 'manifests', 'libcurl4-doc-apt-manifest.json')}\" ",
False,
),
(
# Same as prior test case but ensure escape hatch with --no-validation
"--update-provider digimaun --update-name invalid --update-version 1.0 "
"--compat deviceManufacturer=Contoso deviceModel=Vacuum "
"--step handler=microsoft/fake:1 "
f"--file path=\"{get_context_path(__file__, 'manifests', 'libcurl4-doc-apt-manifest.json')}\" ",
False,
),
],
)
def test_adu_manifest_init_v5_validate_errors(options, no_validation):
Expand Down

0 comments on commit c1545cb

Please sign in to comment.