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

Check for updates when user logs in #6001

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`SettingsAboutAppInfo component should render version, revision, install
<h2
class="euiTitle euiTitle--medium"
>
Wazuh Dashboard version
Dashboard version
</h2>
<div
class="euiSpacer euiSpacer--l"
Expand Down
4 changes: 2 additions & 2 deletions plugins/main/public/components/settings/about/appInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const SettingsAboutAppInfo = ({ appInfo }: SettingsAboutAppInfoProps) =>
return (
<>
<EuiTitle>
<h2>Wazuh Dashboard version</h2>
<h2>Dashboard version</h2>
</EuiTitle>
<EuiSpacer size="l" />
<EuiFlexGroup responsive={false} wrap alignItems="center">
Expand Down Expand Up @@ -70,7 +70,7 @@ export const SettingsAboutAppInfo = ({ appInfo }: SettingsAboutAppInfoProps) =>
<>
<EuiSpacer size="l" />
<EuiCallOut
title="Wazuh Dashboard version must be the same as APIs"
title="Dashboard version must be the same as APIs"
color="warning"
iconType="alert"
/>
Expand Down
37 changes: 0 additions & 37 deletions plugins/wazuh-check-updates/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
import path from 'path';

export const PLUGIN_ID = 'wazuhCheckUpdates';
export const PLUGIN_NAME = 'wazuh_check_updates';

export const SAVED_OBJECT_UPDATES = 'wazuh-check-updates-available-updates';
export const SAVED_OBJECT_SETTINGS = 'wazuh-check-updates-settings';
export const SAVED_OBJECT_USER_PREFERENCES = 'wazuh-check-updates-user-preferences';

export const DEFAULT_SCHEDULE = '0 0 * * *';

export enum routes {
checkUpdates = '/api/wazuh-check-updates/updates',
userPreferences = '/api/wazuh-check-updates/user-preferences/me',
}

// Security
export const WAZUH_SECURITY_PLUGIN_OPENSEARCH_DASHBOARDS_SECURITY =
'OpenSearch Dashboards Security';

// Default Elasticsearch user name context
export const ELASTIC_NAME = 'elastic';

// Wazuh data path
const WAZUH_DATA_PLUGIN_PLATFORM_BASE_PATH = 'data';
export const WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH = path.join(
__dirname,
'../../../',
WAZUH_DATA_PLUGIN_PLATFORM_BASE_PATH
);
export const WAZUH_DATA_ABSOLUTE_PATH = path.join(
WAZUH_DATA_PLUGIN_PLATFORM_BASE_ABSOLUTE_PATH,
'wazuh'
);

// Wazuh data path - config
export const WAZUH_DATA_CONFIG_DIRECTORY_PATH = path.join(WAZUH_DATA_ABSOLUTE_PATH, 'config');
export const WAZUH_DATA_CONFIG_APP_PATH = path.join(WAZUH_DATA_CONFIG_DIRECTORY_PATH, 'wazuh.yml');

// Wazuh data path - logs
export const MAX_MB_LOG_FILES = 100;
export const WAZUH_DATA_LOGS_DIRECTORY_PATH = path.join(WAZUH_DATA_ABSOLUTE_PATH, 'logs');
export const WAZUH_DATA_LOGS_PLAIN_FILENAME = 'wazuhapp-plain.log';
export const WAZUH_DATA_LOGS_RAW_FILENAME = 'wazuhapp.log';

// App configuration
export const WAZUH_CONFIGURATION_CACHE_TIME = 10000; // time in ms;
7 changes: 2 additions & 5 deletions plugins/wazuh-check-updates/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum API_UPDATES_STATUS {
UP_TO_DATE = 'upToDate',
AVAILABLE_UPDATES = 'availableUpdates',
DISABLED = 'disabled',
ERROR = 'error',
}

Expand Down Expand Up @@ -42,13 +43,9 @@ export interface UserPreferences {
hide_update_notifications?: boolean;
}

export interface CheckUpdatesSettings {
schedule?: string;
}

export interface AvailableUpdates {
apis_available_updates: ApiAvailableUpdates[];
last_check_date: Date;
}

export type savedObjectType = AvailableUpdates | UserPreferences | CheckUpdatesSettings;
export type savedObjectType = AvailableUpdates | UserPreferences;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`UpdatesNotification component should retrieve available updates when cl
<h2
class="euiTitle euiTitle--medium"
>
Wazuh APIs version
APIs version
</h2>
<div
class="euiSpacer euiSpacer--l"
Expand Down Expand Up @@ -34,7 +34,7 @@ exports[`UpdatesNotification component should retrieve available updates when cl
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.228 2.942a.5.5 0 11-.538.842A5 5 0 1013 8a.5.5 0 111 0 6 6 0 11-2.772-5.058zM14 1.5v3A1.5 1.5 0 0112.5 6h-3a.5.5 0 010-1h3a.5.5 0 00.5-.5v-3a.5.5 0 111 0z"
d="M11.228 2.942a.5.5 0 1 1-.538.842A5 5 0 1 0 13 8a.5.5 0 1 1 1 0 6 6 0 1 1-2.772-5.058ZM14 1.5v3A1.5 1.5 0 0 1 12.5 6h-3a.5.5 0 0 1 0-1h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 1 1 1 0Z"
/>
</svg>
<span
Expand Down Expand Up @@ -90,7 +90,7 @@ exports[`UpdatesNotification component should return the ApisUpdateStatus compon
<h2
class="euiTitle euiTitle--medium"
>
Wazuh APIs version
APIs version
</h2>
<div
class="euiSpacer euiSpacer--l"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ jest.mock('../dismiss-notification-check', () => ({
}));

jest.mock('./table', () => ({
ApisUpdateTable: jest
.fn()
.mockReturnValue(<div>APIs Updates Table component</div>),
ApisUpdateTable: jest.fn().mockReturnValue(<div>APIs Updates Table component</div>),
}));

jest.mock('../../../../plugin-services', () => ({
getWazuhCore: jest
.fn()
.mockReturnValue({
utils: {
formatUIDate: jest.fn().mockReturnValue('2023-09-18T14:00:00.000Z'),
},
}),
jest.mock('../../plugin-services', () => ({
getWazuhCore: jest.fn().mockReturnValue({
utils: {
formatUIDate: jest.fn().mockReturnValue('2023-09-18T14:00:00.000Z'),
},
}),
}));

const mockedUseAvailabeUpdates = useAvailableUpdates as jest.Mock;
Expand Down Expand Up @@ -59,14 +55,12 @@ describe('UpdatesNotification component', () => {
}));

const { container, getByText } = render(
<ApisUpdateStatus setApisAvailableUpdates={() => {}} />,
<ApisUpdateStatus setApisAvailableUpdates={() => {}} />
);

expect(container).toMatchSnapshot();

const dismissNotificationCheck = getByText(
'Dismiss Notification Check component',
);
const dismissNotificationCheck = getByText('Dismiss Notification Check component');
expect(dismissNotificationCheck).toBeInTheDocument();

const apisUpdateTable = getByText('APIs Updates Table component');
Expand Down Expand Up @@ -103,7 +97,7 @@ describe('UpdatesNotification component', () => {
}));

const { container, getByRole, getByText } = render(
<ApisUpdateStatus setApisAvailableUpdates={() => {}} />,
<ApisUpdateStatus setApisAvailableUpdates={() => {}} />
);

expect(container).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const ApisUpdateStatus = ({
<h2>
<FormattedMessage
id={`wazuhCheckUpdates.apisUpdateStatus.tableTitle`}
defaultMessage='Wazuh APIs version'
defaultMessage='APIs version'
/>
</h2>
</EuiTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ exports[`ApisUpdateTable component should return the ApisUpdateTable component 1
data-test-subj="tableHeaderCell_api_id_0"
role="columnheader"
scope="col"
style="width: 100px;"
>
<span
class="euiTableCellContent"
Expand All @@ -53,7 +52,6 @@ exports[`ApisUpdateTable component should return the ApisUpdateTable component 1
data-test-subj="tableHeaderCell_current_version_1"
role="columnheader"
scope="col"
style="width: 100px;"
>
<span
class="euiTableCellContent"
Expand All @@ -71,7 +69,6 @@ exports[`ApisUpdateTable component should return the ApisUpdateTable component 1
data-test-subj="tableHeaderCell_status_2"
role="columnheader"
scope="col"
style="width: 200px;"
>
<span
class="euiTableCellContent"
Expand All @@ -84,60 +81,6 @@ exports[`ApisUpdateTable component should return the ApisUpdateTable component 1
</span>
</span>
</th>
<th
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell_last_available_major_3"
role="columnheader"
scope="col"
style="width: 200px;"
>
<span
class="euiTableCellContent"
>
<span
class="euiTableCellContent__text"
title="Last major"
>
Last major
</span>
</span>
</th>
<th
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell_last_available_minor_4"
role="columnheader"
scope="col"
style="width: 200px;"
>
<span
class="euiTableCellContent"
>
<span
class="euiTableCellContent__text"
title="Last minor"
>
Last minor
</span>
</span>
</th>
<th
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell_last_available_patch_5"
role="columnheader"
scope="col"
style="width: 200px;"
>
<span
class="euiTableCellContent"
>
<span
class="euiTableCellContent__text"
title="Last patch"
>
Last patch
</span>
</span>
</th>
</tr>
</thead>
<tbody>
Expand All @@ -146,7 +89,6 @@ exports[`ApisUpdateTable component should return the ApisUpdateTable component 1
>
<td
class="euiTableRowCell"
style="width: 100px;"
>
<div
class="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
Expand All @@ -165,7 +107,6 @@ exports[`ApisUpdateTable component should return the ApisUpdateTable component 1
</td>
<td
class="euiTableRowCell"
style="width: 100px;"
>
<div
class="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
Expand All @@ -184,99 +125,20 @@ exports[`ApisUpdateTable component should return the ApisUpdateTable component 1
</td>
<td
class="euiTableRowCell"
style="width: 200px;"
>
<div
class="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
>
Update status
</div>
<div
class="euiTableCellContent euiTableCellContent--overflowingContent"
>
<div
class="euiHealth euiHealth--textSizeS"
>
<div
class="euiFlexGroup euiFlexGroup--gutterExtraSmall euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow"
>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon--warning euiIcon-isLoading"
focusable="false"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</div>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
Available updates
</div>
</div>
</div>
</div>
</td>
<td
class="euiTableRowCell"
style="width: 200px;"
>
<div
class="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
>
Last major
</div>
<div
class="euiTableCellContent euiTableCellContent--overflowingContent"
/>
</td>
<td
class="euiTableRowCell"
style="width: 200px;"
>
<div
class="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
>
Last minor
</div>
<div
class="euiTableCellContent euiTableCellContent--overflowingContent"
/>
</td>
<td
class="euiTableRowCell"
style="width: 200px;"
>
<div
class="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
>
Last patch
</div>
<div
class="euiTableCellContent euiTableCellContent--overflowingContent"
class="euiTableCellContent"
>
<button
aria-label="update-v4.3.8"
class="euiBadge euiBadge-isClickable euiBadge--hollow euiBadge--iconLeft"
style="max-width: max-content;"
title="v4.3.8"
<span
class="euiTableCellContent__text"
>
<span
class="euiBadge__content"
>
<span
class="euiBadge__text"
>
v4.3.8
</span>
</span>
</button>
availableUpdates
</span>
</div>
</td>
</tr>
Expand Down
Loading
Loading