#537 Revive DIST_GIT_BASE_URL
Merged 4 years ago by lholecek. Opened 4 years ago by vmaljulin.
vmaljulin/greenwave FACTORY-5869  into  master

@@ -57,6 +57,11 @@ 

      log.debug("config: Loading subject types from %r", subject_types_dir)

      app.config['subject_types'] = load_subject_types(subject_types_dir)

  

+     if app.config.get('DIST_GIT_URL_TEMPLATE') and app.config.get('DIST_GIT_BASE_URL'):

+         app.config['DIST_GIT_URL_TEMPLATE'] = app.config['DIST_GIT_URL_TEMPLATE'].replace(

+             '{DIST_GIT_BASE_URL}', app.config['DIST_GIT_BASE_URL']

+         )

+ 

      if not _can_use_remote_rule(app.config) and _has_remote_rule(app.config['policies']):

          raise RuntimeError(

              'If you want to apply a RemoteRule, you must have "KOJI_BASE_URL" and '

@@ -38,6 +38,36 @@ 

          create_app(config)

  

  

+ @mock.patch('greenwave.policies.load_policies')

+ def test_remote_rules_base_url(mock_load_policies):

+     """

+     The application shouldn't start if RemoteRule is in policy configuration

+     but if cannot be used because dist-git or koji URL is not configured.

+     """

+ 

+     policies = Policy.safe_load_all(dedent("""

+         --- !Policy

+         id: test_policy

+         product_versions: [fedora-rawhide]

+         decision_context: another_test_context

+         subject_type: koji_build

+         rules:

+           - !RemoteRule {}

+     """))

+     mock_load_policies.return_value = policies

+ 

+     config = TestingConfig()

+     config.DIST_GIT_BASE_URL = 'http://localhost.localdomain/'

+     config.DIST_GIT_URL_TEMPLATE = '{DIST_GIT_BASE_URL}{other_params}/blablabla/gating.yaml'

+     config.REMOTE_RULE_POLICIES = {}

+ 

+     app = create_app(config)

+ 

+     assert app.config['DIST_GIT_URL_TEMPLATE'] == (

+         'http://localhost.localdomain/{other_params}/blablabla/gating.yaml'

+     )

+ 

+ 

  def test_can_use_remote_rule_http_fallback():

      """ Test that _can_use_remote_rule verifies the configuration properly if HTTP is used. """

      config = {

JIRA: FACTORY-5869

Signed-off-by: Valerij Maljulin vmaljuli@redhat.com

rebased onto 9460271

4 years ago

Pull-Request has been merged by lholecek

4 years ago