#296 Check for 'has_hightouch_bug' in whitelist.
Merged 9 months ago by jkaluza. Opened 9 months ago by jkaluza.
jkaluza/freshmaker hightouch-v2  into  master

@@ -98,6 +98,7 @@ 

                  advisory_security_impact=event.advisory.security_impact,

                  advisory_highest_cve_severity=event.advisory.highest_cve_severity,

                  advisory_product_short_name=event.advisory.product_short_name,

+                 advisory_has_hightouch_bug=event.advisory.has_hightouch_bug,

                  dry_run=self.dry_run):

              msg = ("Errata advisory {0} is not allowed by internal policy "

                     "to trigger rebuilds.".format(event.advisory.errata_id))

@@ -647,6 +648,7 @@ 

                  advisory_security_impact=self.event.advisory.security_impact,

                  advisory_highest_cve_severity=self.event.advisory.highest_cve_severity,

                  advisory_product_short_name=self.event.advisory.product_short_name,

+                 advisory_has_hightouch_bug=self.event.advisory.has_hightouch_bug,

                  published=True, dry_run=self.dry_run):

              published = True

              release_category = "Generally Available"

@@ -265,6 +265,35 @@ 

  

      @patch.object(freshmaker.conf, 'handler_build_whitelist', new={

          'ErrataAdvisoryRPMsSignedHandler': {

+             'image': {

+                 'advisory_has_hightouch_bug': True,

+             }

+         }

+     })

+     @patch.object(freshmaker.conf, 'dry_run', new=True)

+     def test_allow_build_has_hightouch_bug(self):

+         compose_4 = Compose(odcs_compose_id=4)

+         db.session.add(compose_4)

+         db.session.commit()

+ 

+         for has_hightouch_bug in [False, True]:

+             self.rhba_event.advisory.has_hightouch_bug = has_hightouch_bug

+             self.mock_find_images_to_rebuild.return_value = [[]]

+             handler = ErrataAdvisoryRPMsSignedHandler()

+             handler.handle(self.rhba_event)

+ 

+             db_event = Event.get(db.session, message_id='123')

+             self.assertEqual(db_event.state, EventState.SKIPPED.value)

+             if not has_hightouch_bug:

+                 self.assertTrue(db_event.state_reason.endswith(

+                     "is not allowed by internal policy to trigger rebuilds."))

+             else:

+                 self.assertEqual(

+                     db_event.state_reason,

+                     "No container images to rebuild for advisory 'RHBA-2017'")

+ 

+     @patch.object(freshmaker.conf, 'handler_build_whitelist', new={

+         'ErrataAdvisoryRPMsSignedHandler': {

              'image': {'advisory_name': 'RHBA-2017'}

          }

      })

We have implemented the ErrataAdvisory.has_hightouch_bug some time ago, but it seems we have never added it to allow_build(...) method call which is responsible for checking the whitelist/blacklist. It was therefore not possible to use the has_hightouch_bug flag in whitelist/blacklist.

This PR adds it to allow_build(...) and we can now use the advisory_has_hightouch_bug in whitelist/blacklist.

Pull-Request has been merged by jkaluza

9 months ago