Esempio n. 1
0
 def summarizer(self):
     return AgentSummarizerDefault(
         ExitSpec(),
         is_cluster=False,
         agent_min_version=0,
         agent_target_version=None,
         only_from=["deep_space"],
     )
Esempio n. 2
0
 def _make_summarizer(self) -> AgentSummarizerDefault:
     return AgentSummarizerDefault(
         self.exit_spec,
         is_cluster=self.host_config.is_cluster,
         agent_min_version=config.agent_min_version,
         agent_target_version=self.host_config.agent_target_version,
         only_from=self.host_config.only_from,
     )
Esempio n. 3
0
 def summarizer(self, request):
     return AgentSummarizerDefault(
         ExitSpec(),
         is_cluster=False,
         agent_min_version=0,
         agent_target_version=request.param,
         only_from=None,
     )
Esempio n. 4
0
def test_tcpdatasource_restricted_address_mismatch(
    monkeypatch,
    restricted_address_mismatch_state,
    only_from,
    rule,
    res,
):
    # TODO(ml): Not only is this white box testing but all these instantiations
    #           before the summarizer obscure the purpose of the test.  This is
    #           way too complicated.  Test the `AgentSummarizerDefault` directly
    #           in `tests.unit.cmk.core_helpers.test_summarizers` instead.
    hostname = HostName("hostname")

    ts = Scenario().add_host(hostname)
    ts.set_option("agent_config",
                  {"only_from": [(rule, [], [str(hostname)], {})]})

    if restricted_address_mismatch_state is not None:
        ts.set_ruleset(
            "check_mk_exit_status",
            [
                (
                    {
                        "restricted_address_mismatch":
                        restricted_address_mismatch_state,
                    },
                    [],
                    [str(hostname)],
                    {},
                ),
            ],
        )

    ts.apply(monkeypatch)
    source = TCPSource(hostname, "ipaddress")

    summarizer = AgentSummarizerDefault(
        source.exit_spec,
        is_cluster=source.host_config.is_cluster,
        agent_min_version=0,
        agent_target_version=source.host_config.agent_target_version,
        only_from=source.host_config.only_from,
    )

    assert summarizer._check_only_from(only_from) == res
Esempio n. 5
0
def test_tcpdatasource_only_from(mode, monkeypatch, res, reported, rule):
    # TODO(ml): Not only is this white box testing but all these instantiations
    #           before the summarizer obscure the purpose of the test.  This is
    #           way too complicated.  Test the `AgentSummarizerDefault` directly
    #           in `tests.unit.cmk.core_helpers.test_summarizers` instead.
    ts = Scenario().add_host("hostname")
    ts.set_option("agent_config", {"only_from": [rule]} if rule else {})
    config_cache = ts.apply(monkeypatch)

    source = TCPSource("hostname", "ipaddress", mode=mode)
    monkeypatch.setattr(config_cache, "host_extra_conf",
                        lambda host, ruleset: ruleset)

    summarizer = AgentSummarizerDefault(
        source.exit_spec,
        is_cluster=source.host_config.is_cluster,
        agent_min_version=0,
        agent_target_version=source.host_config.agent_target_version,
        only_from=source.host_config.only_from,
    )
    assert summarizer._check_only_from(reported) == res
Esempio n. 6
0
 def test_configure_missmatch(self, mode, state):
     assert (AgentSummarizerDefault(
         ExitSpec(restricted_address_mismatch=state),
         is_cluster=False,
         agent_min_version=0,
         agent_target_version=None,
         only_from=["deep_space"],
     ).summarize_check_mk_section(
         [
             ["onlyfrom:", "somewhere_else"],
         ],
         mode=mode,
     )[0].state == state)
Esempio n. 7
0
 def summarizer(self):
     return AgentSummarizerDefault(ExitSpec())
Esempio n. 8
0
 def _make_summarizer(self) -> AgentSummarizerDefault:
     return AgentSummarizerDefault(self.exit_spec)