コード例 #1
0
def test_syslog_to_paasta_log_no_container(
    mock_lookup_service_instance_by_ip, mock_log
):
    syslog_data = fake_syslog_data("my-hostname", SRC="1.2.3.4")
    mock_lookup_service_instance_by_ip.return_value = (None, None)
    firewall_logging.syslog_to_paasta_log(syslog_data, "my-cluster")
    assert mock_log.mock_calls == []
コード例 #2
0
def test_syslog_to_paasta_log(mock_lookup_service_instance_by_ip, mock_log):
    syslog_data = fake_syslog_data('my-hostname', SRC='1.2.3.4')
    mock_lookup_service_instance_by_ip.return_value = ('myservice',
                                                       'myinstance')

    firewall_logging.syslog_to_paasta_log(syslog_data, 'my-cluster')

    assert mock_log.mock_calls == [
        mock.call(service='myservice',
                  component='security',
                  level='debug',
                  cluster='my-cluster',
                  instance='myinstance',
                  line='my-hostname: my-prefix IN=docker0 SRC=1.2.3.4')
    ]
コード例 #3
0
def test_syslog_to_paasta_log(mock_lookup_service_instance_by_ip, mock_log):
    syslog_data = fake_syslog_data("my-hostname", SRC="1.2.3.4")
    mock_lookup_service_instance_by_ip.return_value = ("myservice", "myinstance")

    firewall_logging.syslog_to_paasta_log(syslog_data, "my-cluster")

    assert mock_log.mock_calls == [
        mock.call(
            service="myservice",
            component="security",
            level="debug",
            cluster="my-cluster",
            instance="myinstance",
            line="my-hostname: my-prefix IN=docker0 SRC=1.2.3.4",
        )
    ]
コード例 #4
0
def test_syslog_to_paasta_log_bad_message(
    mock_lookup_service_instance_by_ip, syslog_data, mock_log
):
    firewall_logging.syslog_to_paasta_log(syslog_data.encode(), "my-cluster")
    assert mock_lookup_service_instance_by_ip.mock_calls == []
    assert mock_log.mock_calls == []