Module: check_mk
Branch: master
Commit: 13811914e7ea51292ee87565bb7ef8ab64b9b8b0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=13811914e7ea51…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Feb 20 12:57:21 2018 +0100
Add management board tests involving the management board config ruleset
Change-Id: I1c9d29706f9b2f640d7a5afd796d752f5cc79625
---
tests/cmk_base/test_mgmt_board.py | 100 ++++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/tests/cmk_base/test_mgmt_board.py b/tests/cmk_base/test_mgmt_board.py
index ee43b27..3d55a1d 100644
--- a/tests/cmk_base/test_mgmt_board.py
+++ b/tests/cmk_base/test_mgmt_board.py
@@ -144,3 +144,103 @@ def test_mgmt_inherit_protocol(web):
assert config.management_address_of("mgmt-host") == "127.0.0.1"
assert config.management_protocol_of("mgmt-host") == "snmp"
assert config.management_credentials_of("mgmt-host") == "FOLDER"
+
+
+def test_mgmt_config_ruleset(web):
+ web.set_ruleset("management_board_config", {
+ "ruleset": {
+ "": [ # "" -> folder
+ {
+ 'conditions': {
+ 'host_specs': ['@all'],
+ 'host_tags': []
+ },
+ 'options': {},
+ 'value': ("snmp", "RULESET"),
+ },
+ ],
+ }
+ })
+
+ web.add_folder("folder1")
+
+ web.add_host("mgmt-host", folder="folder1", attributes={
+ "ipaddress": "127.0.0.1",
+ "management_protocol": "snmp",
+ })
+
+ config.load()
+ assert config.has_management_board("mgmt-host")
+ assert config.management_address_of("mgmt-host") == "127.0.0.1"
+ assert config.management_protocol_of("mgmt-host") == "snmp"
+ assert config.management_credentials_of("mgmt-host") ==
"RULESET"
+
+
+def test_mgmt_config_ruleset_overidden_by_explicit_setting(web):
+ web.set_ruleset("management_board_config", {
+ "ruleset": {
+ "": [ # "" -> folder
+ {
+ 'conditions': {
+ 'host_specs': ['@all'],
+ 'host_tags': []
+ },
+ 'options': {},
+ 'value': ("snmp", "RULESET"),
+ },
+ ],
+ }
+ })
+
+ web.add_folder("folder1", attributes={
+ "management_snmp_community": "FOLDER",
+ })
+
+ web.add_host("mgmt-host", folder="folder1", attributes={
+ "ipaddress": "127.0.0.1",
+ "management_protocol": "snmp",
+ })
+
+ config.load()
+ assert config.has_management_board("mgmt-host")
+ assert config.management_address_of("mgmt-host") == "127.0.0.1"
+ assert config.management_protocol_of("mgmt-host") == "snmp"
+ assert config.management_credentials_of("mgmt-host") == "FOLDER"
+
+
+def test_mgmt_config_ruleset_order(web):
+ web.set_ruleset("management_board_config", {
+ "ruleset": {
+ "": [ # "" -> folder
+ {
+ 'conditions': {
+ 'host_specs': ['@all'],
+ 'host_tags': []
+ },
+ 'options': {},
+ 'value': ("snmp", "RULESET1"),
+ },
+ {
+ 'conditions': {
+ 'host_specs': ['@all'],
+ 'host_tags': []
+ },
+ 'options': {},
+ 'value': ("snmp", "RULESET2"),
+ },
+ ],
+ }
+ })
+
+ web.add_folder("folder1")
+
+ web.add_host("mgmt-host", folder="folder1", attributes={
+ "ipaddress": "127.0.0.1",
+ "management_protocol": "snmp",
+ })
+
+ config.load()
+ assert config.has_management_board("mgmt-host")
+ assert config.management_address_of("mgmt-host") == "127.0.0.1"
+ assert config.management_protocol_of("mgmt-host") == "snmp"
+ assert config.management_credentials_of("mgmt-host") ==
"RULESET1"