Skip to content

Commit 15232a7

Browse files
authored
Add Font source group policy support (microsoft#5646)
<!-- To check a checkbox place an "x" between the brackets. e.g: [x] --> This is for issue [5644](microsoft#5644) * microsoft#5644 The purpose of this is to create a group policy definition in anticipation of the upcoming font support so IT administrators can be prepared for its inclusion and lead time. It is not the intent of this checkin to actually implement the font source, but to create the policy so enterprises can be better prepared for it and have more lead time to adjust. Changes: * Added the Font Source group policy and associated tests and strings. Verified build and groupPolicy tests. - [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. ----- ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5646)
1 parent 53e6c0c commit 15232a7

File tree

26 files changed

+157
-7
lines changed

26 files changed

+157
-7
lines changed

doc/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
## Bug Fixes
77
* Manifest validation no longer fails using `UTF-8 BOM` encoding when the schema header is on the first line
88
* Upgrading a portable package with dev mode disabled will no longer remove the package from the PATH variable.
9+
* Fixed source open failure when there were multiple sources but less than two non-explicit sources.
910

1011
## Experimental Features
1112
* Experimental support for Fonts

doc/admx/DesktopAppInstaller.admx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@
103103
<decimal value="0" />
104104
</disabledValue>
105105
</policy>
106+
<policy name="EnableFontSource" class="Machine" displayName="$(string.EnableFontSource)" explainText="$(string.EnableFontSourceExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableFontSource">
107+
<parentCategory ref="AppInstaller" />
108+
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
109+
<enabledValue>
110+
<decimal value="1" />
111+
</enabledValue>
112+
<disabledValue>
113+
<decimal value="0" />
114+
</disabledValue>
115+
</policy>
106116
<policy name="SourceAutoUpdateInterval" class="Machine" displayName="$(string.SourceAutoUpdateInterval)" explainText="$(string.SourceAutoUpdateIntervalExplanation)" presentation="$(presentation.SourceAutoUpdateInterval)" key="Software\Policies\Microsoft\Windows\AppInstaller">
107117
<parentCategory ref="AppInstaller" />
108118
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />

doc/admx/en-US/DesktopAppInstaller.adml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ If you do not configure this setting, the Microsoft Store source for the Windows
6767
If you enable this setting, the Microsoft Store source for the Windows Package Manager will be available and cannot be removed.
6868

6969
If you disable this setting the Microsoft Store source for the Windows Package Manager will not be available.</string>
70+
<string id="EnableFontSource">Enable Windows Package Manager Font Source</string>
71+
<string id="EnableFontSourceExplanation">
72+
This policy controls the Font source included with the Windows Package Manager.
73+
74+
If you do not configure this setting, the Font source for the Windows Package manager will be available and can be removed.
75+
76+
If you enable this setting, the Font source for the Windows Package Manager will be available and cannot be removed.
77+
78+
If you disable this setting the Font source for the Windows Package Manager will not be available.
79+
</string>
7080
<string id="SourceAutoUpdateInterval">Set Windows Package Manager Source Auto Update Interval In Minutes</string>
7181
<string id="SourceAutoUpdateIntervalExplanation">This policy controls the auto-update interval for package-based sources. The default source for Windows Package Manager is configured such that an index of the packages is cached on the local machine. The index is downloaded when a user invokes a command, and the interval has passed.
7282

src/AppInstallerCLICore/ConfigurationWingetDscModuleUnitValidation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace AppInstaller::CLI::Configuration
1919

2020
constexpr static std::string_view WellKnownSourceName_WinGet = "winget"sv;
2121
constexpr static std::string_view WellKnownSourceName_MSStore = "msstore"sv;
22+
constexpr static std::string_view WellKnownSourceName_WinGetFont = "winget-font"sv;
2223

2324
constexpr static std::string_view ValueSetKey_TreatAsArray = "treatAsArray"sv;
2425

@@ -101,7 +102,8 @@ namespace AppInstaller::CLI::Configuration
101102
bool IsWellKnownSourceName(std::string_view sourceName)
102103
{
103104
return Utility::CaseInsensitiveEquals(WellKnownSourceName_WinGet, sourceName) ||
104-
Utility::CaseInsensitiveEquals(WellKnownSourceName_MSStore, sourceName);
105+
Utility::CaseInsensitiveEquals(WellKnownSourceName_MSStore, sourceName) ||
106+
Utility::CaseInsensitiveEquals(WellKnownSourceName_WinGetFont, sourceName);
105107
}
106108

107109
bool ValidateWellKnownSource(const WinGetSource& source)
@@ -110,6 +112,7 @@ namespace AppInstaller::CLI::Configuration
110112
{
111113
Repository::Source{ Repository::WellKnownSource::WinGet }.GetDetails(),
112114
Repository::Source{ Repository::WellKnownSource::MicrosoftStore }.GetDetails(),
115+
Repository::Source{ Repository::WellKnownSource::WinGetFont }.GetDetails(),
113116
};
114117

115118
for (auto const& wellKnownSource : wellKnownSourceDetails)

src/AppInstallerCLIE2ETests/FeaturesCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public void EnableExperimentalFeatures()
5353
WinGetSettingsHelper.ConfigureFeature("experimentalCmd", true);
5454
WinGetSettingsHelper.ConfigureFeature("directMSI", true);
5555
WinGetSettingsHelper.ConfigureFeature("resume", true);
56+
WinGetSettingsHelper.ConfigureFeature("fonts", true);
5657
var result = TestCommon.RunAICLICommand("features", string.Empty);
5758
Assert.True(result.StdOut.Contains("Enabled"));
5859
}

src/AppInstallerCLIE2ETests/GroupPolicy.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ public void EnableMicrosoftStoreSource()
160160
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
161161
}
162162

