diff --git a/plugins/modules/zabbix_connector.py b/plugins/modules/zabbix_connector.py index 2bd6b1d8e..f5c6b511c 100644 --- a/plugins/modules/zabbix_connector.py +++ b/plugins/modules/zabbix_connector.py @@ -242,12 +242,12 @@ class Connector(ZabbixBase): } VALUE_TYPES = { - "numeric_float": "1", - "character": "2", - "log": "4", - "numeric_unsigned": "8", - "text": "10", - "binary": "20", + "numeric_float": 1, + "character": 2, + "log": 4, + "numeric_unsigned": 8, + "text": 10, + "binary": 20, } AUTH_TYPES = { diff --git a/tests/integration/targets/test_zabbix_connector/tasks/main.yml b/tests/integration/targets/test_zabbix_connector/tasks/main.yml index 7a4a030f1..27f51a587 100644 --- a/tests/integration/targets/test_zabbix_connector/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_connector/tasks/main.yml @@ -93,13 +93,58 @@ value: hidden register: connector_auth_tags_update - - name: assert that auth has changed + - name: assert that auth has not changed ansible.builtin.assert: that: not connector_auth_tags_update is changed + - name: test - set item value type (version >= 7.0) + community.zabbix.zabbix_connector: + name: ExampleConnector1 + url: https://127.0.0.1/api/zabbix_stream + data_type: item_values + item_value_types: "{{ item }}" + loop: + - ["numeric_float"] + - ["numeric_float", "numeric_unsigned", "character", "text"] + - ["all+bin"] + - ["all"] + when: zabbix_version is version('7.0', '>=') + register: connector_value_type + + - name: assert that all item value type updates lead to changed + ansible.builtin.assert: + that: + - connector_value_type.results | map(attribute='changed') is all + + - name: test - set non existent item value type (version >= 7.0) + community.zabbix.zabbix_connector: + name: ExampleConnector1 + url: https://127.0.0.1/api/zabbix_stream + data_type: item_values + item_value_types: + - not_a_real_value_type + when: zabbix_version is version('7.0', '>=') + register: connector_wrong_value_type + ignore_errors: true + + - name: assert that the module failed + ansible.builtin.assert: + that: connector_wrong_value_type is failed and "is not a known value type" in connector_wrong_value_type.msg + always: - name: Cleanup connector community.zabbix.zabbix_connector: name: ExampleConnector1 state: absent ignore_errors: true + + - name: test - cleanup connector (again) + community.zabbix.zabbix_connector: + name: ExampleConnector1 + state: absent + ignore_errors: true + register: connector_delete + + - name: assert that nothing has changed + ansible.builtin.assert: + that: not connector_delete is changed or connector_delete is failed