Esempio n. 1
0
def test_get_ssl_domain_files_missing(mock_exists, cert_exists, key_exists, ca_exists, app):
    if mock_exists and cert_exists and key_exists:
        # Skip the case when all are set
        return

    mock_exists.side_effect = [cert_exists, key_exists, ca_exists]

    ssl_domain = messaging._get_ssl_domain()

    assert ssl_domain is None
Esempio n. 2
0
def test_get_ssl_domain_cert_config_not_set(mock_exists, missing_key, app):
    mock_exists.return_value = True
    app.config.update({
        'IIB_MESSAGING_CERT': '/etc/iib/messaging.crt',
        'IIB_MESSAGING_KEY': '/etc/iib/messaging.key',
        'IIB_MESSAGING_CA': '/etc/iib/messaging.ca',
    })
    app.config.pop(missing_key)

    ssl_domain = messaging._get_ssl_domain()

    assert ssl_domain is None
Esempio n. 3
0
def test_get_ssl_domain(mock_ssldomain, mock_exists, app):
    mock_exists.return_value = True

    ssl_domain = messaging._get_ssl_domain()

    assert ssl_domain is mock_ssldomain.return_value
    assert mock_exists.call_count == 3
    mock_ssldomain.return_value.set_credentials.assert_called_once_with(
        '/etc/iib/messaging.crt', '/etc/iib/messaging.key', None)
    mock_ssldomain.return_value.set_trusted_ca_db.assert_called_once_with(
        '/etc/iib/messaging-ca.crt')
    mock_ssldomain.return_value.set_peer_authentication.assert_called_once_with(
        proton.SSLDomain.VERIFY_PEER)