示例#1
0
def test_kafkastorage_ssl_log_replace_client_key_path(
        mock_create_kafka_consumer, caplog):
    storage.KafkaStorage('test',
                         extra_config={'ssl.key.location': 'location'},
                         ssl=SSL('/ca', '/cert', '/key'))
    assert 'KafkaStorage `ssl.key.location` '\
           'in config replaced with SSL object!' in caplog.messages
def test_when_brocker_unavailable(mock_fun, mock_producer, sample_metrics):
    kafka_storage = storage.KafkaStorage(
        brokers_ips=["whatever because is ignored"], topic='some')
    with pytest.raises(storage.FailedDeliveryException,
                       match="Maximum timeout"):
        kafka_storage.store(sample_metrics)
    kafka_storage.producer.flush.assert_called_once()
示例#3
0
def test_kafkastorage_ssl_replace_client_cert_path(mock_create_kafka_consumer):
    kafka = storage.KafkaStorage(
        'test',
        extra_config={'ssl.certificate.location': 'location'},
        ssl=SSL('/ca', '/cert', '/key'))

    assert kafka.extra_config['ssl.certificate.location'] == '/cert'
示例#4
0
def test_kafkastorage_ssl_log_using_own_cipher_suites(
        mock_create_kafka_consumer, caplog):
    storage.KafkaStorage('test',
                         extra_config={'ssl.cipher.suites': 'ciphers'},
                         ssl=SSL('/ca', '/cert', '/key'))
    assert 'KafkaStorage SSL uses extra config cipher suites!' in caplog.messages
示例#5
0
def test_kafkastorage_ssl_assign_cipher_suites(mock_create_kafka_consumer):
    assert storage.KafkaStorage('test', ssl=SSL('/ca', '/cert', '/key'))\
            .extra_config['ssl.cipher.suites'] == SECURE_CIPHERS
示例#6
0
def test_kafkastorage_ssl_exception_no_both_client_key_cert(
        mock_create_kafka_consumer):
    with pytest.raises(storage.KafkaConsumerInitializationException):
        storage.KafkaStorage('test', ssl=SSL('/ca', '/cert'))
示例#7
0
def test_kafkastorage_ssl_exception_no_ca_cert_path(
        mock_create_kafka_consumer):
    with pytest.raises(storage.KafkaConsumerInitializationException):
        storage.KafkaStorage('test', ssl=SSL(True, '/cert', '/key'))
示例#8
0
def test_kafkastorage_ssl_log_using_own_cipher_suites(mock_create_kafka_consumer, mock_log):
    storage.KafkaStorage(
            'test', extra_config={'ssl.cipher.suites': 'ciphers'}, ssl=SSL('/ca', '/cert', '/key'))
    mock_log.warning.assert_called_once_with('KafkaStorage SSL uses extra config cipher suites!')
示例#9
0
def test_kafkastorage_ssl_log_replace_client_key_path(mock_create_kafka_consumer, mock_log):
    storage.KafkaStorage(
            'test', extra_config={'ssl.key.location': 'location'},
            ssl=SSL('/ca', '/cert', '/key'))
    mock_log.warning.assert_called_once_with('KafkaStorage `ssl.key.location` '
                                             'in config replaced with SSL object!')