Example #1
0
def test_config_port_wrong_number():
    """Reject a config with a port out of the valid range."""
    for port in [0, 70000]:
        config = {'protocol': 'http', 'port': port, 'host': 'localhost'}
        assert validate(config) == (False,
                                    'Port configuration for nginx_connection '
                                    'is not a valid port number.')
def test_config_port_wrong_number():
    """Reject a config with a port out of the valid range."""
    for port in [0, 70000]:
        config = {'protocol': 'http', 'port': port, 'host': 'localhost'}
        assert validate(config) == (
            False, 'Port configuration for nginx_connection '
                   'is not a valid port number.')
def test_config_host_wrong():
    """Reject a config with a host that cannot be resolved."""
    config = {'protocol': 'http', 'port': 80, 'host': 'foohost'}
    assert validate(config) == (
        False, 'Host configuration for nginx_connection cannot be resolved.')
def test_config_port_not_a_number():
    """Reject a config with a port that is not a number."""
    config = {'protocol': 'http', 'port': 'foo', 'host': 'localhost'}
    assert validate(config) == (
        False, 'Port configuration for nginx_connections is not a number.')
def test_config_wrong_protocol():
    """Reject a config a protocol other than http or https."""
    config = {'protocol': 'sftp', 'port': 80, 'host': 'localhost'}
    assert validate(config) == (False, "Protocol configuration for "
                                       "nginx_connections should be in "
                                       "['http', 'https'].")
def test_config_not_dict():
    """Reject a config that is not a dict."""
    config = ['list', 'of', 'things']
    assert validate(config) == (False, 'Configuration for nginx_connections '
                                       'beacon must be a dictionary.')
def test_valid_config():
    """Verify a correct config object."""
    config = {'protocol': 'http', 'port': 80, 'host': 'localhost'}
    assert validate(config) == (True, 'Valid beacon configuration.')
Example #8
0
def test_config_host_wrong():
    """Reject a config with a host that cannot be resolved."""
    config = {'protocol': 'http', 'port': 80, 'host': 'foohost'}
    assert validate(config) == (
        False, 'Host configuration for nginx_connection cannot be resolved.')
Example #9
0
def test_config_port_not_a_number():
    """Reject a config with a port that is not a number."""
    config = {'protocol': 'http', 'port': 'foo', 'host': 'localhost'}
    assert validate(config) == (
        False, 'Port configuration for nginx_connections is not a number.')
Example #10
0
def test_config_wrong_protocol():
    """Reject a config a protocol other than http or https."""
    config = {'protocol': 'sftp', 'port': 80, 'host': 'localhost'}
    assert validate(config) == (False, "Protocol configuration for "
                                "nginx_connections should be in "
                                "['http', 'https'].")
Example #11
0
def test_config_not_dict():
    """Reject a config that is not a dict."""
    config = ['list', 'of', 'things']
    assert validate(config) == (False, 'Configuration for nginx_connections '
                                'beacon must be a dictionary.')
Example #12
0
def test_valid_config():
    """Verify a correct config object."""
    config = {'protocol': 'http', 'port': 80, 'host': 'localhost'}
    assert validate(config) == (True, 'Valid beacon configuration.')