Skip to content

Commit

Permalink
Update check from 7.2 to 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanahuckova committed Dec 12, 2024
1 parent c08aea2 commit cd0eccb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/zabbix/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ func (ds *Zabbix) GetAllGroups(ctx context.Context) ([]Group, error) {
"sortfield": "name",
}

// Zabbix v7.2 and later removed `real_hosts` parameter and replaced it with `with_hosts`
if ds.version < 72 {
// Zabbix v7.0 and later removed `real_hosts` parameter and replaced it with `with_hosts`
if ds.version < 70 {
params["real_hosts"] = true
} else {
params["with_hosts"] = true
Expand Down
6 changes: 3 additions & 3 deletions pkg/zabbixapi/zabbix_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func (api *ZabbixAPI) request(ctx context.Context, method string, params ZabbixA
"params": params,
}

// Zabbix v7.2 and later removed `auth` parameter and replaced it with using Auth header
// `auth` parameter throws an error in Zabbix v7.2 and later so we need to add it only for older versions
if auth != "" && version < 72 {
// Zabbix v7.2 and later deprecated `auth` parameter and replaced it with using Auth header
// `auth` parameter throws an error in new versions so we need to add it only for older versions
if auth != "" && version < 70 {
apiRequest["auth"] = auth
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ describe('Zabbix API connector', () => {
expect(zabbixAPIConnector.request).toHaveBeenCalledWith('proxy.get', { output: ['proxyid', 'host'] });
});

it('should send the with_hosts parameter when version is 7.2+', () => {
it('should send the with_hosts parameter when version is 7.0+', () => {
const zabbixAPIConnector = new ZabbixAPIConnector(true, true, 123);
zabbixAPIConnector.version = '7.2.0';
zabbixAPIConnector.version = '7.0.0';
zabbixAPIConnector.request = jest.fn();

zabbixAPIConnector.getGroups();
Expand All @@ -37,9 +37,9 @@ describe('Zabbix API connector', () => {
});
});

it('should send the real_hosts parameter when version is <7.2', () => {
it('should send the real_hosts parameter when version is <7.0', () => {
const zabbixAPIConnector = new ZabbixAPIConnector(true, true, 123);
zabbixAPIConnector.version = '7.1.0';
zabbixAPIConnector.version = '6.5.0';
zabbixAPIConnector.request = jest.fn();

zabbixAPIConnector.getGroups();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export class ZabbixAPIConnector {
sortfield: 'name',
};

// Zabbix v7.2 and later removed `real_hosts` parameter and replaced it with `with_hosts`
if (this.isZabbix72OrHigher()) {
// Zabbix v7.0 and later deprecated `real_hosts` parameter and replaced it with `with_hosts`
if (semver.gte(this.version, '7.0.0')) {
params['with_hosts'] = true;
} else {
params['real_hosts'] = true;
Expand Down

0 comments on commit cd0eccb

Please sign in to comment.