Skip to content

Commit 36c8247

Browse files
committed
test: add test cases for whitelist_for_tests rule
1 parent b8d8401 commit 36c8247

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

rules/frappe_correctness.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from frappe import _
33

44
from frappe.model.document import Document
5+
from frappe.tests.utils import whitelist_for_tests
56
from frappe.utils import cint
67

78

@@ -215,3 +216,25 @@ def good_cache():
215216
def test_single():
216217
# ok: frappe-single-value-type-safety
217218
frappe.db.get_single_value("ABC", "ABC", ["xyz", "xac"])
219+
220+
221+
# Test file context - these should be in test_*.py files
222+
# ruleid: frappe-test-whitelist-missing-protection
223+
@frappe.whitelist()
224+
def test_endpoint():
225+
return "test"
226+
227+
# ok: frappe-test-whitelist-missing-protection
228+
@whitelist_for_tests()
229+
def test_endpoint_protected():
230+
return "test"
231+
232+
# ruleid: frappe-test-whitelist-missing-protection
233+
@frappe.whitelist(allow_guest=True)
234+
def test_guest_endpoint():
235+
return "test"
236+
237+
# ok: frappe-test-whitelist-missing-protection
238+
@whitelist_for_tests(allow_guest=True)
239+
def test_guest_endpoint_protected():
240+
return "test"

0 commit comments

Comments
 (0)