mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-06-14 22:17:34 +08:00
Don't allow building modules with the same name as a base module (e.g. platform)
A user managed to build a module called "platform", which stopped dependency resolution from working. This should stop that from happening again.
This commit is contained in:
@@ -568,6 +568,10 @@ def submit_module_build(username, url, mmd, optional_params=None):
|
||||
"""
|
||||
import koji # Placed here to avoid py2/py3 conflicts...
|
||||
|
||||
if mmd.get_name() in conf.base_module_names:
|
||||
raise ValidationError(
|
||||
'You cannot build a module named "{}" since it is a base module'.format(mmd.get_name()))
|
||||
|
||||
raise_if_stream_ambigous = False
|
||||
default_streams = {}
|
||||
if optional_params:
|
||||
|
||||
@@ -1309,6 +1309,26 @@ class TestViews:
|
||||
}
|
||||
assert rv.status_code == 400
|
||||
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
def test_submit_build_with_base_module_name(self, mocked_scm, mocked_get_user):
|
||||
FakeSCM(mocked_scm, 'platform', 'testmodule.yaml',
|
||||
'620ec77321b2ea7b0d67d82992dda3e1d67055b4')
|
||||
|
||||
data = {
|
||||
'branch': 'master',
|
||||
'scmurl': 'https://src.stg.fedoraproject.org/modules/'
|
||||
'platform.git?#68931c90de214d9d13feefbd35246a81b6cb8d49',
|
||||
}
|
||||
rv = self.client.post('/module-build-service/1/module-builds/', data=json.dumps(data))
|
||||
result = json.loads(rv.data)
|
||||
assert result == {
|
||||
'error': 'Bad Request',
|
||||
'status': 400,
|
||||
'message': 'You cannot build a module named "platform" since it is a base module'
|
||||
}
|
||||
assert rv.status_code == 400
|
||||
|
||||
@pytest.mark.parametrize('dep_type', ('buildrequire', 'require'))
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
|
||||
Reference in New Issue
Block a user