From 2a6884b4e8b3db445eb90da65e365e239e728905 Mon Sep 17 00:00:00 2001 From: Antonio <34042064+Desvelao@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:49:53 +0100 Subject: [PATCH] Upgrade version axios (#6114) * fix: update axios dependency * fix: tests of Wazuh Check Updates plugin using supertest instead of axios * changelog: add entry --- CHANGELOG.md | 1 + plugins/main/package.json | 2 +- plugins/main/yarn.lock | 8 ++++---- plugins/wazuh-check-updates/package.json | 2 +- .../server/routes/updates/get-updates.test.ts | 12 ++++++------ .../user-preferences/get-user-preferences.test.ts | 10 ++++++---- .../user-preferences/update-user-preferences.test.ts | 10 ++++++---- plugins/wazuh-check-updates/yarn.lock | 12 ++++++------ plugins/wazuh-core/package.json | 4 ++-- plugins/wazuh-core/yarn.lock | 12 ++++++------ 10 files changed, 39 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb4ea6e6b..34c81501ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/plugins/main/package.json b/plugins/main/package.json index bf70296e0e..a4769bf9fa 100644 --- a/plugins/main/package.json +++ b/plugins/main/package.json @@ -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", diff --git a/plugins/main/yarn.lock b/plugins/main/yarn.lock index c30706356d..915a66d1d9 100644 --- a/plugins/main/yarn.lock +++ b/plugins/main/yarn.lock @@ -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" diff --git a/plugins/wazuh-check-updates/package.json b/plugins/wazuh-check-updates/package.json index 7103f1ea3c..aae942e027 100644 --- a/plugins/wazuh-check-updates/package.json +++ b/plugins/wazuh-check-updates/package.json @@ -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" diff --git a/plugins/wazuh-check-updates/server/routes/updates/get-updates.test.ts b/plugins/wazuh-check-updates/server/routes/updates/get-updates.test.ts index 14a4d4c0d9..7172b12182 100644 --- a/plugins/wazuh-check-updates/server/routes/updates/get-updates.test.ts +++ b/plugins/wazuh-check-updates/server/routes/updates/get-updates.test.ts @@ -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'); @@ -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', }); diff --git a/plugins/wazuh-check-updates/server/routes/user-preferences/get-user-preferences.test.ts b/plugins/wazuh-check-updates/server/routes/user-preferences/get-user-preferences.test.ts index d7467542c2..89264fd9ac 100644 --- a/plugins/wazuh-check-updates/server/routes/user-preferences/get-user-preferences.test.ts +++ b/plugins/wazuh-check-updates/server/routes/user-preferences/get-user-preferences.test.ts @@ -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'); @@ -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); }); }); diff --git a/plugins/wazuh-check-updates/server/routes/user-preferences/update-user-preferences.test.ts b/plugins/wazuh-check-updates/server/routes/user-preferences/update-user-preferences.test.ts index ec2173248c..8fb6714142 100644 --- a/plugins/wazuh-check-updates/server/routes/user-preferences/update-user-preferences.test.ts +++ b/plugins/wazuh-check-updates/server/routes/user-preferences/update-user-preferences.test.ts @@ -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'); @@ -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); }); }); diff --git a/plugins/wazuh-check-updates/yarn.lock b/plugins/wazuh-check-updates/yarn.lock index 33ba9821b4..77ac1ea0cc 100644 --- a/plugins/wazuh-check-updates/yarn.lock +++ b/plugins/wazuh-check-updates/yarn.lock @@ -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" @@ -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" diff --git a/plugins/wazuh-core/package.json b/plugins/wazuh-core/package.json index 02c41ac1b0..0cd35b67a3 100644 --- a/plugins/wazuh-core/package.json +++ b/plugins/wazuh-core/package.json @@ -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": { diff --git a/plugins/wazuh-core/yarn.lock b/plugins/wazuh-core/yarn.lock index dd76016347..a28ac899ed 100644 --- a/plugins/wazuh-core/yarn.lock +++ b/plugins/wazuh-core/yarn.lock @@ -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" @@ -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"