From 7c7552a1281ddc2ab0448c3000373d947c23a430 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Jul 11 2020 13:41:33 +0000 Subject: Fix users check against packagers group Signed-off-by: Mattia Verga --- diff --git a/fedscm_admin/bugzilla.py b/fedscm_admin/bugzilla.py index 5b6fde4..b8000c9 100644 --- a/fedscm_admin/bugzilla.py +++ b/fedscm_admin/bugzilla.py @@ -161,16 +161,26 @@ class BugzillaClient(object): if flag.get('status') == '+': flag_set = True if check_fas and require_auth: - fas_user = self.get_fas_user_by_bz_email(bug.creator) - if not fas_user: + fas_reviewer = self.get_fas_user_by_bz_email(bug.assigned_to) + if not fas_reviewer: raise ValidationError( 'The email address "{0}" of the Bugzilla reviewer ' 'is not tied to a user in FAS. Group membership ' - 'can\'t be validated.'.format(flag['setter'])) - if not FAS_CLIENT.user_member_of(fas_user, 'packager'): + 'can\'t be validated.'.format(bug.assigned_to)) + if not FAS_CLIENT.user_member_of(fas_reviewer, 'packager'): raise ValidationError('The Bugzilla bug\'s review ' 'is approved by a user that is ' 'not a packager') + fas_submitter = self.get_fas_user_by_bz_email(bug.creator) + if not fas_submitter: + raise ValidationError( + 'The email address "{0}" of the Bugzilla submitter ' + 'is not tied to a user in FAS. Group membership ' + 'can\'t be validated.'.format(bug.creator)) + if not FAS_CLIENT.user_member_of(fas_submitter, 'packager'): + raise ValidationError('The Bugzilla bug\'s review ' + 'is submitted by a user that is ' + 'not a packager') # Setter will be an empty string and emails will not be shown # if the user is not logged in. This is why we check for # authentication here.