winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 2f7f20dd134e90905e4e97f7b900ccff500e3685
parent aa954a4b19b5bc38e950e8bdc7fe14c313eb70ab
Author: yao-msft <50888816+yao-msft@users.noreply.github.com>
Date:   Tue,  2 Nov 2021 16:36:30 -0700

Fix yaml manifest schema and parsing for ExpectedReturnCodes (#1646)


Diffstat:
Mschemas/JSON/manifests/v1.0.0/manifest.defaultLocale.1.0.0.json | 2+-
Mschemas/JSON/manifests/v1.0.0/manifest.installer.1.0.0.json | 4++--
Mschemas/JSON/manifests/v1.0.0/manifest.locale.1.0.0.json | 8++------
Mschemas/JSON/manifests/v1.0.0/manifest.singleton.1.0.0.json | 7++-----
Mschemas/JSON/manifests/v1.0.0/manifest.version.1.0.0.json | 2+-
Mschemas/JSON/manifests/v1.1.0/manifest.defaultLocale.1.1.0.json | 2+-
Mschemas/JSON/manifests/v1.1.0/manifest.installer.1.1.0.json | 4++--
Mschemas/JSON/manifests/v1.1.0/manifest.locale.1.1.0.json | 8++------
Mschemas/JSON/manifests/v1.1.0/manifest.singleton.1.1.0.json | 7++-----
Mschemas/JSON/manifests/v1.1.0/manifest.version.1.1.0.json | 2+-
Msrc/AppInstallerCLITests/AppInstallerCLITests.vcxproj | 3+++
Msrc/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters | 3+++
Msrc/AppInstallerCLITests/RestInterface_1_1.cpp | 1-
Asrc/AppInstallerCLITests/TestData/Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml | 18++++++++++++++++++
Msrc/AppInstallerCLITests/YamlManifest.cpp | 1+
Msrc/AppInstallerCommonCore/Manifest/ManifestYamlPopulator.cpp | 5+++--
Msrc/AppInstallerRepositoryCore/Rest/Schema/1_1/Json/ManifestDeserializer_1_1.cpp | 11+++++++++++
17 files changed, 55 insertions(+), 33 deletions(-)

diff --git a/schemas/JSON/manifests/v1.0.0/manifest.defaultLocale.1.0.0.json b/schemas/JSON/manifests/v1.0.0/manifest.defaultLocale.1.0.0.json @@ -33,7 +33,7 @@ "PackageLocale": { "type": "string", "default": "en-US", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The package meta-data locale" }, diff --git a/schemas/JSON/manifests/v1.0.0/manifest.installer.1.0.0.json b/schemas/JSON/manifests/v1.0.0/manifest.installer.1.0.0.json @@ -17,9 +17,9 @@ }, "Locale": { "type": [ "string", "null" ], - "minLength": 1, + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, - "description": "The package meta-data locale" + "description": "The installer meta-data locale" }, "Channel": { "type": [ "string", "null" ], diff --git a/schemas/JSON/manifests/v1.0.0/manifest.locale.1.0.0.json b/schemas/JSON/manifests/v1.0.0/manifest.locale.1.0.0.json @@ -13,7 +13,7 @@ "type": [ "string", "null" ], "minLength": 1, "maxLength": 40, - "description": "Package moniker or tag" + "description": "Package tag" } }, "type": "object", @@ -32,7 +32,7 @@ }, "PackageLocale": { "type": "string", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The package meta-data locale" }, @@ -102,10 +102,6 @@ "maxLength": 10000, "description": "The full package description" }, - "Moniker": { - "$ref": "#/definitions/Tag", - "description": "The most common package term" - }, "Tags": { "type": [ "array", "null" ], "items": { diff --git a/schemas/JSON/manifests/v1.0.0/manifest.singleton.1.0.0.json b/schemas/JSON/manifests/v1.0.0/manifest.singleton.1.0.0.json @@ -17,7 +17,7 @@ }, "Locale": { "type": [ "string", "null" ], - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The package meta-data locale" }, @@ -387,10 +387,7 @@ "$ref": "#/definitions/PackageVersion" }, "PackageLocale": { - "type": "string", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", - "maxLength": 20, - "description": "The package meta-data locale" + "$ref": "#/definitions/Locale" }, "Publisher": { "type": "string", diff --git a/schemas/JSON/manifests/v1.0.0/manifest.version.1.0.0.json b/schemas/JSON/manifests/v1.0.0/manifest.version.1.0.0.json @@ -19,7 +19,7 @@ "DefaultLocale": { "type": "string", "default": "en-US", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The default package meta-data locale" }, diff --git a/schemas/JSON/manifests/v1.1.0/manifest.defaultLocale.1.1.0.json b/schemas/JSON/manifests/v1.1.0/manifest.defaultLocale.1.1.0.json @@ -54,7 +54,7 @@ "PackageLocale": { "type": "string", "default": "en-US", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The package meta-data locale" }, diff --git a/schemas/JSON/manifests/v1.1.0/manifest.installer.1.1.0.json b/schemas/JSON/manifests/v1.1.0/manifest.installer.1.1.0.json @@ -17,9 +17,9 @@ }, "Locale": { "type": [ "string", "null" ], - "minLength": 1, + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, - "description": "The package meta-data locale" + "description": "The installer meta-data locale" }, "Channel": { "type": [ "string", "null" ], diff --git a/schemas/JSON/manifests/v1.1.0/manifest.locale.1.1.0.json b/schemas/JSON/manifests/v1.1.0/manifest.locale.1.1.0.json @@ -13,7 +13,7 @@ "type": [ "string", "null" ], "minLength": 1, "maxLength": 40, - "description": "Package moniker or tag" + "description": "Package tag" }, "Agreement": { "type": "object", @@ -53,7 +53,7 @@ }, "PackageLocale": { "type": "string", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The package meta-data locale" }, @@ -123,10 +123,6 @@ "maxLength": 10000, "description": "The full package description" }, - "Moniker": { - "$ref": "#/definitions/Tag", - "description": "The most common package term" - }, "Tags": { "type": [ "array", "null" ], "items": { diff --git a/schemas/JSON/manifests/v1.1.0/manifest.singleton.1.1.0.json b/schemas/JSON/manifests/v1.1.0/manifest.singleton.1.1.0.json @@ -17,7 +17,7 @@ }, "Locale": { "type": [ "string", "null" ], - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The package meta-data locale" }, @@ -590,10 +590,7 @@ "$ref": "#/definitions/PackageVersion" }, "PackageLocale": { - "type": "string", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", - "maxLength": 20, - "description": "The package meta-data locale" + "$ref": "#/definitions/Locale" }, "Publisher": { "type": "string", diff --git a/schemas/JSON/manifests/v1.1.0/manifest.version.1.1.0.json b/schemas/JSON/manifests/v1.1.0/manifest.version.1.1.0.json @@ -19,7 +19,7 @@ "DefaultLocale": { "type": "string", "default": "en-US", - "pattern": "^([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", + "pattern": "^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$", "maxLength": 20, "description": "The default package meta-data locale" }, diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj @@ -469,6 +469,9 @@ <CopyFileToFolders Include="TestData\Manifest-Good-AllDependencyTypes.yaml"> <DeploymentContent>true</DeploymentContent> </CopyFileToFolders> + <CopyFileToFolders Include="TestData\Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml"> + <DeploymentContent>true</DeploymentContent> + </CopyFileToFolders> <CopyFileToFolders Include="TestData\Manifest-Encoding-ANSI.yaml"> <DeploymentContent>true</DeploymentContent> </CopyFileToFolders> diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters @@ -513,6 +513,9 @@ <CopyFileToFolders Include="TestData\Manifest-Good-AllDependencyTypes.yaml"> <Filter>TestData</Filter> </CopyFileToFolders> + <CopyFileToFolders Include="TestData\Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml"> + <Filter>TestData</Filter> + </CopyFileToFolders> <CopyFileToFolders Include="TestData\ImportFile-Good-Dependencies.json"> <Filter>TestData</Filter> </CopyFileToFolders> diff --git a/src/AppInstallerCLITests/RestInterface_1_1.cpp b/src/AppInstallerCLITests/RestInterface_1_1.cpp @@ -297,7 +297,6 @@ namespace REQUIRE(actualInstaller.AppsAndFeaturesEntries.at(0).InstallerType == InstallerTypeEnum::Exe); REQUIRE(actualInstaller.Markets.AllowedMarkets.size() == 1); REQUIRE(actualInstaller.Markets.AllowedMarkets.at(0) == "US"); - REQUIRE(actualInstaller.ExpectedReturnCodes.size() == 1); REQUIRE(actualInstaller.ExpectedReturnCodes.at(3) == ExpectedReturnCodeEnum::InstallInProgress); } }; diff --git a/src/AppInstallerCLITests/TestData/Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml b/src/AppInstallerCLITests/TestData/Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml @@ -0,0 +1,18 @@ +# Default expected return codes exist in InstallerSuccessCodes +PackageIdentifier: microsoft.msixsdk +PackageName: MSIX SDK +PackageVersion: 1.07.32-beta +Publisher: Microsoft +ShortDescription: description +License: Test +PackageLocale: en-US +InstallerSuccessCodes: +- 1603 +- 3010 +Installers: + - Architecture: x86 + InstallerUrl: https://rubengustorage.blob.core.windows.net/publiccontainer/msixsdk-x86.msi + InstallerSha256: 98B67758CEAFFCBB3FE47838FD0A8D7BD581C2650842D6B2B0E0D49A23270CCD + InstallerType: msi +ManifestType: singleton +ManifestVersion: 1.1.0 diff --git a/src/AppInstallerCLITests/YamlManifest.cpp b/src/AppInstallerCLITests/YamlManifest.cpp @@ -220,6 +220,7 @@ TEST_CASE("ReadGoodManifests", "[ManifestValidation]") { "Manifest-Good-Minimum.yaml" }, { "Manifest-Good-Minimum-InstallerType.yaml" }, { "Manifest-Good-Switches.yaml" }, + { "Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml" }, }; for (auto const& testCase : TestCases) diff --git a/src/AppInstallerCommonCore/Manifest/ManifestYamlPopulator.cpp b/src/AppInstallerCommonCore/Manifest/ManifestYamlPopulator.cpp @@ -754,11 +754,12 @@ namespace AppInstaller::Manifest } } - // Populate installer default return codes if not present + // Populate installer default return codes if not present in ExpectedReturnCodes and InstallerSuccessCodes auto defaultReturnCodes = GetDefaultKnownReturnCodes(installer.InstallerType); for (auto const& defaultReturnCode : defaultReturnCodes) { - if (installer.ExpectedReturnCodes.find(defaultReturnCode.first) == installer.ExpectedReturnCodes.end()) + if (installer.ExpectedReturnCodes.find(defaultReturnCode.first) == installer.ExpectedReturnCodes.end() && + std::find(installer.InstallerSuccessCodes.begin(), installer.InstallerSuccessCodes.end(), defaultReturnCode.first) == installer.InstallerSuccessCodes.end()) { installer.ExpectedReturnCodes[defaultReturnCode.first] = defaultReturnCode.second; } diff --git a/src/AppInstallerRepositoryCore/Rest/Schema/1_1/Json/ManifestDeserializer_1_1.cpp b/src/AppInstallerRepositoryCore/Rest/Schema/1_1/Json/ManifestDeserializer_1_1.cpp @@ -147,6 +147,17 @@ namespace AppInstaller::Repository::Rest::Schema::V1_1::Json } } } + + // Populate installer default return codes if not present in ExpectedReturnCodes and InstallerSuccessCodes + auto defaultReturnCodes = GetDefaultKnownReturnCodes(installer.InstallerType); + for (auto const& defaultReturnCode : defaultReturnCodes) + { + if (installer.ExpectedReturnCodes.find(defaultReturnCode.first) == installer.ExpectedReturnCodes.end() && + std::find(installer.InstallerSuccessCodes.begin(), installer.InstallerSuccessCodes.end(), defaultReturnCode.first) == installer.InstallerSuccessCodes.end()) + { + installer.ExpectedReturnCodes[defaultReturnCode.first] = defaultReturnCode.second; + } + } } return result;