mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-08 05:08:45 +08:00
Skip prefix validation for modules in allowed_privileged_module_names and base_module_names
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
This commit is contained in:
@@ -230,6 +230,16 @@ def validate_koji_tag(tag_arg_names, pre="", post="-", dict_key="name"):
|
||||
def wrapper(*args, **kwargs):
|
||||
call_args = inspect.getcallargs(function, *args, **kwargs)
|
||||
|
||||
# if module name is in allowed_privileged_module_names or base_module_names lists
|
||||
# we don't have to validate it since they could use an arbitrary Koji tag
|
||||
try:
|
||||
if call_args['self'].module_str in \
|
||||
conf.allowed_privileged_module_names + conf.base_module_names:
|
||||
# skip validation
|
||||
return function(*args, **kwargs)
|
||||
except (AttributeError, KeyError):
|
||||
pass
|
||||
|
||||
for tag_arg_name in tag_arg_names:
|
||||
err_subject = "Koji tag validation:"
|
||||
|
||||
|
||||
@@ -759,6 +759,20 @@ class TestUtils:
|
||||
validate_koji_tag_is_None(None)
|
||||
assert str(cm.value).endswith(" No value provided.") is True
|
||||
|
||||
@patch(
|
||||
"module_build_service.config.Config.allowed_privileged_module_names",
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value=["testmodule"],
|
||||
)
|
||||
def test_validate_koji_tag_previleged_module_name(self, conf_apmn):
|
||||
@module_build_service.utils.validate_koji_tag("tag_arg")
|
||||
def validate_koji_tag_priv_mod_name(self, tag_arg):
|
||||
pass
|
||||
|
||||
builder = mock.MagicMock()
|
||||
builder.module_str = 'testmodule'
|
||||
validate_koji_tag_priv_mod_name(builder, "abc")
|
||||
|
||||
@patch("module_build_service.scm.SCM")
|
||||
def test_record_component_builds_duplicate_components(self, mocked_scm, db_session):
|
||||
clean_database()
|
||||
|
||||
Reference in New Issue
Block a user