Exemplo n.º 1
0
def test_attribute_defaults(monkeypatch):
    ipaddress = "1.2.3.4"
    hostname = HostName("testhost")
    Scenario().add_host(hostname).apply(monkeypatch)

    source = TCPSource(hostname, ipaddress)
    monkeypatch.setattr(source, "file_cache_base_path", Path("/my/path/"))
    assert source.fetcher_configuration == {
        "file_cache": {
            "hostname": "testhost",
            "disabled": False,
            "max_age": MaxAge.none(),
            "base_path": "/my/path",
            "simulation": False,
            "use_outdated": False,
        },
        "family": socket.AF_INET,
        "address": (ipaddress, 6556),
        "host_name": str(hostname),
        "timeout": 5.0,
        "encryption_settings": {
            "use_realtime": "enforce",
            "use_regular": "disable",
        },
        "use_only_cache": False,
    }
    assert source.description == "TCP: %s:%s" % (ipaddress, 6556)
    assert source.id == "agent"
Exemplo n.º 2
0
 def file_cache(self) -> DefaultAgentFileCache:
     return DefaultAgentFileCache(
         HostName("hostname"),
         base_path=Path(os.devnull),
         max_age=MaxAge.none(),
         disabled=True,
         use_outdated=True,
         simulation=False,
     )
Exemplo n.º 3
0
 def file_cache(self, request) -> FileCache:
     return request.param(
         HostName("hostname"),
         base_path=Path(os.devnull),
         max_age=MaxAge.none(),
         disabled=True,
         use_outdated=False,
         simulation=True,
     )
Exemplo n.º 4
0
 def file_cache(self):
     return StubFileCache(
         "hostname",
         base_path=Path(os.devnull),
         max_age=MaxAge.none(),
         disabled=True,
         use_outdated=True,
         simulation=False,
     )
Exemplo n.º 5
0
 def file_cache(self) -> SNMPFileCache:
     return SNMPFileCache(
         HostName("hostname"),
         base_path=Path(os.devnull),
         max_age=MaxAge.none(),
         disabled=True,
         use_outdated=True,
         simulation=True,
         use_only_cache=True,
     )
Exemplo n.º 6
0
 def test_fetching_without_cache_raises_in_non_checking_mode(self) -> None:
     with TCPFetcher(
             StubFileCache(
                 HostName("hostname"),
                 base_path=Path(os.devnull),
                 max_age=MaxAge.none(),
                 disabled=False,
                 use_outdated=True,
                 simulation=False,
                 use_only_cache=False,
             ),
             family=socket.AF_INET,
             address=("127.0.0.1", 6556),
             host_name=HostName("irrelevant_for_this_test"),
             timeout=0.1,
             encryption_settings={"use_regular": "allow"},
     ) as fetcher:
         for mode in Mode:
             if mode is Mode.CHECKING:
                 continue
             fetched = fetcher.fetch(mode)
             assert isinstance(fetched.error, MKFetcherError)