Esempio n. 1
0
def test_parse_line():
    """With a standard line should parse the hostnames."""
    assert KnownHostsQuery.parse_known_hosts_line(
        'host1 ecdsa-sha2-nistp256 AAAA...=') == ({'host1'}, set())
Esempio n. 2
0
def test_parse_line_unknown_marker():
    """Lines with an unknown marker should raise KnownHostsLineError."""
    with pytest.raises(KnownHostsLineError, match='unknown marker'):
        KnownHostsQuery.parse_known_hosts_line(
            '@marker host1 ecdsa-sha2-nistp256 AAAA...=')
Esempio n. 3
0
def test_parse_line_ca():
    """Lines with a cert-authority marker should parse the hostnames."""
    expected = ({'host1'}, set())
    assert KnownHostsQuery.parse_known_hosts_line(
        '@cert-authority host1 ecdsa-sha2-nistp256 AAAA...=') == expected
Esempio n. 4
0
def test_parse_line_revoked():
    """Lines with a revoked marker should raise KnownHostsSkippedLineError."""
    with pytest.raises(KnownHostsSkippedLineError, match='revoked'):
        KnownHostsQuery.parse_known_hosts_line(
            '@revoked host1 ecdsa-sha2-nistp256 AAAA...=')
Esempio n. 5
0
def test_parse_line_no_fields_mark():
    """Lines with a marker but without enough fields should raise KnownHostsLineError."""
    with pytest.raises(KnownHostsLineError, match='not enough fields'):
        KnownHostsQuery.parse_known_hosts_line('@marker host1 ssh-rsa')
Esempio n. 6
0
def test_parse_line_hashed():
    """Hashed lines should raise KnownHostsSkippedLineError."""
    with pytest.raises(KnownHostsSkippedLineError, match='hashed'):
        KnownHostsQuery.parse_known_hosts_line(
            '|1|HaSh=|HaSh= ecdsa-sha2-nistp256 AAAA...=')
Esempio n. 7
0
def test_parse_line_comment():
    """Comment lines should raise KnownHostsSkippedLineError."""
    with pytest.raises(KnownHostsSkippedLineError, match='comment'):
        KnownHostsQuery.parse_known_hosts_line('# comment')
Esempio n. 8
0
def test_parse_line_empty():
    """Empty lines should raise KnownHostsSkippedLineError."""
    with pytest.raises(KnownHostsSkippedLineError, match='empty line'):
        KnownHostsQuery.parse_known_hosts_line('')
    with pytest.raises(KnownHostsSkippedLineError, match='empty line'):
        KnownHostsQuery.parse_known_hosts_line('\n')