Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@permission_required('testapp.delete_book', fn=objectgetter(Book, 'book_id'))
def delete_book(request, book_id):
return HttpResponse('OK')
class BookDeleteView(LoginRequiredMixin, PermissionRequiredMixin, BookMixin, DeleteView):
template_name = 'empty.html'
permission_required = 'testapp.delete_book'
@permission_required('testapp.delete_book', fn=objectgetter(Book, 'book_id'), raise_exception=True)
def view_that_raises(request, book_id):
return HttpResponse('OK')
class ViewThatRaises(LoginRequiredMixin, PermissionRequiredMixin, BookMixin, DeleteView):
template_name = 'empty.html'
raise_exception = True
permission_required = 'testapp.delete_book'
@permission_required(['testapp.change_book', 'testapp.delete_book'], fn=objectgetter(Book, 'book_id'))
def view_with_permission_list(request, book_id):
return HttpResponse('OK')
class ViewWithPermissionList(LoginRequiredMixin, PermissionRequiredMixin, BookMixin, DeleteView):
template_name = 'empty.html'
permission_required = ['testapp.change_book', 'testapp.delete_book']
@permission_required('testapp.delete_book', fn=objectgetter(Book, 'book_id'))
def test_metavalue_startswith_filter_with_invalid_param(self):
queryset = YaraRuleFilter({'metavalue_startswith': self.failure_keyword}, queryset=self.queryset).qs
self.assertEqual(0, queryset.count())
def test_tagged_filter_as_true(self):
queryset = YaraRuleFilter({'tagged': 'true'}, queryset=self.queryset).qs
self.assertEqual(2, queryset.count())
def test_all_dependencies_filter_with_single_dependency(self):
queryset = YaraRuleFilter({'all_dependencies': 'TestRule1'}, queryset=self.queryset).qs
self.assertEqual(1, queryset.count())
def test_metavalue_endswith_filter_with_valid_param(self):
queryset = YaraRuleFilter({'metavalue_endswith': 'Rule'}, queryset=self.queryset).qs
self.assertEqual(1, queryset.count())
def test_category_filter_with_multiple_categories(self):
queryset = YaraRuleFilter({'category': 'Test Rules, Experimental Rules'}, queryset=self.queryset).qs
self.assertEqual(3, queryset.count())
def test_metakey_contains_filter_with_invalid_param(self):
queryset = YaraRuleFilter({'metakey_contains': self.failure_keyword}, queryset=self.queryset).qs
self.assertEqual(0, queryset.count())
def test_tagged_filter_as_false(self):
queryset = YaraRuleFilter({'tagged': 'false'}, queryset=self.queryset).qs
self.assertEqual(1, queryset.count())
def test_all_metakeys_filter_with_multiple_metakeys(self):
queryset = YaraRuleFilter({'all_metakeys': 'author, description'}, queryset=self.queryset).qs
self.assertEqual(1, queryset.count())
def test_all_imports_filter_with_invalid_import(self):
queryset = YaraRuleFilter({'all_imports': self.failure_keyword}, queryset=self.queryset).qs
self.assertEqual(0, queryset.count())