Skip to content

Commit

Permalink
Upgrade version axios (#6114)
Browse files Browse the repository at this point in the history
* fix: update axios dependency

* fix: tests of Wazuh Check Updates plugin using supertest instead of axios

* changelog: add entry
  • Loading branch information
Desvelao authored Nov 13, 2023
1 parent d69d81c commit 2a6884b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Moved the plugin menu to platform applications into the side menu [#5840](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5840)
- Changed dashboards. [#6035](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6035)
- Change the display order of tabs in all modules. [#6067](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6067)
- Upgraded the `axios` dependency to `1.6.1` [#5062](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5062)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion plugins/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"angular-animate": "1.8.3",
"angular-material": "1.2.5",
"axios": "^1.3.4",
"axios": "^1.6.1",
"install": "^0.13.0",
"js2xmlparser": "^5.0.0",
"json2csv": "^4.1.2",
Expand Down
8 changes: 4 additions & 4 deletions plugins/main/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,10 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

axios@^1.3.4, axios@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==
axios@^1.4.0, axios@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7"
integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion plugins/wazuh-check-updates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:jest:runner": "node scripts/runner test"
},
"dependencies": {
"axios": "^1.5.0",
"axios": "^1.6.1",
"md5": "^2.3.0",
"node-cron": "^3.0.2",
"winston": "^3.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { ByteSizeValue } from '@osd/config-schema';
import { getUpdates } from '../../services/updates';
import { routes } from '../../../common/constants';
import { getUpdatesRoute } from './get-updates';
import axios from 'axios';
import supertest from 'supertest';
import { API_UPDATES_STATUS, AvailableUpdates } from '../../../common/types';

const serverAddress = '127.0.0.1';
const port = 11002; //assign a different port in each unit test
axios.defaults.baseURL = `http://${serverAddress}:${port}`;

const mockedGetUpdates = getUpdates as jest.Mock;
jest.mock('../../services/updates');
Expand Down Expand Up @@ -100,11 +99,12 @@ describe(`[endpoint] GET ${routes.checkUpdates}`, () => {
};

mockedGetUpdates.mockImplementation(() => mockResponse);
const response = await axios.get(
`${routes.checkUpdates}?checkAvailableUpdates=true`,
);
const response = await supertest(innerServer.listener)
.get(`${routes.checkUpdates}?checkAvailableUpdates=true`)
.send(mockResponse)
.expect(200);

expect(response.data).toEqual({
expect(response.body).toEqual({
...mockResponse,
last_check_date: '2023-09-30T14:00:00.000Z',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { HttpServer } from '../../../../../src/core/server/http/http_server';
import { loggingSystemMock } from '../../../../../src/core/server/logging/logging_system.mock';
import { ByteSizeValue } from '@osd/config-schema';
import { routes } from '../../../common/constants';
import axios from 'axios';
import supertest from 'supertest';
import { getUserPreferences } from '../../services/user-preferences';
import { getUserPreferencesRoutes } from './get-user-preferences';
import { UserPreferences } from '../../../common/types';

const serverAddress = '127.0.0.1';
const port = 11003; //assign a different port in each unit test
axios.defaults.baseURL = `http://${serverAddress}:${port}`;

const mockedGetUserPreferences = getUserPreferences as jest.Mock;
jest.mock('../../services/user-preferences');
Expand Down Expand Up @@ -87,8 +86,11 @@ describe(`[endpoint] GET ${routes.userPreferences}`, () => {
};

mockedGetUserPreferences.mockImplementation(() => mockResponse);
const response = await axios.get(routes.userPreferences);

expect(response.data).toEqual(mockResponse);
const response = await supertest(innerServer.listener)
.get(routes.userPreferences)
.expect(200);

expect(response.body).toEqual(mockResponse);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { HttpServer } from '../../../../../src/core/server/http/http_server';
import { loggingSystemMock } from '../../../../../src/core/server/logging/logging_system.mock';
import { ByteSizeValue } from '@osd/config-schema';
import { routes } from '../../../common/constants';
import axios from 'axios';
import supertest from 'supertest';
import { updateUserPreferences } from '../../services/user-preferences';
import { updateUserPreferencesRoutes } from './update-user-preferences';
import { UserPreferences } from '../../../common/types';

const serverAddress = '127.0.0.1';
const port = 11004; //assign a different port in each unit test
axios.defaults.baseURL = `http://${serverAddress}:${port}`;

const mockedUpdateUserPreferences = updateUserPreferences as jest.Mock;
jest.mock('../../services/user-preferences');
Expand Down Expand Up @@ -87,8 +86,11 @@ describe(`[endpoint] PATCH ${routes.userPreferences}`, () => {
};

mockedUpdateUserPreferences.mockImplementation(() => mockResponse);
const response = await axios.patch(routes.userPreferences);
const response = await supertest(innerServer.listener)
.patch(routes.userPreferences)
.send(mockResponse)
.expect(200);

expect(response.data).toEqual(mockResponse);
expect(response.body).toEqual(mockResponse);
});
});
12 changes: 6 additions & 6 deletions plugins/wazuh-check-updates/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ asynckit@^0.4.0:
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==

axios@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.0.tgz#f02e4af823e2e46a9768cfc74691fdd0517ea267"
integrity sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==
version "1.6.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7"
integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
Expand Down Expand Up @@ -138,9 +138,9 @@ fn.name@1.x.x:
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==

follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
version "1.15.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a"
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==

form-data@^4.0.0:
version "4.0.0"
Expand Down
4 changes: 2 additions & 2 deletions plugins/wazuh-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"test:jest:runner": "node scripts/runner test"
},
"dependencies": {
"axios": "^1.5.0",
"axios": "^1.6.1",
"json2csv": "^4.1.2",
"jwt-decode": "^3.1.2",
"node-cron": "^3.0.2",
"md5": "^2.3.0",
"node-cron": "^3.0.2",
"winston": "^3.10.0"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions plugins/wazuh-core/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ asynckit@^0.4.0:
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==

axios@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.0.tgz#f02e4af823e2e46a9768cfc74691fdd0517ea267"
integrity sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==
version "1.6.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7"
integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
Expand Down Expand Up @@ -138,9 +138,9 @@ fn.name@1.x.x:
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==

follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
version "1.15.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a"
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==

form-data@^4.0.0:
version "4.0.0"
Expand Down

0 comments on commit 2a6884b

Please sign in to comment.