Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Jul 5, 2024
1 parent 6eb12fa commit 424a106
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dojo/api_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3314,7 +3314,7 @@ class AnnouncementViewSet(


class NotificationWebhooksViewSet(
PrefetchDojoModelViewSet
PrefetchDojoModelViewSet,
):
serializer_class = serializers.NotificationWebhooksSerializer
queryset = Notification_Webhooks.objects.all()
Expand Down
8 changes: 4 additions & 4 deletions dojo/notifications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ class NotificationWebhooksView(View):

def check_webhooks_enabled(self):
if not get_system_setting('enable_webhooks_notifications'):
raise Http404()
raise Http404

def check_user_permissions(self, request: HttpRequest):
if not request.user.is_superuser:
raise PermissionDenied()
raise PermissionDenied
# TODO finished access for other users
# if not user_has_configuration_permission(request.user, self.permission):
# raise PermissionDenied()
Expand Down Expand Up @@ -288,7 +288,7 @@ def get_initial_context(self, request: HttpRequest, nwh: Notification_Webhooks):
'name': 'Edit Notification Webhook',
'user': request.user,
'form': self.get_form(request, instance=nwh),
'nwh': nwh
'nwh': nwh,
}

def process_form(self, request: HttpRequest, nwh: Notification_Webhooks, context: dict):
Expand Down Expand Up @@ -383,7 +383,7 @@ def get_form(
def get_initial_context(self, request: HttpRequest, nwh: Notification_Webhooks):
return {
'form': self.get_form(request, instance=nwh),
'nwh': nwh
'nwh': nwh,
}

def process_form(self, request: HttpRequest, nwh: Notification_Webhooks, context: dict):
Expand Down
18 changes: 9 additions & 9 deletions unittests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def test_headers(self, mock):
'X-DefectDojo-Event': 'product_type_added',
'X-DefectDojo-Instance': 'http://localhost:8080',
'Accept': 'application/json',
'Auth': 'Token xxx'
'Auth': 'Token xxx',
})

@patch('requests.request')
Expand Down Expand Up @@ -619,16 +619,16 @@ def test_events_messages(self, mock):
notifications_helper.notify_scan_added(test,
updated_count=4,
new_findings=[
Finding.objects.create(test=test, title='New Finding', severity='Critical')
Finding.objects.create(test=test, title='New Finding', severity='Critical'),
],
findings_mitigated=[
Finding.objects.create(test=test, title='Mitigated Finding', severity='Medium')
Finding.objects.create(test=test, title='Mitigated Finding', severity='Medium'),
],
findings_reactivated=[
Finding.objects.create(test=test, title='Reactivated Finding', severity='Low')
Finding.objects.create(test=test, title='Reactivated Finding', severity='Low'),
],
findings_untouched=[
Finding.objects.create(test=test, title='Untouched Finding', severity='Info')
Finding.objects.create(test=test, title='Untouched Finding', severity='Info'),
],
)
self.assertEqual(mock.call_args.kwargs['headers']['X-DefectDojo-Event'], 'scan_added')
Expand All @@ -638,24 +638,24 @@ def test_events_messages(self, mock):
'id': 232,
'title': 'New Finding',
'severity': 'Critical',
'url': 'http://localhost:8080/finding/232'
'url': 'http://localhost:8080/finding/232',
}],
'mitigated': [{
'id': 233,
'title': 'Mitigated Finding',
'severity': 'Medium',
'url': 'http://localhost:8080/finding/233'
'url': 'http://localhost:8080/finding/233',
}],
'reactivated': [{
'id': 234,
'title': 'Reactivated Finding',
'severity': 'Low',
'url': 'http://localhost:8080/finding/234'
'url': 'http://localhost:8080/finding/234',
}],
'untouched': [{
'id': 235,
'title': 'Untouched Finding',
'severity': 'Info',
'url': 'http://localhost:8080/finding/235'
'url': 'http://localhost:8080/finding/235',
}],
})

0 comments on commit 424a106

Please sign in to comment.