Ejemplo n.º 1
0
def test_host_labels_ps_match():
    section = (
        1,
        [
            (
                ps.PsInfo.from_raw("(root,4056,1512,0.0/52-04:56:05,5689)"),
                ["/usr/lib/ssh/sshd"],
            ),
        ],
    )
    params = [
        {
            "default_params": {},
            "descr": "SSH",
            "match": "~.*ssh?",
            "label": {
                "marco": "polo"
            },
        },
        {},
    ]
    assert list(ps.host_labels_ps(params,
                                  section)) == [  # type: ignore[arg-type]
                                      HostLabel("marco", "polo")
                                  ]
Ejemplo n.º 2
0
def test_host_labels_ps_match():
    section = (
        1,
        [
            (
                ps.ps_info("(root,4056,1512,0.0/52-04:56:05,5689)".split()
                           ),  # type: ignore[call-arg]
                ["/usr/lib/ssh/sshd"],
            ),
        ])
    params = [
        {
            "default_params": {},
            "descr": "SSH",
            "match": "~.*ssh?",
            "label": {
                'marco': 'polo'
            },
        },
        {},
    ]
    assert list(ps.host_labels_ps(params,
                                  section)) == [  # type: ignore[arg-type]
                                      HostLabel('marco', 'polo')
                                  ]
Ejemplo n.º 3
0
def test_host_labels_ps_no_match_pattern():
    section = (
        1,
        [
            (
                ps.ps_info("(root,4056,1512,0.0/52-04:56:05,5689)".split()
                           ),  # type: ignore[call-arg]
                ["/usr/lib/ssh/sshd"],
            ),
        ])
    params = [
        Parameters({
            "default_params": {},
            "descr": "SSH",
            "match": "~wat?",
            "label": DiscoveredHostLabels(HostLabel(u'marco', u'polo')),
        }),
        Parameters({}),
    ]
    assert list(ps.host_labels_ps(params, section)) == []
Ejemplo n.º 4
0
def test_host_labels_ps_no_match_pattern():
    section = (1, [
        (
            ps.PsInfo.from_raw("(root,4056,1512,0.0/52-04:56:05,5689)"),
            ["/usr/lib/ssh/sshd"],
        ),
    ])
    params = [
        {
            "default_params": {},
            "descr": "SSH",
            "match": "~wat?",
            "label": {
                'marco': 'polo'
            },
        },
        {},
    ]
    assert list(ps.host_labels_ps(params,
                                  section)) == []  # type: ignore[arg-type]
Ejemplo n.º 5
0
def test_host_labels_ps_no_match_attr():
    section = (
        1,
        [
            (
                ps.ps_info("(root,4056,1512,0.0/52-04:56:05,5689)".split()
                           ),  # type: ignore[call-arg]
                ["/usr/lib/ssh/sshd"],
            ),
        ])
    params = [
        Parameters({
            "default_params": {},
            "descr": "SSH",
            "match": "~.*ssh?",
            "user": "******",
            "label": {
                'marco': 'polo'
            },
        }),
        Parameters({}),
    ]
    assert list(ps.host_labels_ps(params, section)) == []