Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix outdated year in PDF report footer #5766

Merged
merged 10 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed the agents active coverage stat as NaN in Details panel of Agents section [#5490](https://github.com/wazuh/wazuh-kibana-app/pull/5490)
- Fixed a broken documentation link to agent labels [#5687](https://github.com/wazuh/wazuh-kibana-app/pull/5687)
- Fixed the PDF report filters applied to tables [#5714](https://github.com/wazuh/wazuh-kibana-app/pull/5714)
- Fixed outdated year in the PDF report footer [#5766](https://github.com/wazuh/wazuh-kibana-app/pull/5766)

### Removed

Expand Down
2 changes: 1 addition & 1 deletion common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const ASSETS_PUBLIC_URL = '/plugins/wazuh/public/assets/';
// Reports
export const REPORTS_LOGO_IMAGE_ASSETS_RELATIVE_PATH = 'images/logo_reports.png';
export const REPORTS_PRIMARY_COLOR = '#256BD1';
export const REPORTS_PAGE_FOOTER_TEXT = 'Copyright © 2022 Wazuh, Inc.';
export const REPORTS_PAGE_FOOTER_TEXT = 'Copyright © 2023 Wazuh, Inc.';
export const REPORTS_PAGE_HEADER_TEXT = 'info@wazuh.com\nhttps://wazuh.com';

// Plugin platform
Expand Down
115 changes: 61 additions & 54 deletions common/services/settings.test.ts
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,
);
},
);
});
});