mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Add policy support for linux (#272579)
This commit is contained in:
@@ -57,6 +57,7 @@ ${this.renderProfileManifestValue(translations)}
|
|||||||
</dict>`;
|
</dict>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract renderJsonValue(): string | number | boolean | object | null;
|
||||||
abstract renderProfileValue(): string;
|
abstract renderProfileValue(): string;
|
||||||
abstract renderProfileManifestValue(translations?: LanguageTranslations): string;
|
abstract renderProfileManifestValue(translations?: LanguageTranslations): string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ class BooleanPolicy extends basePolicy_1.BasePolicy {
|
|||||||
renderADMLPresentationContents() {
|
renderADMLPresentationContents() {
|
||||||
return `<checkBox refId="${this.name}">${this.name}</checkBox>`;
|
return `<checkBox refId="${this.name}">${this.name}</checkBox>`;
|
||||||
}
|
}
|
||||||
|
renderJsonValue() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
renderProfileValue() {
|
renderProfileValue() {
|
||||||
return `<false/>`;
|
return `<false/>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ export class BooleanPolicy extends BasePolicy {
|
|||||||
return `<checkBox refId="${this.name}">${this.name}</checkBox>`;
|
return `<checkBox refId="${this.name}">${this.name}</checkBox>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderJsonValue() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
renderProfileValue(): string {
|
renderProfileValue(): string {
|
||||||
return `<false/>`;
|
return `<false/>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ class NumberPolicy extends basePolicy_1.BasePolicy {
|
|||||||
renderADMLPresentationContents() {
|
renderADMLPresentationContents() {
|
||||||
return `<decimalTextBox refId="${this.name}" defaultValue="${this.defaultValue}">${this.name}</decimalTextBox>`;
|
return `<decimalTextBox refId="${this.name}" defaultValue="${this.defaultValue}">${this.name}</decimalTextBox>`;
|
||||||
}
|
}
|
||||||
|
renderJsonValue() {
|
||||||
|
return this.defaultValue;
|
||||||
|
}
|
||||||
renderProfileValue() {
|
renderProfileValue() {
|
||||||
return `<integer>${this.defaultValue}</integer>`;
|
return `<integer>${this.defaultValue}</integer>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ export class NumberPolicy extends BasePolicy {
|
|||||||
return `<decimalTextBox refId="${this.name}" defaultValue="${this.defaultValue}">${this.name}</decimalTextBox>`;
|
return `<decimalTextBox refId="${this.name}" defaultValue="${this.defaultValue}">${this.name}</decimalTextBox>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderJsonValue() {
|
||||||
|
return this.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
renderProfileValue() {
|
renderProfileValue() {
|
||||||
return `<integer>${this.defaultValue}</integer>`;
|
return `<integer>${this.defaultValue}</integer>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ class ObjectPolicy extends basePolicy_1.BasePolicy {
|
|||||||
renderADMLPresentationContents() {
|
renderADMLPresentationContents() {
|
||||||
return `<multiTextBox refId="${this.name}" />`;
|
return `<multiTextBox refId="${this.name}" />`;
|
||||||
}
|
}
|
||||||
|
renderJsonValue() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
renderProfileValue() {
|
renderProfileValue() {
|
||||||
return `<string></string>`;
|
return `<string></string>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ export class ObjectPolicy extends BasePolicy {
|
|||||||
return `<multiTextBox refId="${this.name}" />`;
|
return `<multiTextBox refId="${this.name}" />`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderJsonValue() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
renderProfileValue(): string {
|
renderProfileValue(): string {
|
||||||
return `<string></string>`;
|
return `<string></string>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,10 +203,18 @@ async function darwinMain(policies, translations) {
|
|||||||
await fs_1.promises.writeFile(path_1.default.join(languagePath, `${bundleIdentifier}.plist`), contents.replace(/\r?\n/g, '\n'));
|
await fs_1.promises.writeFile(path_1.default.join(languagePath, `${bundleIdentifier}.plist`), contents.replace(/\r?\n/g, '\n'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async function linuxMain(policies) {
|
||||||
|
const root = '.build/policies/linux';
|
||||||
|
const policyFileContents = JSON.stringify((0, render_1.renderJsonPolicies)(policies), undefined, 4);
|
||||||
|
await fs_1.promises.rm(root, { recursive: true, force: true });
|
||||||
|
await fs_1.promises.mkdir(root, { recursive: true });
|
||||||
|
const jsonPath = path_1.default.join(root, `policy.json`);
|
||||||
|
await fs_1.promises.writeFile(jsonPath, policyFileContents.replace(/\r?\n/g, '\n'));
|
||||||
|
}
|
||||||
async function main() {
|
async function main() {
|
||||||
const args = (0, minimist_1.default)(process.argv.slice(2));
|
const args = (0, minimist_1.default)(process.argv.slice(2));
|
||||||
if (args._.length !== 2) {
|
if (args._.length !== 2) {
|
||||||
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32>`);
|
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32|linux>`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const policyDataFile = args._[0];
|
const policyDataFile = args._[0];
|
||||||
@@ -218,8 +226,11 @@ async function main() {
|
|||||||
else if (platform === 'win32') {
|
else if (platform === 'win32') {
|
||||||
await windowsMain(policies, translations);
|
await windowsMain(policies, translations);
|
||||||
}
|
}
|
||||||
|
else if (platform === 'linux') {
|
||||||
|
await linuxMain(policies);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32>`);
|
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32|linux>`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { ObjectPolicy } from './objectPolicy';
|
|||||||
import { StringEnumPolicy } from './stringEnumPolicy';
|
import { StringEnumPolicy } from './stringEnumPolicy';
|
||||||
import { StringPolicy } from './stringPolicy';
|
import { StringPolicy } from './stringPolicy';
|
||||||
import { Version, LanguageTranslations, Policy, Translations, Languages, ProductJson } from './types';
|
import { Version, LanguageTranslations, Policy, Translations, Languages, ProductJson } from './types';
|
||||||
import { renderGP, renderMacOSPolicy } from './render';
|
import { renderGP, renderJsonPolicies, renderMacOSPolicy } from './render';
|
||||||
|
|
||||||
const product = require('../../../product.json') as ProductJson;
|
const product = require('../../../product.json') as ProductJson;
|
||||||
const packageJson = require('../../../package.json');
|
const packageJson = require('../../../package.json');
|
||||||
@@ -202,10 +202,21 @@ async function darwinMain(policies: Policy[], translations: Translations) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function linuxMain(policies: Policy[]) {
|
||||||
|
const root = '.build/policies/linux';
|
||||||
|
const policyFileContents = JSON.stringify(renderJsonPolicies(policies), undefined, 4);
|
||||||
|
|
||||||
|
await fs.rm(root, { recursive: true, force: true });
|
||||||
|
await fs.mkdir(root, { recursive: true });
|
||||||
|
|
||||||
|
const jsonPath = path.join(root, `policy.json`);
|
||||||
|
await fs.writeFile(jsonPath, policyFileContents.replace(/\r?\n/g, '\n'));
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const args = minimist(process.argv.slice(2));
|
const args = minimist(process.argv.slice(2));
|
||||||
if (args._.length !== 2) {
|
if (args._.length !== 2) {
|
||||||
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32>`);
|
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32|linux>`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +228,10 @@ async function main() {
|
|||||||
await darwinMain(policies, translations);
|
await darwinMain(policies, translations);
|
||||||
} else if (platform === 'win32') {
|
} else if (platform === 'win32') {
|
||||||
await windowsMain(policies, translations);
|
await windowsMain(policies, translations);
|
||||||
|
} else if (platform === 'linux') {
|
||||||
|
await linuxMain(policies);
|
||||||
} else {
|
} else {
|
||||||
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32>`);
|
console.error(`Usage: node build/lib/policies <policy-data-file> <darwin|win32|linux>`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ exports.renderADML = renderADML;
|
|||||||
exports.renderProfileManifest = renderProfileManifest;
|
exports.renderProfileManifest = renderProfileManifest;
|
||||||
exports.renderMacOSPolicy = renderMacOSPolicy;
|
exports.renderMacOSPolicy = renderMacOSPolicy;
|
||||||
exports.renderGP = renderGP;
|
exports.renderGP = renderGP;
|
||||||
|
exports.renderJsonPolicies = renderJsonPolicies;
|
||||||
function renderADMLString(prefix, moduleName, nlsString, translations) {
|
function renderADMLString(prefix, moduleName, nlsString, translations) {
|
||||||
let value;
|
let value;
|
||||||
if (translations) {
|
if (translations) {
|
||||||
@@ -268,4 +269,11 @@ function renderGP(product, policies, translations) {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function renderJsonPolicies(policies) {
|
||||||
|
const policyObject = {};
|
||||||
|
for (const policy of policies) {
|
||||||
|
policyObject[policy.name] = policy.renderJsonValue();
|
||||||
|
}
|
||||||
|
return policyObject;
|
||||||
|
}
|
||||||
//# sourceMappingURL=render.js.map
|
//# sourceMappingURL=render.js.map
|
||||||
@@ -293,3 +293,11 @@ export function renderGP(product: ProductJson, policies: Policy[], translations:
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function renderJsonPolicies(policies: Policy[]) {
|
||||||
|
const policyObject: { [key: string]: string | number | boolean | object | null } = {};
|
||||||
|
for (const policy of policies) {
|
||||||
|
policyObject[policy.name] = policy.renderJsonValue();
|
||||||
|
}
|
||||||
|
return policyObject;
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ class StringEnumPolicy extends basePolicy_1.BasePolicy {
|
|||||||
renderADMLPresentationContents() {
|
renderADMLPresentationContents() {
|
||||||
return `<dropdownList refId="${this.name}" />`;
|
return `<dropdownList refId="${this.name}" />`;
|
||||||
}
|
}
|
||||||
|
renderJsonValue() {
|
||||||
|
return this.enum_[0];
|
||||||
|
}
|
||||||
renderProfileValue() {
|
renderProfileValue() {
|
||||||
return `<string>${this.enum_[0]}</string>`;
|
return `<string>${this.enum_[0]}</string>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ export class StringEnumPolicy extends BasePolicy {
|
|||||||
return `<dropdownList refId="${this.name}" />`;
|
return `<dropdownList refId="${this.name}" />`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderJsonValue() {
|
||||||
|
return this.enum_[0];
|
||||||
|
}
|
||||||
|
|
||||||
renderProfileValue() {
|
renderProfileValue() {
|
||||||
return `<string>${this.enum_[0]}</string>`;
|
return `<string>${this.enum_[0]}</string>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ class StringPolicy extends basePolicy_1.BasePolicy {
|
|||||||
renderADMXElements() {
|
renderADMXElements() {
|
||||||
return [`<text id="${this.name}" valueName="${this.name}" required="true" />`];
|
return [`<text id="${this.name}" valueName="${this.name}" required="true" />`];
|
||||||
}
|
}
|
||||||
|
renderJsonValue() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
renderADMLPresentationContents() {
|
renderADMLPresentationContents() {
|
||||||
return `<textBox refId="${this.name}"><label>${this.name}:</label></textBox>`;
|
return `<textBox refId="${this.name}"><label>${this.name}:</label></textBox>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ export class StringPolicy extends BasePolicy {
|
|||||||
return [`<text id="${this.name}" valueName="${this.name}" required="true" />`];
|
return [`<text id="${this.name}" valueName="${this.name}" required="true" />`];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderJsonValue() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
renderADMLPresentationContents() {
|
renderADMLPresentationContents() {
|
||||||
return `<textBox refId="${this.name}"><label>${this.name}:</label></textBox>`;
|
return `<textBox refId="${this.name}"><label>${this.name}:</label></textBox>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export interface Policy {
|
|||||||
renderADMX(regKey: string): string[];
|
renderADMX(regKey: string): string[];
|
||||||
renderADMLStrings(translations?: LanguageTranslations): string[];
|
renderADMLStrings(translations?: LanguageTranslations): string[];
|
||||||
renderADMLPresentation(): string;
|
renderADMLPresentation(): string;
|
||||||
|
renderJsonValue(): string | number | boolean | object | null;
|
||||||
renderProfile(): string[];
|
renderProfile(): string[];
|
||||||
// https://github.com/ProfileManifests/ProfileManifests/wiki/Manifest-Format
|
// https://github.com/ProfileManifests/ProfileManifests/wiki/Manifest-Format
|
||||||
renderProfileManifest(translations?: LanguageTranslations): string;
|
renderProfileManifest(translations?: LanguageTranslations): string;
|
||||||
|
|||||||
@@ -79,6 +79,12 @@ suite('BooleanPolicy', () => {
|
|||||||
const presentation = policy.renderADMLPresentation();
|
const presentation = policy.renderADMLPresentation();
|
||||||
assert_1.default.strictEqual(presentation, '<presentation id="TestBooleanPolicy"><checkBox refId="TestBooleanPolicy">TestBooleanPolicy</checkBox></presentation>');
|
assert_1.default.strictEqual(presentation, '<presentation id="TestBooleanPolicy"><checkBox refId="TestBooleanPolicy">TestBooleanPolicy</checkBox></presentation>');
|
||||||
});
|
});
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = booleanPolicy_js_1.BooleanPolicy.from(mockCategory, mockPolicy);
|
||||||
|
assert_1.default.ok(policy);
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
assert_1.default.strictEqual(jsonValue, false);
|
||||||
|
});
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = booleanPolicy_js_1.BooleanPolicy.from(mockCategory, mockPolicy);
|
const policy = booleanPolicy_js_1.BooleanPolicy.from(mockCategory, mockPolicy);
|
||||||
assert_1.default.ok(policy);
|
assert_1.default.ok(policy);
|
||||||
|
|||||||
@@ -98,6 +98,16 @@ suite('BooleanPolicy', () => {
|
|||||||
assert.strictEqual(presentation, '<presentation id="TestBooleanPolicy"><checkBox refId="TestBooleanPolicy">TestBooleanPolicy</checkBox></presentation>');
|
assert.strictEqual(presentation, '<presentation id="TestBooleanPolicy"><checkBox refId="TestBooleanPolicy">TestBooleanPolicy</checkBox></presentation>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = BooleanPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
assert.ok(policy);
|
||||||
|
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
|
||||||
|
assert.strictEqual(jsonValue, false);
|
||||||
|
});
|
||||||
|
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = BooleanPolicy.from(mockCategory, mockPolicy);
|
const policy = BooleanPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"ChatAgentExtensionTools": false,
|
||||||
|
"ChatAgentMode": false,
|
||||||
|
"ChatMCP": "none",
|
||||||
|
"ChatPromptFiles": false,
|
||||||
|
"ChatToolsAutoApprove": false,
|
||||||
|
"McpGalleryServiceUrl": "",
|
||||||
|
"AllowedExtensions": "",
|
||||||
|
"ExtensionGalleryServiceUrl": "",
|
||||||
|
"ChatToolsTerminalEnableAutoApprove": false,
|
||||||
|
"EnableFeedback": false,
|
||||||
|
"TelemetryLevel": "all",
|
||||||
|
"UpdateMode": "none"
|
||||||
|
}
|
||||||
@@ -78,6 +78,12 @@ suite('NumberPolicy', () => {
|
|||||||
const presentation = policy.renderADMLPresentation();
|
const presentation = policy.renderADMLPresentation();
|
||||||
assert_1.default.strictEqual(presentation, '<presentation id="TestNumberPolicy"><decimalTextBox refId="TestNumberPolicy" defaultValue="42">TestNumberPolicy</decimalTextBox></presentation>');
|
assert_1.default.strictEqual(presentation, '<presentation id="TestNumberPolicy"><decimalTextBox refId="TestNumberPolicy" defaultValue="42">TestNumberPolicy</decimalTextBox></presentation>');
|
||||||
});
|
});
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = numberPolicy_js_1.NumberPolicy.from(mockCategory, mockPolicy);
|
||||||
|
assert_1.default.ok(policy);
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
assert_1.default.strictEqual(jsonValue, 42);
|
||||||
|
});
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = numberPolicy_js_1.NumberPolicy.from(mockCategory, mockPolicy);
|
const policy = numberPolicy_js_1.NumberPolicy.from(mockCategory, mockPolicy);
|
||||||
assert_1.default.ok(policy);
|
assert_1.default.ok(policy);
|
||||||
|
|||||||
@@ -97,6 +97,16 @@ suite('NumberPolicy', () => {
|
|||||||
assert.strictEqual(presentation, '<presentation id="TestNumberPolicy"><decimalTextBox refId="TestNumberPolicy" defaultValue="42">TestNumberPolicy</decimalTextBox></presentation>');
|
assert.strictEqual(presentation, '<presentation id="TestNumberPolicy"><decimalTextBox refId="TestNumberPolicy" defaultValue="42">TestNumberPolicy</decimalTextBox></presentation>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = NumberPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
assert.ok(policy);
|
||||||
|
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
|
||||||
|
assert.strictEqual(jsonValue, 42);
|
||||||
|
});
|
||||||
|
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = NumberPolicy.from(mockCategory, mockPolicy);
|
const policy = NumberPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ suite('ObjectPolicy', () => {
|
|||||||
const presentation = policy.renderADMLPresentation();
|
const presentation = policy.renderADMLPresentation();
|
||||||
assert_1.default.strictEqual(presentation, '<presentation id="TestObjectPolicy"><multiTextBox refId="TestObjectPolicy" /></presentation>');
|
assert_1.default.strictEqual(presentation, '<presentation id="TestObjectPolicy"><multiTextBox refId="TestObjectPolicy" /></presentation>');
|
||||||
});
|
});
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = objectPolicy_js_1.ObjectPolicy.from(mockCategory, mockPolicy);
|
||||||
|
assert_1.default.ok(policy);
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
assert_1.default.strictEqual(jsonValue, '');
|
||||||
|
});
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = objectPolicy_js_1.ObjectPolicy.from(mockCategory, mockPolicy);
|
const policy = objectPolicy_js_1.ObjectPolicy.from(mockCategory, mockPolicy);
|
||||||
assert_1.default.ok(policy);
|
assert_1.default.ok(policy);
|
||||||
|
|||||||
@@ -96,6 +96,16 @@ suite('ObjectPolicy', () => {
|
|||||||
assert.strictEqual(presentation, '<presentation id="TestObjectPolicy"><multiTextBox refId="TestObjectPolicy" /></presentation>');
|
assert.strictEqual(presentation, '<presentation id="TestObjectPolicy"><multiTextBox refId="TestObjectPolicy" /></presentation>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = ObjectPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
assert.ok(policy);
|
||||||
|
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
|
||||||
|
assert.strictEqual(jsonValue, '');
|
||||||
|
});
|
||||||
|
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = ObjectPolicy.from(mockCategory, mockPolicy);
|
const policy = ObjectPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
|||||||
@@ -451,5 +451,15 @@ suite('Policy E2E conversion', () => {
|
|||||||
// Compare the rendered ADML with the fixture
|
// Compare the rendered ADML with the fixture
|
||||||
assert_1.default.strictEqual(frFrAdml.contents, expectedContent, 'Windows fr-fr ADML should match the fixture');
|
assert_1.default.strictEqual(frFrAdml.contents, expectedContent, 'Windows fr-fr ADML should match the fixture');
|
||||||
});
|
});
|
||||||
|
test('should render Linux policy JSON from policies list', async () => {
|
||||||
|
const parsedPolicies = parsePolicies(policies);
|
||||||
|
const result = (0, render_1.renderJsonPolicies)(parsedPolicies);
|
||||||
|
// Load the expected fixture file
|
||||||
|
const fixturePath = path_1.default.join(__dirname, 'fixtures', 'policies', 'linux', 'policy.json');
|
||||||
|
const expectedContent = await fs_1.promises.readFile(fixturePath, 'utf-8');
|
||||||
|
const expectedJson = JSON.parse(expectedContent);
|
||||||
|
// Compare the rendered JSON with the fixture
|
||||||
|
assert_1.default.deepStrictEqual(result, expectedJson, 'Linux policy JSON should match the fixture');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=policyConversion.test.js.map
|
//# sourceMappingURL=policyConversion.test.js.map
|
||||||
@@ -13,7 +13,7 @@ import { ObjectPolicy } from '../policies/objectPolicy';
|
|||||||
import { StringEnumPolicy } from '../policies/stringEnumPolicy';
|
import { StringEnumPolicy } from '../policies/stringEnumPolicy';
|
||||||
import { StringPolicy } from '../policies/stringPolicy';
|
import { StringPolicy } from '../policies/stringPolicy';
|
||||||
import { Policy, ProductJson } from '../policies/types';
|
import { Policy, ProductJson } from '../policies/types';
|
||||||
import { renderGP, renderMacOSPolicy } from '../policies/render';
|
import { renderGP, renderMacOSPolicy, renderJsonPolicies } from '../policies/render';
|
||||||
|
|
||||||
const PolicyTypes = [
|
const PolicyTypes = [
|
||||||
BooleanPolicy,
|
BooleanPolicy,
|
||||||
@@ -492,4 +492,17 @@ suite('Policy E2E conversion', () => {
|
|||||||
assert.strictEqual(frFrAdml.contents, expectedContent, 'Windows fr-fr ADML should match the fixture');
|
assert.strictEqual(frFrAdml.contents, expectedContent, 'Windows fr-fr ADML should match the fixture');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render Linux policy JSON from policies list', async () => {
|
||||||
|
const parsedPolicies = parsePolicies(policies);
|
||||||
|
const result = renderJsonPolicies(parsedPolicies);
|
||||||
|
|
||||||
|
// Load the expected fixture file
|
||||||
|
const fixturePath = path.join(__dirname, 'fixtures', 'policies', 'linux', 'policy.json');
|
||||||
|
const expectedContent = await fs.readFile(fixturePath, 'utf-8');
|
||||||
|
const expectedJson = JSON.parse(expectedContent);
|
||||||
|
|
||||||
|
// Compare the rendered JSON with the fixture
|
||||||
|
assert.deepStrictEqual(result, expectedJson, 'Linux policy JSON should match the fixture');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ suite('Render Functions', () => {
|
|||||||
renderADMLStrings: () => ['<string id="TestPolicy">Test Policy</string>'],
|
renderADMLStrings: () => ['<string id="TestPolicy">Test Policy</string>'],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
||||||
renderProfile: () => ['<key>TestPolicy</key>', '<true/>'],
|
renderProfile: () => ['<key>TestPolicy</key>', '<true/>'],
|
||||||
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy</string></dict>'
|
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy</string></dict>',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
test('should render ADMX with correct XML structure', () => {
|
test('should render ADMX with correct XML structure', () => {
|
||||||
const result = (0, render_js_1.renderADMX)('VSCode', ['1.85'], [mockCategory], [mockPolicy]);
|
const result = (0, render_js_1.renderADMX)('VSCode', ['1.85'], [mockCategory], [mockPolicy]);
|
||||||
@@ -167,7 +168,8 @@ suite('Render Functions', () => {
|
|||||||
renderADMLStrings: () => ['<string id="TestPolicy2">Test Policy 2</string>'],
|
renderADMLStrings: () => ['<string id="TestPolicy2">Test Policy 2</string>'],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy2"/>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy2"/>',
|
||||||
renderProfile: () => ['<key>TestPolicy2</key>', '<string/>'],
|
renderProfile: () => ['<key>TestPolicy2</key>', '<string/>'],
|
||||||
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy2</string></dict>'
|
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy2</string></dict>',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
const result = (0, render_js_1.renderADMX)('VSCode', ['1.0'], [mockCategory], [mockPolicy, policy2]);
|
const result = (0, render_js_1.renderADMX)('VSCode', ['1.0'], [mockCategory], [mockPolicy, policy2]);
|
||||||
assert_1.default.ok(result.includes('TestPolicy'));
|
assert_1.default.ok(result.includes('TestPolicy'));
|
||||||
@@ -190,7 +192,8 @@ suite('Render Functions', () => {
|
|||||||
],
|
],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy"><textBox refId="TestPolicy"/></presentation>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy"><textBox refId="TestPolicy"/></presentation>',
|
||||||
renderProfile: () => [],
|
renderProfile: () => [],
|
||||||
renderProfileManifest: () => ''
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
test('should render ADML with correct XML structure', () => {
|
test('should render ADML with correct XML structure', () => {
|
||||||
const result = (0, render_js_1.renderADML)('VS Code', ['1.85'], [mockCategory], [mockPolicy]);
|
const result = (0, render_js_1.renderADML)('VS Code', ['1.85'], [mockCategory], [mockPolicy]);
|
||||||
@@ -258,7 +261,8 @@ suite('Render Functions', () => {
|
|||||||
<string>TestPolicy</string>
|
<string>TestPolicy</string>
|
||||||
<key>pfm_description</key>
|
<key>pfm_description</key>
|
||||||
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
||||||
</dict>`
|
</dict>`,
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
test('should render profile manifest with correct XML structure', () => {
|
test('should render profile manifest with correct XML structure', () => {
|
||||||
const result = (0, render_js_1.renderProfileManifest)('VS Code', 'com.microsoft.vscode', ['1.0'], [mockCategory], [mockPolicy]);
|
const result = (0, render_js_1.renderProfileManifest)('VS Code', 'com.microsoft.vscode', ['1.0'], [mockCategory], [mockPolicy]);
|
||||||
@@ -364,7 +368,8 @@ suite('Render Functions', () => {
|
|||||||
<string>TestPolicy</string>
|
<string>TestPolicy</string>
|
||||||
<key>pfm_description</key>
|
<key>pfm_description</key>
|
||||||
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
||||||
</dict>`
|
</dict>`,
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
test('should render complete macOS policy profile', () => {
|
test('should render complete macOS policy profile', () => {
|
||||||
const product = {
|
const product = {
|
||||||
@@ -525,7 +530,8 @@ suite('Render Functions', () => {
|
|||||||
],
|
],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
||||||
renderProfile: () => [],
|
renderProfile: () => [],
|
||||||
renderProfileManifest: () => ''
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
test('should render complete GP with ADMX and ADML', () => {
|
test('should render complete GP with ADMX and ADML', () => {
|
||||||
const product = {
|
const product = {
|
||||||
@@ -679,5 +685,171 @@ suite('Render Functions', () => {
|
|||||||
assert_1.default.ok(Array.isArray(result.adml));
|
assert_1.default.ok(Array.isArray(result.adml));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
suite('renderJsonPolicies', () => {
|
||||||
|
const mockCategory = {
|
||||||
|
moduleName: 'testModule',
|
||||||
|
name: { value: 'Test Category', nlsKey: 'test.category' }
|
||||||
|
};
|
||||||
|
test('should render boolean policy JSON value', () => {
|
||||||
|
const booleanPolicy = {
|
||||||
|
name: 'BooleanPolicy',
|
||||||
|
type: types_js_1.PolicyType.Boolean,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => false
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([booleanPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, { BooleanPolicy: false });
|
||||||
|
});
|
||||||
|
test('should render number policy JSON value', () => {
|
||||||
|
const numberPolicy = {
|
||||||
|
name: 'NumberPolicy',
|
||||||
|
type: types_js_1.PolicyType.Number,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 42
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([numberPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, { NumberPolicy: 42 });
|
||||||
|
});
|
||||||
|
test('should render string policy JSON value', () => {
|
||||||
|
const stringPolicy = {
|
||||||
|
name: 'StringPolicy',
|
||||||
|
type: types_js_1.PolicyType.String,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => ''
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([stringPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, { StringPolicy: '' });
|
||||||
|
});
|
||||||
|
test('should render string enum policy JSON value', () => {
|
||||||
|
const stringEnumPolicy = {
|
||||||
|
name: 'StringEnumPolicy',
|
||||||
|
type: types_js_1.PolicyType.StringEnum,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 'auto'
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([stringEnumPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, { StringEnumPolicy: 'auto' });
|
||||||
|
});
|
||||||
|
test('should render object policy JSON value', () => {
|
||||||
|
const objectPolicy = {
|
||||||
|
name: 'ObjectPolicy',
|
||||||
|
type: types_js_1.PolicyType.Object,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => ''
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([objectPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, { ObjectPolicy: '' });
|
||||||
|
});
|
||||||
|
test('should render multiple policies', () => {
|
||||||
|
const booleanPolicy = {
|
||||||
|
name: 'BooleanPolicy',
|
||||||
|
type: types_js_1.PolicyType.Boolean,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => true
|
||||||
|
};
|
||||||
|
const numberPolicy = {
|
||||||
|
name: 'NumberPolicy',
|
||||||
|
type: types_js_1.PolicyType.Number,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 100
|
||||||
|
};
|
||||||
|
const stringPolicy = {
|
||||||
|
name: 'StringPolicy',
|
||||||
|
type: types_js_1.PolicyType.String,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 'test-value'
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([booleanPolicy, numberPolicy, stringPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, {
|
||||||
|
BooleanPolicy: true,
|
||||||
|
NumberPolicy: 100,
|
||||||
|
StringPolicy: 'test-value'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('should handle empty policies array', () => {
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([]);
|
||||||
|
assert_1.default.deepStrictEqual(result, {});
|
||||||
|
});
|
||||||
|
test('should handle null JSON value', () => {
|
||||||
|
const nullPolicy = {
|
||||||
|
name: 'NullPolicy',
|
||||||
|
type: types_js_1.PolicyType.String,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => null
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([nullPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, { NullPolicy: null });
|
||||||
|
});
|
||||||
|
test('should handle object JSON value', () => {
|
||||||
|
const objectPolicy = {
|
||||||
|
name: 'ComplexObjectPolicy',
|
||||||
|
type: types_js_1.PolicyType.Object,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => ({ nested: { value: 123 } })
|
||||||
|
};
|
||||||
|
const result = (0, render_js_1.renderJsonPolicies)([objectPolicy]);
|
||||||
|
assert_1.default.deepStrictEqual(result, { ComplexObjectPolicy: { nested: { value: 123 } } });
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=render.test.js.map
|
//# sourceMappingURL=render.test.js.map
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import { renderADMLString, renderProfileString, renderADMX, renderADML, renderProfileManifest, renderMacOSPolicy, renderGP } from '../policies/render.js';
|
import { renderADMLString, renderProfileString, renderADMX, renderADML, renderProfileManifest, renderMacOSPolicy, renderGP, renderJsonPolicies } from '../policies/render.js';
|
||||||
import { NlsString, LanguageTranslations, Category, Policy, PolicyType } from '../policies/types.js';
|
import { NlsString, LanguageTranslations, Category, Policy, PolicyType } from '../policies/types.js';
|
||||||
|
|
||||||
suite('Render Functions', () => {
|
suite('Render Functions', () => {
|
||||||
@@ -136,7 +136,8 @@ suite('Render Functions', () => {
|
|||||||
renderADMLStrings: () => ['<string id="TestPolicy">Test Policy</string>'],
|
renderADMLStrings: () => ['<string id="TestPolicy">Test Policy</string>'],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
||||||
renderProfile: () => ['<key>TestPolicy</key>', '<true/>'],
|
renderProfile: () => ['<key>TestPolicy</key>', '<true/>'],
|
||||||
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy</string></dict>'
|
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy</string></dict>',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should render ADMX with correct XML structure', () => {
|
test('should render ADMX with correct XML structure', () => {
|
||||||
@@ -210,7 +211,8 @@ suite('Render Functions', () => {
|
|||||||
renderADMLStrings: () => ['<string id="TestPolicy2">Test Policy 2</string>'],
|
renderADMLStrings: () => ['<string id="TestPolicy2">Test Policy 2</string>'],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy2"/>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy2"/>',
|
||||||
renderProfile: () => ['<key>TestPolicy2</key>', '<string/>'],
|
renderProfile: () => ['<key>TestPolicy2</key>', '<string/>'],
|
||||||
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy2</string></dict>'
|
renderProfileManifest: () => '<dict><key>pfm_name</key><string>TestPolicy2</string></dict>',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
const result = renderADMX('VSCode', ['1.0'], [mockCategory], [mockPolicy, policy2]);
|
const result = renderADMX('VSCode', ['1.0'], [mockCategory], [mockPolicy, policy2]);
|
||||||
|
|
||||||
@@ -237,7 +239,8 @@ suite('Render Functions', () => {
|
|||||||
],
|
],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy"><textBox refId="TestPolicy"/></presentation>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy"><textBox refId="TestPolicy"/></presentation>',
|
||||||
renderProfile: () => [],
|
renderProfile: () => [],
|
||||||
renderProfileManifest: () => ''
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should render ADML with correct XML structure', () => {
|
test('should render ADML with correct XML structure', () => {
|
||||||
@@ -326,7 +329,8 @@ suite('Render Functions', () => {
|
|||||||
<string>TestPolicy</string>
|
<string>TestPolicy</string>
|
||||||
<key>pfm_description</key>
|
<key>pfm_description</key>
|
||||||
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
||||||
</dict>`
|
</dict>`,
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should render profile manifest with correct XML structure', () => {
|
test('should render profile manifest with correct XML structure', () => {
|
||||||
@@ -463,7 +467,8 @@ suite('Render Functions', () => {
|
|||||||
<string>TestPolicy</string>
|
<string>TestPolicy</string>
|
||||||
<key>pfm_description</key>
|
<key>pfm_description</key>
|
||||||
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
<string>${translations?.['testModule']?.['test.desc'] || 'Default Desc'}</string>
|
||||||
</dict>`
|
</dict>`,
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should render complete macOS policy profile', () => {
|
test('should render complete macOS policy profile', () => {
|
||||||
@@ -645,7 +650,8 @@ suite('Render Functions', () => {
|
|||||||
],
|
],
|
||||||
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
renderADMLPresentation: () => '<presentation id="TestPolicy"/>',
|
||||||
renderProfile: () => [],
|
renderProfile: () => [],
|
||||||
renderProfileManifest: () => ''
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => null
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should render complete GP with ADMX and ADML', () => {
|
test('should render complete GP with ADMX and ADML', () => {
|
||||||
@@ -824,4 +830,200 @@ suite('Render Functions', () => {
|
|||||||
assert.ok(Array.isArray(result.adml));
|
assert.ok(Array.isArray(result.adml));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
suite('renderJsonPolicies', () => {
|
||||||
|
|
||||||
|
const mockCategory: Category = {
|
||||||
|
moduleName: 'testModule',
|
||||||
|
name: { value: 'Test Category', nlsKey: 'test.category' }
|
||||||
|
};
|
||||||
|
|
||||||
|
test('should render boolean policy JSON value', () => {
|
||||||
|
const booleanPolicy: Policy = {
|
||||||
|
name: 'BooleanPolicy',
|
||||||
|
type: PolicyType.Boolean,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => false
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([booleanPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, { BooleanPolicy: false });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render number policy JSON value', () => {
|
||||||
|
const numberPolicy: Policy = {
|
||||||
|
name: 'NumberPolicy',
|
||||||
|
type: PolicyType.Number,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 42
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([numberPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, { NumberPolicy: 42 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render string policy JSON value', () => {
|
||||||
|
const stringPolicy: Policy = {
|
||||||
|
name: 'StringPolicy',
|
||||||
|
type: PolicyType.String,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => ''
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([stringPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, { StringPolicy: '' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render string enum policy JSON value', () => {
|
||||||
|
const stringEnumPolicy: Policy = {
|
||||||
|
name: 'StringEnumPolicy',
|
||||||
|
type: PolicyType.StringEnum,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 'auto'
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([stringEnumPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, { StringEnumPolicy: 'auto' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render object policy JSON value', () => {
|
||||||
|
const objectPolicy: Policy = {
|
||||||
|
name: 'ObjectPolicy',
|
||||||
|
type: PolicyType.Object,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => ''
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([objectPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, { ObjectPolicy: '' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render multiple policies', () => {
|
||||||
|
const booleanPolicy: Policy = {
|
||||||
|
name: 'BooleanPolicy',
|
||||||
|
type: PolicyType.Boolean,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => true
|
||||||
|
};
|
||||||
|
|
||||||
|
const numberPolicy: Policy = {
|
||||||
|
name: 'NumberPolicy',
|
||||||
|
type: PolicyType.Number,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 100
|
||||||
|
};
|
||||||
|
|
||||||
|
const stringPolicy: Policy = {
|
||||||
|
name: 'StringPolicy',
|
||||||
|
type: PolicyType.String,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => 'test-value'
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([booleanPolicy, numberPolicy, stringPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, {
|
||||||
|
BooleanPolicy: true,
|
||||||
|
NumberPolicy: 100,
|
||||||
|
StringPolicy: 'test-value'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should handle empty policies array', () => {
|
||||||
|
const result = renderJsonPolicies([]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, {});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should handle null JSON value', () => {
|
||||||
|
const nullPolicy: Policy = {
|
||||||
|
name: 'NullPolicy',
|
||||||
|
type: PolicyType.String,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => null
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([nullPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, { NullPolicy: null });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should handle object JSON value', () => {
|
||||||
|
const objectPolicy: Policy = {
|
||||||
|
name: 'ComplexObjectPolicy',
|
||||||
|
type: PolicyType.Object,
|
||||||
|
category: mockCategory,
|
||||||
|
minimumVersion: '1.0',
|
||||||
|
renderADMX: () => [],
|
||||||
|
renderADMLStrings: () => [],
|
||||||
|
renderADMLPresentation: () => '',
|
||||||
|
renderProfile: () => [],
|
||||||
|
renderProfileManifest: () => '',
|
||||||
|
renderJsonValue: () => ({ nested: { value: 123 } })
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = renderJsonPolicies([objectPolicy]);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(result, { ComplexObjectPolicy: { nested: { value: 123 } } });
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,6 +95,12 @@ suite('StringEnumPolicy', () => {
|
|||||||
const presentation = policy.renderADMLPresentation();
|
const presentation = policy.renderADMLPresentation();
|
||||||
assert_1.default.strictEqual(presentation, '<presentation id="TestStringEnumPolicy"><dropdownList refId="TestStringEnumPolicy" /></presentation>');
|
assert_1.default.strictEqual(presentation, '<presentation id="TestStringEnumPolicy"><dropdownList refId="TestStringEnumPolicy" /></presentation>');
|
||||||
});
|
});
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy);
|
||||||
|
assert_1.default.ok(policy);
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
assert_1.default.strictEqual(jsonValue, 'auto');
|
||||||
|
});
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy);
|
const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy);
|
||||||
assert_1.default.ok(policy);
|
assert_1.default.ok(policy);
|
||||||
|
|||||||
@@ -114,6 +114,16 @@ suite('StringEnumPolicy', () => {
|
|||||||
assert.strictEqual(presentation, '<presentation id="TestStringEnumPolicy"><dropdownList refId="TestStringEnumPolicy" /></presentation>');
|
assert.strictEqual(presentation, '<presentation id="TestStringEnumPolicy"><dropdownList refId="TestStringEnumPolicy" /></presentation>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = StringEnumPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
assert.ok(policy);
|
||||||
|
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
|
||||||
|
assert.strictEqual(jsonValue, 'auto');
|
||||||
|
});
|
||||||
|
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = StringEnumPolicy.from(mockCategory, mockPolicy);
|
const policy = StringEnumPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ suite('StringPolicy', () => {
|
|||||||
const presentation = policy.renderADMLPresentation();
|
const presentation = policy.renderADMLPresentation();
|
||||||
assert_1.default.strictEqual(presentation, '<presentation id="TestStringPolicy"><textBox refId="TestStringPolicy"><label>TestStringPolicy:</label></textBox></presentation>');
|
assert_1.default.strictEqual(presentation, '<presentation id="TestStringPolicy"><textBox refId="TestStringPolicy"><label>TestStringPolicy:</label></textBox></presentation>');
|
||||||
});
|
});
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = stringPolicy_js_1.StringPolicy.from(mockCategory, mockPolicy);
|
||||||
|
assert_1.default.ok(policy);
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
assert_1.default.strictEqual(jsonValue, '');
|
||||||
|
});
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = stringPolicy_js_1.StringPolicy.from(mockCategory, mockPolicy);
|
const policy = stringPolicy_js_1.StringPolicy.from(mockCategory, mockPolicy);
|
||||||
assert_1.default.ok(policy);
|
assert_1.default.ok(policy);
|
||||||
|
|||||||
@@ -97,6 +97,16 @@ suite('StringPolicy', () => {
|
|||||||
assert.strictEqual(presentation, '<presentation id="TestStringPolicy"><textBox refId="TestStringPolicy"><label>TestStringPolicy:</label></textBox></presentation>');
|
assert.strictEqual(presentation, '<presentation id="TestStringPolicy"><textBox refId="TestStringPolicy"><label>TestStringPolicy:</label></textBox></presentation>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render JSON value correctly', () => {
|
||||||
|
const policy = StringPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
assert.ok(policy);
|
||||||
|
|
||||||
|
const jsonValue = policy.renderJsonValue();
|
||||||
|
|
||||||
|
assert.strictEqual(jsonValue, '');
|
||||||
|
});
|
||||||
|
|
||||||
test('should render profile value correctly', () => {
|
test('should render profile value correctly', () => {
|
||||||
const policy = StringPolicy.from(mockCategory, mockPolicy);
|
const policy = StringPolicy.from(mockCategory, mockPolicy);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,11 @@
|
|||||||
import { localize } from '../../nls.js';
|
import { localize } from '../../nls.js';
|
||||||
import { IDefaultAccount } from './defaultAccount.js';
|
import { IDefaultAccount } from './defaultAccount.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System-wide policy file path for Linux systems.
|
||||||
|
*/
|
||||||
|
export const LINUX_SYSTEM_POLICY_FILE_PATH = '/etc/vscode/policy.json';
|
||||||
|
|
||||||
export type PolicyName = string;
|
export type PolicyName = string;
|
||||||
export type LocalizedValue = {
|
export type LocalizedValue = {
|
||||||
key: string;
|
key: string;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { getPathLabel } from '../../base/common/labels.js';
|
|||||||
import { Schemas } from '../../base/common/network.js';
|
import { Schemas } from '../../base/common/network.js';
|
||||||
import { basename, resolve } from '../../base/common/path.js';
|
import { basename, resolve } from '../../base/common/path.js';
|
||||||
import { mark } from '../../base/common/performance.js';
|
import { mark } from '../../base/common/performance.js';
|
||||||
import { IProcessEnvironment, isMacintosh, isWindows, OS } from '../../base/common/platform.js';
|
import { IProcessEnvironment, isLinux, isMacintosh, isWindows, OS } from '../../base/common/platform.js';
|
||||||
import { cwd } from '../../base/common/process.js';
|
import { cwd } from '../../base/common/process.js';
|
||||||
import { rtrim, trim } from '../../base/common/strings.js';
|
import { rtrim, trim } from '../../base/common/strings.js';
|
||||||
import { Promises as FSPromises } from '../../base/node/pfs.js';
|
import { Promises as FSPromises } from '../../base/node/pfs.js';
|
||||||
@@ -73,6 +73,7 @@ import { SaveStrategy, StateService } from '../../platform/state/node/stateServi
|
|||||||
import { FileUserDataProvider } from '../../platform/userData/common/fileUserDataProvider.js';
|
import { FileUserDataProvider } from '../../platform/userData/common/fileUserDataProvider.js';
|
||||||
import { addUNCHostToAllowlist, getUNCHost } from '../../base/node/unc.js';
|
import { addUNCHostToAllowlist, getUNCHost } from '../../base/node/unc.js';
|
||||||
import { ThemeMainService } from '../../platform/theme/electron-main/themeMainServiceImpl.js';
|
import { ThemeMainService } from '../../platform/theme/electron-main/themeMainServiceImpl.js';
|
||||||
|
import { LINUX_SYSTEM_POLICY_FILE_PATH } from '../../base/common/policy.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main VS Code entry point.
|
* The main VS Code entry point.
|
||||||
@@ -204,6 +205,8 @@ class CodeMain {
|
|||||||
policyService = disposables.add(new NativePolicyService(logService, productService.win32RegValueName));
|
policyService = disposables.add(new NativePolicyService(logService, productService.win32RegValueName));
|
||||||
} else if (isMacintosh && productService.darwinBundleIdentifier) {
|
} else if (isMacintosh && productService.darwinBundleIdentifier) {
|
||||||
policyService = disposables.add(new NativePolicyService(logService, productService.darwinBundleIdentifier));
|
policyService = disposables.add(new NativePolicyService(logService, productService.darwinBundleIdentifier));
|
||||||
|
} else if (isLinux) {
|
||||||
|
policyService = disposables.add(new FilePolicyService(URI.file(LINUX_SYSTEM_POLICY_FILE_PATH), fileService, logService));
|
||||||
} else if (environmentMainService.policyFile) {
|
} else if (environmentMainService.policyFile) {
|
||||||
policyService = disposables.add(new FilePolicyService(environmentMainService.policyFile, fileService, logService));
|
policyService = disposables.add(new FilePolicyService(environmentMainService.policyFile, fileService, logService));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { isSigPipeError, onUnexpectedError, setUnexpectedErrorHandler } from '..
|
|||||||
import { Disposable } from '../../base/common/lifecycle.js';
|
import { Disposable } from '../../base/common/lifecycle.js';
|
||||||
import { Schemas } from '../../base/common/network.js';
|
import { Schemas } from '../../base/common/network.js';
|
||||||
import { isAbsolute, join } from '../../base/common/path.js';
|
import { isAbsolute, join } from '../../base/common/path.js';
|
||||||
import { isWindows, isMacintosh } from '../../base/common/platform.js';
|
import { isWindows, isMacintosh, isLinux } from '../../base/common/platform.js';
|
||||||
import { cwd } from '../../base/common/process.js';
|
import { cwd } from '../../base/common/process.js';
|
||||||
import { URI } from '../../base/common/uri.js';
|
import { URI } from '../../base/common/uri.js';
|
||||||
import { IConfigurationService } from '../../platform/configuration/common/configuration.js';
|
import { IConfigurationService } from '../../platform/configuration/common/configuration.js';
|
||||||
@@ -76,6 +76,7 @@ import { McpGalleryService } from '../../platform/mcp/common/mcpGalleryService.j
|
|||||||
import { AllowedMcpServersService } from '../../platform/mcp/common/allowedMcpServersService.js';
|
import { AllowedMcpServersService } from '../../platform/mcp/common/allowedMcpServersService.js';
|
||||||
import { IMcpGalleryManifestService } from '../../platform/mcp/common/mcpGalleryManifest.js';
|
import { IMcpGalleryManifestService } from '../../platform/mcp/common/mcpGalleryManifest.js';
|
||||||
import { McpGalleryManifestService } from '../../platform/mcp/common/mcpGalleryManifestService.js';
|
import { McpGalleryManifestService } from '../../platform/mcp/common/mcpGalleryManifestService.js';
|
||||||
|
import { LINUX_SYSTEM_POLICY_FILE_PATH } from '../../base/common/policy.js';
|
||||||
|
|
||||||
class CliMain extends Disposable {
|
class CliMain extends Disposable {
|
||||||
|
|
||||||
@@ -182,6 +183,8 @@ class CliMain extends Disposable {
|
|||||||
policyService = this._register(new NativePolicyService(logService, productService.win32RegValueName));
|
policyService = this._register(new NativePolicyService(logService, productService.win32RegValueName));
|
||||||
} else if (isMacintosh && productService.darwinBundleIdentifier) {
|
} else if (isMacintosh && productService.darwinBundleIdentifier) {
|
||||||
policyService = this._register(new NativePolicyService(logService, productService.darwinBundleIdentifier));
|
policyService = this._register(new NativePolicyService(logService, productService.darwinBundleIdentifier));
|
||||||
|
} else if (isLinux) {
|
||||||
|
policyService = this._register(new FilePolicyService(URI.file(LINUX_SYSTEM_POLICY_FILE_PATH), fileService, logService));
|
||||||
} else if (environmentService.policyFile) {
|
} else if (environmentService.policyFile) {
|
||||||
policyService = this._register(new FilePolicyService(environmentService.policyFile, fileService, logService));
|
policyService = this._register(new FilePolicyService(environmentService.policyFile, fileService, logService));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user