Skip to content

Commit

Permalink
Add cluster's IP and protocol as suggestions in the agent deployment …
Browse files Browse the repository at this point in the history
…wizard (#4776)

* section deploy new agent in progress

* tabSystemD and tabSysV

* section deploy a new agent done

* cleaning code

* cleaning code

* test

* CHANGELOG

* code cleaning

* design for when a user selects an obsolete system version

* code cleanup

* changed macOS for macOS and updated the macOS version view

* development with information update provided by ci cd

* applying some of the new changes that the ci cd team sent us today

* delete

* updating information sent by ci/cd on operating systems, commands, etc.

* logic of displaying message to rare operating systems and redirecting them to documentation

* logic of displaying message to rare operating systems and redirecting them to documentation

* wazuh protocol variable

* Ordered OS buttons in deploy new agent steps

* Replaced input server address

* Testing signed commits

* Added server address component isolated from register-agent component

* Added test for multiple nodes rendered in combobox

* Added wazuh manager multiple ips in command definition

* Refactored and cleaned code

* Added unit test

* Updated CHANGELOG

* Added default option and paste only name in combo tag

* variable of deployment wazuh protocol

* merge 4.4-7.10

* Added free option enter and cleaned code

* removing spaces, css den deshuso, unify uppercase

* Refactored code and added new tests and fixed old tests

* removing link space

* fixed labels

* Resolved review comments following dev style guide

* change of logic in links

* Added OS delimiter condition

* Added and updated unit tests

* Resolved review comments

* Removed empty file

* Removed snapshot to fix unit tests workflow

* message + error handling

* Detached getRemoteInfo request in service to ease unit testing

* Add agent name to the deployment command (#4739)

* Add variable for the agent's name

* input is cleaned if there is no data

* design input name

* Update CHANGELOG

* Resolved review comment, unused code and code format

Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>

* Fixing tests

* Testing signed commit with updated email

* Fixing unverified commit

* Fixing eslint errors

* Added get remote info by node and unit tests

* Added server address and protocol behavior

* Updated Server address unit tests

* Updated and added register agent service unit tests

* Added error managment in register agent and server address component

* Updated CHANGELOG

* Fixed tests workflow

* CHANGELOG

* udpProtocol:false

* constants for repeated text

Co-authored-by: chantal.kelm <chantal.belen.kelm@gmail.com>
Co-authored-by: Chantal Belén kelm <99441266+chantal-kelm@users.noreply.github.com>
Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit d178752)
  • Loading branch information
Machi3mfl authored and chantal-kelm committed Nov 11, 2022
1 parent 6fb45d5 commit 17ebbee
Show file tree
Hide file tree
Showing 8 changed files with 1,043 additions and 77 deletions.
14 changes: 3 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,34 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added agent synchronization status in the agent module. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874)
- The input name was added and when the user adds a value the variable WAZUH_AGENT_NAME with its value appears in the installation command. [#4739](https://github.com/wazuh/wazuh-kibana-app/pull/4739)
- Redesign the SCA table from agent's dashboard [#4512](https://github.com/wazuh/wazuh-kibana-app/pull/4512)
- Enhanced the plugin setting description displayed in the UI and the configuration file. [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4501)
- Added validation to the plugin settings in the form of `Settings/Configuration` and the endpoint to update the plugin configuration [#4503](https://github.com/wazuh/wazuh-kibana-app/pull/4503)[#4785](https://github.com/wazuh/wazuh-kibana-app/pull/4785)
- Added new plugin settings to customize the header and footer on the PDF reports [#4505](https://github.com/wazuh/wazuh-kibana-app/pull/4505)[#4798](https://github.com/wazuh/wazuh-kibana-app/pull/4798)[#4805](https://github.com/wazuh/wazuh-kibana-app/pull/4805)
- Add a new plugin setting to enable or disable the customization [#4507](https://github.com/wazuh/wazuh-kibana-app/pull/4507)

### Changed

- Changed the HTTP verb from `GET` to `POST` in the requests to login to the Wazuh API [#4103](https://github.com/wazuh/wazuh-kibana-app/pull/4103)
- Improve alerts summary performance [#4376](https://github.com/wazuh/wazuh-kibana-app/pull/4376)
- Endpoint `/agents/summary/status` response was adapted. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874)
- Updated and added operating systems, versions, architectures commands of Install and enroll the agent and
commands of Start the agent in the deploy new agent section [#4458](https://github.com/wazuh/wazuh-kibana-app/pull/4458)
- Makes Agents Overview loading icons independent [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- Added cluster's IP and protocol as suggestions in the agent deployment wizard. [#4776](https://github.com/wazuh/wazuh-kibana-app/pull/4776)
- Changed the endpoint that updates the plugin configuration to support multiple settings. [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4501)

### Fixed

- Improves Agents Overview performance [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- Improved alerts summary performance [#4376](https://github.com/wazuh/wazuh-kibana-app/pull/4376)
- The endpoint `/agents/summary/status` response was adapted. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874)
- Made Agents Overview icons load independently [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- Improved the message displayed when there is a versions mismatch between the Wazuh API and the Wazuh APP [#4529](https://github.com/wazuh/wazuh-kibana-app/pull/4529)
- Changed the endpoint that updates the plugin configuration to support multiple settings. [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4501)
- Allowed to upload an image for the `customization.logo.*` settings in `Settings/Configuration` [#4504](https://github.com/wazuh/wazuh-kibana-app/pull/4504)
- Fixed the agents wizard OS styles and their versions. [#4832](https://github.com/wazuh/wazuh-kibana-app/pull/4832) [#4838](https://github.com/wazuh/wazuh-kibana-app/pull/4838/files)
- Improved Agents Overview performance [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)

### Fixed

- Fixed nested fields filtering in dashboards tables and KPIs [#4425](https://github.com/wazuh/wazuh-kibana-app/pull/4425)
- Fixed nested field rendering in security alerts table details [#4428](https://github.com/wazuh/wazuh-kibana-app/pull/4428)
- Improved Agents Overview performance [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- Fixed a bug where the Wazuh logo was used instead of the custom one [#4539](https://github.com/wazuh/wazuh-kibana-app/pull/4539)
- Fixed rendering problems of the `Agent Overview` section in low resolutions [#4516](https://github.com/wazuh/wazuh-kibana-app/pull/4516)
- Fixed issue when logging out from Wazuh when SAML is enabled [#4595](https://github.com/wazuh/wazuh-kibana-app/issues/4595)
- Fixed server errors with code 500 when the Wazuh API is not reachable / up. [#4710](https://github.com/wazuh/wazuh-kibana-app/pull/4710) [#4728](https://github.com/wazuh/wazuh-kibana-app/pull/4728)


- Fixed pagination to SCA table [#4653](https://github.com/wazuh/wazuh-kibana-app/issues/4653)

## Wazuh v4.3.9 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4310
Expand Down
272 changes: 272 additions & 0 deletions public/controllers/agent/components/register-agent-service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
import * as RegisterAgentService from './register-agent-service';
import { WzRequest } from '../../../react-services/wz-request';
import { ServerAddressOptions } from '../register-agent/steps';

jest.mock('../../../react-services', () => ({
...jest.requireActual('../../../react-services') as object,
WzRequest: () => ({
apiReq: jest.fn(),
}),
}));


describe('Register agent service', () => {
beforeEach(() => jest.clearAllMocks());
describe('getRemoteConfiguration', () => {
it('should return secure connection = TRUE when have connection secure', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.haveSecureConnection).toBe(true);
});

it('should return secure connection = FALSE available when dont have connection secure', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP', 'TCP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.haveSecureConnection).toBe(false);
});

it('should return protocols UDP when is the only connection protocol available', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.isUdp).toEqual(true);
});

it('should return protocols TCP when is the only connection protocol available', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['TCP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['TCP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.isUdp).toEqual(false);
});

it('should return is not UDP when have UDP and TCP protocols available', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['TCP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.isUdp).toEqual(false);
});
});

describe('getConnectionConfig', () => {

beforeAll(() => {
jest.clearAllMocks();
})

it('should return UDP when the server address is typed manually (custom)', async () => {
const nodeSelected: ServerAddressOptions = {
label: 'node-selected',
value: 'node-selected',
nodetype: 'master'
};

const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);

const config = await RegisterAgentService.getConnectionConfig(nodeSelected, 'default-dns-address');
expect(config.udpProtocol).toEqual(true);
expect(config.serverAddress).toBe('default-dns-address');
})

it('should return UDP when the server address is received like default server address dns (custom)', async () => {
const nodeSelected: ServerAddressOptions = {
label: 'node-selected',
value: 'node-selected',
nodetype: 'master'
};

const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);

const config = await RegisterAgentService.getConnectionConfig(nodeSelected);
expect(config.udpProtocol).toEqual(true);
})
})
});
Loading

0 comments on commit 17ebbee

Please sign in to comment.