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_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'
def test_zookeeper_pass_ssl_cert_as_string(mock_kazoo_client): ZookeeperDatabase(['https://127.0.0.1:2181', 'https://127.0.0.2:2181'], 'zk_namespace', ssl=SSL(server_verify='/path/to/sever_cert'))
def test_zookeeper_raise_exception_when_invalid_ssl(mock_kazoo_client): with pytest.raises(ValidationError): ZookeeperDatabase(['https://127.0.0.1:2181', 'https://127.0.0.2:2181'], 'zk_namespace', ssl=SSL(server_verify=123))
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
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
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'))
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'))
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!')
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!')