mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-23 01:16:24 -06:00
SDA-4714 - Add missing latestAutoUpdateChannelEnabled into plist file (#2221)
This commit is contained in:
parent
5488ef8452
commit
5c76460707
@ -118,6 +118,7 @@ if [ "$EUID" -ne 0 ]; then
|
||||
defaults write "$plistFilePath" userDataPath -string ""
|
||||
defaults write "$plistFilePath" chromeFlags -string ""
|
||||
defaults write "$plistFilePath" betaAutoUpdateChannelEnabled -bool true
|
||||
defaults write "$plistFilePath" latestAutoUpdateChannelEnabled -bool true
|
||||
defaults write "$plistFilePath" installVariant -string "$uuid"
|
||||
else
|
||||
sudo -u "$userName" defaults write "$plistFilePath" url -string "$pod_url"
|
||||
@ -161,6 +162,7 @@ else
|
||||
sudo -u "$userName" defaults write "$plistFilePath" userDataPath -string ""
|
||||
sudo -u "$userName" defaults write "$plistFilePath" chromeFlags -string ""
|
||||
sudo -u "$userName" defaults write "$plistFilePath" betaAutoUpdateChannelEnabled -bool true
|
||||
sudo -u "$userName" defaults write "$plistFilePath" latestAutoUpdateChannelEnabled -bool true
|
||||
sudo -u "$userName" defaults write "$plistFilePath" installVariant -string "$uuid"
|
||||
fi
|
||||
|
||||
|
65
spec/postinstall.spec.ts
Normal file
65
spec/postinstall.spec.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import * as fs from 'fs';
|
||||
|
||||
const extractUserDefaults = (filePath: string) => {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
const fieldRegex =
|
||||
/^\s*sudo -u "\$userName"\s+defaults write "\$plistFilePath"\s+([a-zA-Z_][a-zA-Z0-9_]*)/gm;
|
||||
return Array.from(content.matchAll(fieldRegex), (match) => match[1]);
|
||||
};
|
||||
|
||||
const extractSystemDefaults = (filePath: string) => {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
const fieldRegex =
|
||||
/^\s*defaults write "\$plistFilePath"\s+([a-zA-Z_][a-zA-Z0-9_]*)/gm;
|
||||
return Array.from(content.matchAll(fieldRegex), (match) => match[1]);
|
||||
};
|
||||
|
||||
const isArraySubset = (array1: string[], array2: string[]): boolean => {
|
||||
return array2.every((item) => array1.includes(item));
|
||||
};
|
||||
|
||||
const removeFields = (array: string[], stringsToRemove: string[]): string[] => {
|
||||
return array.filter((item) => !stringsToRemove.includes(item));
|
||||
};
|
||||
|
||||
describe('Shell Script Field Validation', () => {
|
||||
it('should contain all the user defaults fields from JSON', async () => {
|
||||
const jsonFilePath = './config/Symphony.config';
|
||||
const scriptFilePath = './installer/mac/postinstall.sh';
|
||||
|
||||
// Read Symphony config JSON file
|
||||
const jsonContent = JSON.parse(fs.readFileSync(jsonFilePath, 'utf-8'));
|
||||
const fields = Object.keys(jsonContent) as [];
|
||||
const filteredFields = removeFields(fields, [
|
||||
'notificationSettings',
|
||||
'customFlags',
|
||||
'permissions',
|
||||
]);
|
||||
|
||||
// Read fields from post install script file
|
||||
const scriptFields = extractUserDefaults(scriptFilePath);
|
||||
scriptFields.splice(scriptFields.indexOf('ApplicationName'), 1);
|
||||
|
||||
expect(isArraySubset(scriptFields, filteredFields)).toBe(true);
|
||||
});
|
||||
|
||||
it('should contain all the system defaults fields from JSON', async () => {
|
||||
const jsonFilePath = './config/Symphony.config';
|
||||
const scriptFilePath = './installer/mac/postinstall.sh';
|
||||
|
||||
// Read Symphony config JSON file
|
||||
const jsonContent = JSON.parse(fs.readFileSync(jsonFilePath, 'utf-8'));
|
||||
const fields = Object.keys(jsonContent) as [];
|
||||
const filteredFields = removeFields(fields, [
|
||||
'notificationSettings',
|
||||
'customFlags',
|
||||
'permissions',
|
||||
]);
|
||||
|
||||
// Read fields from post install script file
|
||||
const scriptFields = extractSystemDefaults(scriptFilePath);
|
||||
scriptFields.splice(scriptFields.indexOf('ApplicationName'), 1);
|
||||
|
||||
expect(isArraySubset(scriptFields, filteredFields)).toBe(true);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user