-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 4.5.1-7.16] Fix outdated year in PDF report footer (#5767)
Fix outdated year in PDF report footer (#5766) * Fix year in PDF footer * Modify changelog * Change tests to match the new value * Change md5 in reporting test * Change md5 in reporting test * Revert accidental change * Revert accidental change * Fix md5 in test * Change md5 in test * Change md5 in test (cherry picked from commit a997dcf) Co-authored-by: Nicolas Agustin Guevara Pihen <42900763+Tostti@users.noreply.github.com>
- Loading branch information
1 parent
40073cd
commit 683c1c7
Showing
4 changed files
with
159 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,67 @@ | ||
import { | ||
formatLabelValuePair, | ||
formatSettingValueToFile, | ||
getCustomizationSetting | ||
} from "./settings"; | ||
formatLabelValuePair, | ||
formatSettingValueToFile, | ||
getCustomizationSetting, | ||
} from './settings'; | ||
|
||
describe('[settings] Methods', () => { | ||
describe('formatLabelValuePair: Format the label-value pairs used to display the allowed values', () => { | ||
it.each` | ||
label | value | expected | ||
${'TestLabel'} | ${true} | ${'true (TestLabel)'} | ||
${'true'} | ${true} | ${'true'} | ||
`( | ||
`label: $label | value: $value | expected: $expected`, | ||
({ label, expected, value }) => { | ||
expect(formatLabelValuePair(label, value)).toBe(expected); | ||
}, | ||
); | ||
}); | ||
|
||
describe('formatLabelValuePair: Format the label-value pairs used to display the allowed values', () => { | ||
it.each` | ||
label | value | expected | ||
${'TestLabel'} | ${true} | ${'true (TestLabel)'} | ||
${'true'} | ${true} | ${'true'} | ||
`(`label: $label | value: $value | expected: $expected`, ({ label, expected, value }) => { | ||
expect(formatLabelValuePair(label, value)).toBe(expected); | ||
}); | ||
}); | ||
describe('formatSettingValueToFile: Format setting values to save in the configuration file', () => { | ||
it.each` | ||
input | expected | ||
${'test'} | ${'"test"'} | ||
${'test space'} | ${'"test space"'} | ||
${'test\nnew line'} | ${'"test\\nnew line"'} | ||
${''} | ${'""'} | ||
${1} | ${1} | ||
${true} | ${true} | ||
${false} | ${false} | ||
${['test1']} | ${'["test1"]'} | ||
${['test1', 'test2']} | ${'["test1","test2"]'} | ||
`(`input: $input | expected: $expected`, ({ input, expected }) => { | ||
expect(formatSettingValueToFile(input)).toBe(expected); | ||
}); | ||
}); | ||
|
||
describe('formatSettingValueToFile: Format setting values to save in the configuration file', () => { | ||
it.each` | ||
input | expected | ||
${'test'} | ${'\"test\"'} | ||
${'test space'} | ${'\"test space\"'} | ||
${'test\nnew line'} | ${'\"test\\nnew line\"'} | ||
${''} | ${'\"\"'} | ||
${1} | ${1} | ||
${true} | ${true} | ||
${false} | ${false} | ||
${['test1']} | ${'[\"test1\"]'} | ||
${['test1', 'test2']} | ${'[\"test1\",\"test2\"]'} | ||
`(`input: $input | expected: $expected`, ({ input, expected }) => { | ||
expect(formatSettingValueToFile(input)).toBe(expected); | ||
}); | ||
}); | ||
|
||
describe('getCustomizationSetting: Get the value for the "customization." settings depending on the "customization.enabled" setting', () => { | ||
it.each` | ||
customizationEnabled | settingKey | configValue | expected | ||
${true} | ${'customization.logo.app'} | ${'custom-image-app.png'} | ${'custom-image-app.png'} | ||
${true} | ${'customization.logo.app'} | ${''} | ${''} | ||
${false} | ${'customization.logo.app'} | ${'custom-image-app.png'} | ${''} | ||
${false} | ${'customization.logo.app'} | ${''} | ${''} | ||
${true} | ${'customization.reports.footer'} | ${'Custom footer'} | ${'Custom footer'} | ||
${true} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2022 Wazuh, Inc.'} | ||
${false} | ${'customization.reports.footer'} | ${'Custom footer'} | ${'Copyright © 2022 Wazuh, Inc.'} | ||
${false} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2022 Wazuh, Inc.'} | ||
${false} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2022 Wazuh, Inc.'} | ||
${true} | ${'customization.reports.header'} | ${'Custom header'} | ${'Custom header'} | ||
${true} | ${'customization.reports.header'} | ${''} | ${'info@wazuh.com\nhttps://wazuh.com'} | ||
${false} | ${'customization.reports.header'} | ${'Custom header'} | ${'info@wazuh.com\nhttps://wazuh.com'} | ||
${false} | ${'customization.reports.header'} | ${''} | ${'info@wazuh.com\nhttps://wazuh.com'} | ||
`(`customizationEnabled: $customizationEnabled | settingKey: $settingKey | configValue: $configValue | expected: $expected`, ({ configValue, customizationEnabled, expected, settingKey }) => { | ||
const configuration = { | ||
'customization.enabled': customizationEnabled, | ||
[settingKey]: configValue | ||
}; | ||
expect(getCustomizationSetting(configuration, settingKey)).toBe(expected); | ||
}); | ||
}); | ||
describe('getCustomizationSetting: Get the value for the "customization." settings depending on the "customization.enabled" setting', () => { | ||
it.each` | ||
customizationEnabled | settingKey | configValue | expected | ||
${true} | ${'customization.logo.app'} | ${'custom-image-app.png'} | ${'custom-image-app.png'} | ||
${true} | ${'customization.logo.app'} | ${''} | ${''} | ||
${false} | ${'customization.logo.app'} | ${'custom-image-app.png'} | ${''} | ||
${false} | ${'customization.logo.app'} | ${''} | ${''} | ||
${true} | ${'customization.reports.footer'} | ${'Custom footer'} | ${'Custom footer'} | ||
${true} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2023 Wazuh, Inc.'} | ||
${false} | ${'customization.reports.footer'} | ${'Custom footer'} | ${'Copyright © 2023 Wazuh, Inc.'} | ||
${false} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2023 Wazuh, Inc.'} | ||
${false} | ${'customization.reports.footer'} | ${''} | ${'Copyright © 2023 Wazuh, Inc.'} | ||
${true} | ${'customization.reports.header'} | ${'Custom header'} | ${'Custom header'} | ||
${true} | ${'customization.reports.header'} | ${''} | ${'info@wazuh.com\nhttps://wazuh.com'} | ||
${false} | ${'customization.reports.header'} | ${'Custom header'} | ${'info@wazuh.com\nhttps://wazuh.com'} | ||
${false} | ${'customization.reports.header'} | ${''} | ${'info@wazuh.com\nhttps://wazuh.com'} | ||
`( | ||
`customizationEnabled: $customizationEnabled | settingKey: $settingKey | configValue: $configValue | expected: $expected`, | ||
({ configValue, customizationEnabled, expected, settingKey }) => { | ||
const configuration = { | ||
'customization.enabled': customizationEnabled, | ||
[settingKey]: configValue, | ||
}; | ||
expect(getCustomizationSetting(configuration, settingKey)).toBe( | ||
expected, | ||
); | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters