Skip to content

Commit ddb86d4

Browse files
authored
Add RestSource and tests for Manifest v1.12 (#5695)
Closes #5694 Updates the RestSource and interface to support v1.12 Manifest schema. * Added Manifest 1.12 Schema to the Rest source and support for the new installer type. * Added tests for v1.12 rest source. * Added unit tests for WinGetUtilInterop for the v1.12 merged manifest and validating the new installertype. Tested: * WinGetUtilInterop Unit tests passed, verified in debugger that the new v1.12 manifest and manifest properties were being tested and validated. * AppInstallerCLITests for [RestSource] and the new [Interface_1_12] both pass. <!-- To check a checkbox place an "x" between the brackets. e.g: [x] --> (This is part of schema update for 1.12 so nothing new to add to release notes.) - [x] I have signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs). - [x] I have updated the [Release Notes](../doc/ReleaseNotes.md). - [x] This pull request is related to an issue. -----
1 parent 2a5443a commit ddb86d4

16 files changed

+878
-4
lines changed

src/AppInstallerCLITests/AppInstallerCLITests.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@
278278
<ClCompile Include="RestInterface_1_0.cpp" />
279279
<ClCompile Include="RestInterface_1_1.cpp" />
280280
<ClCompile Include="RestInterface_1_10.cpp" />
281+
<ClCompile Include="RestInterface_1_12.cpp" />
281282
<ClCompile Include="RestInterface_1_4.cpp" />
282283
<ClCompile Include="RestInterface_1_5.cpp" />
283284
<ClCompile Include="RestInterface_1_6.cpp" />

src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@
377377
<ClCompile Include="RestInterface_1_10.cpp">
378378
<Filter>Source Files\Repository</Filter>
379379
</ClCompile>
380+
<ClCompile Include="RestInterface_1_12.cpp">
381+
<Filter>Source Files\Repository</Filter>
382+
</ClCompile>
380383
<ClCompile Include="ManifestComparator.cpp">
381384
<Filter>Source Files\Common</Filter>
382385
</ClCompile>

src/AppInstallerCLITests/RestClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ TEST_CASE("GetSupportedInterface", "[RestSource]")
6161
REQUIRE(RestClient::GetSupportedInterface(TestRestUri, {}, info, {}, version, {})->GetVersion() == version);
6262

6363
// Update this test to next version so that we don't forget to add to supported versions before rest e2e tests are available.
64-
Version invalid{ "1.11.0" };
64+
Version invalid{ "1.13.0" };
6565
REQUIRE_THROWS_HR(RestClient::GetSupportedInterface(TestRestUri, {}, info, {}, invalid, {}), APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION);
6666

6767
Authentication::AuthenticationArguments authArgs;

src/AppInstallerCLITests/RestInterface_1_12.cpp

Lines changed: 411 additions & 0 deletions
Large diffs are not rendered by default.

src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@
383383
<ClInclude Include="Rest\Schema\1_0\Json\SearchResponseDeserializer.h" />
384384
<ClInclude Include="Rest\Schema\1_10\Interface.h" />
385385
<ClInclude Include="Rest\Schema\1_10\Json\ManifestDeserializer.h" />
386+
<ClInclude Include="Rest\Schema\1_12\Interface.h" />
387+
<ClInclude Include="Rest\Schema\1_12\Json\ManifestDeserializer.h" />
386388
<ClInclude Include="Rest\Schema\1_1\Interface.h" />
387389
<ClInclude Include="Rest\Schema\1_1\Json\ManifestDeserializer.h" />
388390
<ClInclude Include="Rest\Schema\1_1\Json\SearchRequestSerializer.h" />
@@ -480,6 +482,8 @@
480482
<ClCompile Include="Rest\Schema\1_0\Json\SearchResponseDeserializer_1_0.cpp" />
481483
<ClCompile Include="Rest\Schema\1_10\Json\ManifestDeserializer_1_10.cpp" />
482484
<ClCompile Include="Rest\Schema\1_10\RestInterface_1_10.cpp" />
485+
<ClCompile Include="Rest\Schema\1_12\Json\ManifestDeserializer_1_12.cpp" />
486+
<ClCompile Include="Rest\Schema\1_12\RestInterface_1_12.cpp" />
483487
<ClCompile Include="Rest\Schema\1_1\Json\ManifestDeserializer_1_1.cpp" />
484488
<ClCompile Include="Rest\Schema\1_1\Json\SearchRequestSerializer_1_1.cpp" />
485489
<ClCompile Include="Rest\Schema\1_1\RestInterface_1_1.cpp" />

src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj.filters

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
<Filter Include="Rest\Schema\1_10\Json">
116116
<UniqueIdentifier>{1a1efb9f-7332-4094-bb98-a4c51ea68b24}</UniqueIdentifier>
117117
</Filter>
118+
<Filter Include="Rest\Schema\1_12">
119+
<UniqueIdentifier>{c29ae113-5eb6-41af-b64d-fac925dcf2c2}</UniqueIdentifier>
120+
</Filter>
121+
<Filter Include="Rest\Schema\1_12\Json">
122+
<UniqueIdentifier>{2075b51e-aa11-473a-bae0-e0d4366f926b}</UniqueIdentifier>
123+
</Filter>
118124
</ItemGroup>
119125
<ItemGroup>
120126
<ClInclude Include="pch.h">
@@ -486,6 +492,12 @@
486492
<ClInclude Include="Rest\Schema\1_10\Json\ManifestDeserializer.h">
487493
<Filter>Rest\Schema\1_10\Json</Filter>
488494
</ClInclude>
495+
<ClInclude Include="Rest\Schema\1_12\Interface.h">
496+
<Filter>Rest\Schema\1_12</Filter>
497+
</ClInclude>
498+
<ClInclude Include="Rest\Schema\1_12\Json\ManifestDeserializer.h">
499+
<Filter>Rest\Schema\1_12\Json</Filter>
500+
</ClInclude>
489501
</ItemGroup>
490502
<ItemGroup>
491503
<ClCompile Include="pch.cpp">
@@ -758,6 +770,12 @@
758770
<ClCompile Include="Rest\Schema\1_10\Json\ManifestDeserializer_1_10.cpp">
759771
<Filter>Rest\Schema\1_10\Json</Filter>
760772
</ClCompile>
773+
<ClCompile Include="Rest\Schema\1_12\RestInterface_1_12.cpp">
774+
<Filter>Rest\Schema\1_12</Filter>
775+
</ClCompile>
776+
<ClCompile Include="Rest\Schema\1_12\Json\ManifestDeserializer_1_12.cpp">
777+
<Filter>Rest\Schema\1_12\Json</Filter>
778+
</ClCompile>
761779
</ItemGroup>
762780
<ItemGroup>
763781
<None Include="PropertySheet.props" />

src/AppInstallerRepositoryCore/ManifestJSONParser.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Rest/Schema/1_7/Json/ManifestDeserializer.h"
1111
#include "Rest/Schema/1_9/Json/ManifestDeserializer.h"
1212
#include "Rest/Schema/1_10/Json/ManifestDeserializer.h"
13+
#include "Rest/Schema/1_12/Json/ManifestDeserializer.h"
1314

1415
namespace AppInstaller::Repository::JSON
1516
{
@@ -56,10 +57,14 @@ namespace AppInstaller::Repository::JSON
5657
{
5758
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_9::Json::ManifestDeserializer>();
5859
}
59-
else
60+
else if (parts.size() > 1 && parts[1].Integer < 12)
6061
{
6162
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_10::Json::ManifestDeserializer>();
6263
}
64+
else
65+
{
66+
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_12::Json::ManifestDeserializer>();
67+
}
6368
}
6469
else
6570
{

src/AppInstallerRepositoryCore/Rest/RestClient.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Rest/Schema/1_7/Interface.h"
1111
#include "Rest/Schema/1_9/Interface.h"
1212
#include "Rest/Schema/1_10/Interface.h"
13+
#include "Rest/Schema/1_12/Interface.h"
1314
#include "Rest/Schema/InformationResponseDeserializer.h"
1415
#include "Rest/Schema/CommonRestConstants.h"
1516
#include <winget/HttpClientHelper.h>
@@ -24,7 +25,17 @@ using namespace AppInstaller::Http;
2425
namespace AppInstaller::Repository::Rest
2526
{
2627
// Supported versions
27-
std::set<Version> WingetSupportedContracts = { Version_1_0_0, Version_1_1_0, Version_1_4_0, Version_1_5_0, Version_1_6_0, Version_1_7_0, Version_1_9_0, Version_1_10_0 };
28+
std::set<Version> WingetSupportedContracts = {
29+
Version_1_0_0,
30+
Version_1_1_0,
31+
Version_1_4_0,
32+
Version_1_5_0,
33+
Version_1_6_0,
34+
Version_1_7_0,
35+
Version_1_9_0,
36+
Version_1_10_0,
37+
Version_1_12_0,
38+
};
2839

2940
constexpr std::string_view WindowsPackageManagerHeader = "Windows-Package-Manager"sv;
3041
constexpr size_t WindowsPackageManagerHeaderMaxLength = 1024;
@@ -186,6 +197,10 @@ namespace AppInstaller::Repository::Rest
186197
{
187198
return std::make_unique<Schema::V1_10::Interface>(api, helper, information, additionalHeaders, authArgs);
188199
}
200+
else if (version == Version_1_12_0)
201+
{
202+
return std::make_unique<Schema::V1_12::Interface>(api, helper, information, additionalHeaders, authArgs);
203+
}
189204

190205
THROW_HR(APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION);
191206
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#pragma once
4+
#include "Rest/Schema/1_10/Interface.h"
5+
6+
namespace AppInstaller::Repository::Rest::Schema::V1_12
7+
{
8+
// Interface to this schema version exposed through IRestClient.
9+
struct Interface : public V1_10::Interface
10+
{
11+
Interface(const std::string& restApi, const Http::HttpClientHelper& helper, IRestClient::Information information, const Http::HttpClientHelper::HttpRequestHeaders& additionalHeaders = {}, Authentication::AuthenticationArguments authArgs = {});
12+
13+
Interface(const Interface&) = delete;
14+
Interface& operator=(const Interface&) = delete;
15+
16+
Interface(Interface&&) = default;
17+
Interface& operator=(Interface&&) = default;
18+
19+
Utility::Version GetVersion() const override;
20+
};
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#pragma once
4+
#include "Rest/Schema/1_10/Json/ManifestDeserializer.h"
5+
6+
namespace AppInstaller::Repository::Rest::Schema::V1_12::Json
7+
{
8+
// Manifest Deserializer.
9+
struct ManifestDeserializer : public V1_10::Json::ManifestDeserializer
10+
{
11+
protected:
12+
13+
Manifest::InstallerTypeEnum ConvertToInstallerType(std::string_view in) const override;
14+
15+
Manifest::ManifestVer GetManifestVersion() const override;
16+
};
17+
}

0 commit comments

Comments
 (0)