예제 #1
0
def test_smtp_connection_remote_smtp_wrong_credentials(configuration):
    configuration["SMTP"]["PASSWORD"] = "******"
    with pytest.raises(
            ConfigurationException,
            match=r"SMTP authentication failed with user",
    ):
        validate(configuration, validate_remote=True)
예제 #2
0
def test_ldap_connection_remote_ldap_unreachable(configuration):
    configuration["LDAP"]["URI"] = "ldap://invalid-ldap.com"
    with pytest.raises(
            ConfigurationException,
            match=r"Could not connect to the LDAP server",
    ):
        validate(configuration, validate_remote=True)
예제 #3
0
def test_smtp_connection_remote_smtp_unreachable(configuration):
    configuration["SMTP"]["HOST"] = "smtp://invalid-smtp.com"
    with pytest.raises(
            ConfigurationException,
            match=r"Could not connect to the SMTP server",
    ):
        validate(configuration, validate_remote=True)
예제 #4
0
def test_ldap_connection_remote_ldap_wrong_credentials(configuration):
    configuration["LDAP"]["BIND_PW"] = "invalid-password"
    with pytest.raises(
            ConfigurationException,
            match=r"LDAP authentication failed with user",
    ):
        validate(configuration, validate_remote=True)
예제 #5
0
def test_no_public_key(configuration):
    configuration["JWT"]["PUBLIC_KEY"] = "invalid-path"
    with pytest.raises(
            ConfigurationException,
            match=r"Public key does not exist",
    ):
        validate(configuration)
예제 #6
0
def test_no_private_key(configuration):
    configuration["JWT"]["PRIVATE_KEY"] = "invalid-path"
    with pytest.raises(
            ConfigurationException,
            match=r"Private key does not exist",
    ):
        validate(configuration)
예제 #7
0
def check():
    """
    Check the configuration file.
    """
    from canaille.configuration import validate, ConfigurationException

    try:
        validate(current_app.config, validate_remote=True)
    except ConfigurationException as exc:
        print(exc)
        sys.exit(1)
예제 #8
0
def test_ldap_cannot_create_groups(configuration):
    from canaille.models import Group

    def fake_init(*args, **kwarg):
        raise ldap.INSUFFICIENT_ACCESS

    with mock.patch.object(Group, "__init__", fake_init):
        with pytest.raises(
                ConfigurationException,
                match=r"cannot create groups at",
        ):
            validate(configuration, validate_remote=True)
예제 #9
0
def test_invalid_theme(configuration):
    validate(configuration, validate_remote=False)

    with pytest.raises(
            ConfigurationException,
            match=r"Cannot find theme",
    ):
        configuration["THEME"] = "invalid"
        validate(configuration, validate_remote=False)

    with pytest.raises(
            ConfigurationException,
            match=r"Cannot find theme",
    ):
        configuration["THEME"] = "/path/to/invalid"
        validate(configuration, validate_remote=False)
예제 #10
0
def test_ldap_connection_remote(configuration):
    validate(configuration, validate_remote=True)
예제 #11
0
def test_ldap_connection_no_remote(configuration):
    validate(configuration)