Exemplo n.º 1
0
def test_parse_valid(service_config_valid):
    config = ServiceConfig.get_from_dict(service_config_valid)
    assert config.debug
    assert config.deployment == Deployment.prod
    assert config.fas_user == "santa"
    assert config.fas_password == "does-not-exist"
    assert config.keytab_path == "/secrets/fedora.keytab"
    assert config.webhook_secret == "secret"
    assert config.validate_webhooks
    assert config.testing_farm_secret == "granko"
    assert config.testing_farm_api_url == TESTING_FARM_API_URL
    assert config.bugzilla_url == "https://ladybug-zilla"
    assert config.bugzilla_api_key == "ratamahatta"
    assert config.bugz_namespaces == {"^magic/namespace"}
    assert config.bugz_branches == {"^onlythis$"}
    assert config.command_handler_work_dir == "/tmp/sandcastle"
    assert config.admins == {"Dasher", "Dancer", "Vixen", "Comet", "Blitzen"}
    assert config.server_name == "hub.packit.org"
    assert config.gitlab_token_secret == "jwt_secret"
    assert len(config.gitlab_mr_targets_handled) == 3
    assert (MRTarget("redhat/centos-stream/src/.+", "c9s")
            in config.gitlab_mr_targets_handled)
    assert MRTarget("packit-service/src/.+",
                    None) in config.gitlab_mr_targets_handled
    assert MRTarget(None, "rawhide") in config.gitlab_mr_targets_handled
    assert config.enabled_private_namespaces == {
        "gitlab.com/private/namespace",
        "github.com/other-private-namespace",
    }
Exemplo n.º 2
0
def test_parse_optional_values(service_config_valid):
    """When optional values are set, they are correctly parsed"""
    config = ServiceConfig.get_from_dict({
        **service_config_valid, "testing_farm_api_url":
        "https://other.url"
    })
    assert config.testing_farm_api_url == "https://other.url"
Exemplo n.º 3
0
def test_parse_valid(service_config_valid):
    config = ServiceConfig.get_from_dict(service_config_valid)
    assert config.debug
    assert config.deployment == Deployment.prod
    assert config.fas_user == "santa"
    assert config.fas_password == "does-not-exist"
    assert config.keytab_path == "/secrets/fedora.keytab"
    assert config.webhook_secret == "secret"
    assert config.validate_webhooks
    assert config.disable_sentry is False
    assert config.testing_farm_secret == "granko"
    assert config.command_handler_work_dir == "/sandcastle"
    assert config.admins == {"Dasher", "Dancer", "Vixen", "Comet", "Blitzen"}
    assert config.server_name == "hub.packit.org"
Exemplo n.º 4
0
def test_parse_valid(service_config_valid):
    config = ServiceConfig.get_from_dict(service_config_valid)
    assert config.debug
    assert config.deployment == Deployment.prod
    assert config.fas_user == "santa"
    assert config.fas_password == "does-not-exist"
    assert config.keytab_path == "/secrets/fedora.keytab"
    assert config.webhook_secret == "secret"
    assert config.validate_webhooks
    assert config.testing_farm_secret == "granko"
    assert config.bugzilla_url == "https://ladybug-zilla"
    assert config.bugzilla_api_key == "ratamahatta"
    assert config.pr_accepted_labels == {"good-enough", "will-maintain-this"}
    assert config.command_handler_work_dir == "/sandcastle"
    assert config.admins == {"Dasher", "Dancer", "Vixen", "Comet", "Blitzen"}
    assert config.server_name == "hub.packit.org"
Exemplo n.º 5
0
def test_parse_valid(service_config_valid):
    config = ServiceConfig.get_from_dict(service_config_valid)
    assert config.debug
    assert config.deployment == Deployment.prod
    assert config.fas_user == "santa"
    assert config.fas_password == "does-not-exist"
    assert config.keytab_path == "/secrets/fedora.keytab"
    assert config.webhook_secret == "secret"
    assert config.validate_webhooks
    assert config.testing_farm_secret == "granko"
    assert config.testing_farm_api_url == TESTING_FARM_API_URL
    assert config.bugzilla_url == "https://ladybug-zilla"
    assert config.bugzilla_api_key == "ratamahatta"
    assert config.pr_accepted_labels == {"good-enough", "will-maintain-this"}
    assert config.command_handler_work_dir == "/sandcastle"
    assert config.admins == {"Dasher", "Dancer", "Vixen", "Comet", "Blitzen"}
    assert config.server_name == "hub.packit.org"
    assert config.gitlab_token_secret == "jwt_secret"
    assert config.gitlab_webhook_tokens == {"token1", "token2", "token3", "aged"}
    assert config.enabled_private_namespaces == {
        "gitlab.com/private/namespace",
        "github.com/other-private-namespace",
    }
Exemplo n.º 6
0
def test_parse_missing(service_config_missing):
    with pytest.raises(ValidationError):
        ServiceConfig.get_from_dict(service_config_missing)
Exemplo n.º 7
0
def test_parse_invalid(service_config_invalid):
    with pytest.raises(ValidationError):
        ServiceConfig.get_from_dict(service_config_invalid)
Exemplo n.º 8
0
    with pytest.raises(ValidationError):
        ServiceConfig.get_from_dict(service_config_invalid)


@pytest.fixture()
def service_config_missing():
    return {}


def test_parse_missing(service_config_missing):
    with pytest.raises(ValidationError):
        ServiceConfig.get_from_dict(service_config_missing)


@pytest.mark.parametrize("sc", (
    (ServiceConfig.get_from_dict({"deployment": "stg"})),
    (ServiceConfig()),
))
def test_config_opts(sc):
    """ test that ServiceConfig knows all the options """
    assert sc.server_name is not None
    assert sc.deployment == Deployment.stg
    assert sc.admins is not None
    assert sc.command_handler is not None
    assert sc.command_handler_work_dir is not None
    assert sc.command_handler_pvc_env_var is not None
    assert sc.command_handler_image_reference is not None
    assert sc.command_handler_k8s_namespace is not None
    assert sc.fas_password is not None
    assert sc.testing_farm_secret is not None
    assert sc.github_requests_log_path is not None
Exemplo n.º 9
0
def test_parse_missing(service_config_missing):
    with pytest.raises(PackitInvalidConfigException):
        ServiceConfig.get_from_dict(service_config_missing)
Exemplo n.º 10
0
def test_parse_valid(service_config_valid):
    config = ServiceConfig.get_from_dict(service_config_valid)
    assert config.deployment == Deployment("prod")