From cd0eccbcfb1b259d1290c0ac786f7f838b21eb75 Mon Sep 17 00:00:00 2001 From: Ivana Huckova Date: Thu, 12 Dec 2024 15:41:25 +0100 Subject: [PATCH] Update check from 7.2 to 7.0 --- pkg/zabbix/methods.go | 4 ++-- pkg/zabbixapi/zabbix_api.go | 6 +++--- .../connectors/zabbix_api/zabbixAPIConnector.test.ts | 8 ++++---- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/zabbix/methods.go b/pkg/zabbix/methods.go index 2cc60b1c..5f98dd96 100644 --- a/pkg/zabbix/methods.go +++ b/pkg/zabbix/methods.go @@ -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 diff --git a/pkg/zabbixapi/zabbix_api.go b/pkg/zabbixapi/zabbix_api.go index 18cb3f1d..f0c9bca4 100644 --- a/pkg/zabbixapi/zabbix_api.go +++ b/pkg/zabbixapi/zabbix_api.go @@ -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 } diff --git a/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.test.ts b/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.test.ts index 0c8f6c52..5369ae15 100644 --- a/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.test.ts +++ b/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.test.ts @@ -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(); @@ -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(); diff --git a/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 0b22558b..12ff7f44 100644 --- a/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -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;