163+
/// <summary>
164+
/// Test font source is enabled by policy.
165+
/// </summary>
166+
[Test]
167+
public void EnableFontSource()
168+
{
169+
WinGetSettingsHelper.ConfigureFeature("fonts", true);
170+
GroupPolicyHelper.EnableFontSource.Disable();
171+
172+
var result = TestCommon.RunAICLICommand("source list", "winget-font");
173+
Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
174+
175+
GroupPolicyHelper.EnableFontSource.Enable();
176+
result = TestCommon.RunAICLICommand("source list", "winget-font");
177+
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
178+
}
179+
163180
/// <summary>
164181
/// Test additional sources are enabled by policy.
165182
/// </summary>

src/AppInstallerCLIE2ETests/GroupPolicyHelper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ private GroupPolicyHelper(string name, string elementId)
103103
/// </summary>
104104
public static GroupPolicyHelper EnableMicrosoftStoreSource { get; private set; } = new GroupPolicyHelper("EnableMicrosoftStoreSource");
105105

106+
/// <summary>
107+
/// Gets the Enable font source policy.
108+
/// </summary>
109+
public static GroupPolicyHelper EnableFontSource { get; private set; } = new GroupPolicyHelper("EnableFontSource");
110+
106111
/// <summary>
107112
/// Gets the Enable additional sources policy.
108113
/// </summary>
@@ -138,6 +143,7 @@ private GroupPolicyHelper(string name, string elementId)
138143
EnableLocalArchiveMalwareScanOverride,
139144
EnableDefaultSource,
140145
EnableMicrosoftStoreSource,
146+
EnableFontSource,
141147
EnableAdditionalSources,
142148
EnableAllowedSources,
143149
SourceAutoUpdateInterval,

src/AppInstallerCLIE2ETests/Helpers/WinGetSettingsHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ public static void InitializeAllFeatures(bool status)
226226
ConfigureFeature(settingsJson, "windowsFeature", status);
227227
ConfigureFeature(settingsJson, "resume", status);
228228
ConfigureFeature(settingsJson, "reboot", status);
229+
ConfigureFeature(settingsJson, "fonts", status);
229230

230231
SetWingetSettings(settingsJson);
231232
}

src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ They can be configured through the settings file 'winget settings'.</value>
900900
<data name="PolicyEnableMSStoreSource" xml:space="preserve">
901901
<value>Enable Windows App Installer Microsoft Store Source</value>
902902
</data>
903+
<data name="PolicyEnableFontSource" xml:space="preserve">
904+
<value>Enable Windows App Installer Font Source</value>
905+
</data>
903906
<data name="PolicyEnableWinGetSettings" xml:space="preserve">
904907
<value>Enable Windows Package Manager Settings</value>
905908
</data>

src/AppInstallerCLITests/GroupPolicy.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ TEST_CASE("GroupPolicy_AllEnabled", "[groupPolicy]")
395395
SetRegistryValue(policiesKey.get(), EnableHashOverridePolicyValueName, 1);
396396
SetRegistryValue(policiesKey.get(), EnableLocalArchiveMalwareScanOverridePolicyValueName, 1);
397397
SetRegistryValue(policiesKey.get(), DefaultSourcePolicyValueName, 1);
398-
SetRegistryValue(policiesKey.get(), MSStoreSourcePolicyValueName, 1);;
398+
SetRegistryValue(policiesKey.get(), MSStoreSourcePolicyValueName, 1);
399+
SetRegistryValue(policiesKey.get(), FontSourcePolicyValueName, 1);
399400
SetRegistryValue(policiesKey.get(), AdditionalSourcesPolicyValueName, 1);
400401
SetRegistryValue(policiesKey.get(), AllowedSourcesPolicyValueName, 1);
401402
SetRegistryValue(policiesKey.get(), BypassCertificatePinningForMicrosoftStoreValueName, 1);

0 commit comments

Comments
 (0)