예제 #1
0
def fixture_symlink_push_host(
    tmp_path: Path,
    uuid: UUID,
) -> None:
    source = site_context.agent_output_dir() / str(uuid)
    (target_dir := tmp_path / "hostname").mkdir()
    source.symlink_to(target_dir)
예제 #2
0
파일: utils.py 프로젝트: LinuxHaus/checkmk
    def __init__(self, uuid: UUID):
        self._source_path = agent_output_dir() / str(uuid)

        self._registered = self.source_path.is_symlink()
        target_path = self._get_target_path() if self.registered else None

        self._hostname = target_path.name if target_path else None
        self._host_type = self._get_host_type(target_path)
예제 #3
0
def test_pull_host_registered(tmp_path: Path, uuid: UUID) -> None:
    source = site_context.agent_output_dir() / str(uuid)
    target_dir = tmp_path / "hostname"
    source.symlink_to(target_dir)

    host = Host(uuid)

    assert host.registered is True
    assert host.hostname == "hostname"
    assert host.host_type is HostTypeEnum.PULL
    assert host.source_path == source
예제 #4
0
def test_agent_data_pull_host(
    tmp_path: Path,
    client: TestClient,
    uuid: UUID,
    agent_data_headers: Mapping[str, str],
    compressed_agent_data: io.BytesIO,
) -> None:
    source = site_context.agent_output_dir() / str(uuid)
    source.symlink_to(tmp_path / "hostname")

    response = client.post(
        f"/agent_data/{uuid}",
        headers=typeshed_issue_7724(agent_data_headers),
        files={"monitoring_data": (
            "filename",
            compressed_agent_data,
        )},
    )
    assert response.status_code == 403
    assert response.json() == {"detail": "Host is not a push host"}
예제 #5
0
def test_registration_status_pull_host(
    tmp_path: Path,
    client: TestClient,
    uuid: UUID,
    registration_status_headers: Mapping[str, str],
) -> None:
    source = site_context.agent_output_dir() / str(uuid)
    target_dir = tmp_path / "hostname"
    source.symlink_to(target_dir)

    response = client.get(
        f"/registration_status/{uuid}",
        headers=typeshed_issue_7724(registration_status_headers),
    )

    assert response.status_code == 200
    assert response.json() == {
        "hostname": "hostname",
        "status": None,
        "type": HostTypeEnum.PULL.value,
        "message": "Host registered",
    }
예제 #6
0
def setup_site_context() -> None:
    site_context.agent_output_dir().mkdir(parents=True)
    site_context.r4r_dir().mkdir(parents=True)
    site_context.log_path().parent.mkdir(parents=True)