fix(security): enforce read permission check in Payroll Entry overtime endpoints - #4998
fix(security): enforce read permission check in Payroll Entry overtime endpoints#4998pratheep-bit wants to merge 8 commits into
Conversation
Confidence Score: 4/5The production permission guards are correct; the test does not fully verify both methods. The two production-code lines are sound. The test only ever exercises get_unsubmitted_overtime_slips — get_overtime_slip_details is silently skipped because both calls share a single assertRaises block and execution stops at the first exception. Files Needing Attention: test_payroll_entry.py — the permission test needs separate assertRaises blocks for each method. Reviews (14): Last reviewed commit: "fix(test): clear Guest permission cache ..." | Re-trigger Greptile |
| self.assertEqual(get_end_date("2017-02-15", "monthly"), {"end_date": "2017-03-14"}) | ||
| self.assertEqual(get_end_date("2017-02-15", "daily"), {"end_date": "2017-02-15"}) | ||
|
|
||
| def test_get_payroll_entries_for_jv_filters_docstatus(self): |
There was a problem hiding this comment.
@pratheep-bit, this test only checks that get_payroll_entries_for_jv returns a list, not that the docstatus == 1 filter actually works. It'd pass even without your the fix you added.
Could you create a Draft Payroll Entry and assert it's excluded from the results (and a submitted one is included)?
|
@pratheep-bit, you've already raised a PR (#4997) for submitted payroll filter. Why is the same commit duplicated here too? Could you drop it from one of the two? |
2ab8ec2 to
c143d5e
Compare
|
Hi @iamkhanraheel, Thanks for the feedback!
Force-pushed a single clean commit. |
c143d5e to
1e1c49b
Compare
|
Fixed CI test failure in test_get_unsubmitted_overtime_slips_permission_check. Root Cause: The test previously called make_payroll_entry(), which executes fill_employee_details() and searches for active employee salary structures for the given date range. Since no employee salary structure was set up for those dates in the CI runner, it raised ValidationError: No employees found for the mentioned criteria. Fix: Replaced make_payroll_entry() with frappe.get_doc(doctype="Payroll Entry", ...).insert(), creating the document instance directly without relying on pre-existing employee test setup. Force-pushed. |
1e1c49b to
0ea8ed0
Compare
|
Fixed the CI failure properly this time. The previous amend picked up stale staged code. What was wrong: The test used Fix: Replaced with Also removed the duplicated Force-pushed clean single commit |
@pratheep-bit, Hope you will push the fix for test #4998 (comment) in #4997 |
0ea8ed0 to
8f96e24
Compare
|
Hi @iamkhanraheel, Updated in PR #4998 with and . It now creates a saved Payroll Entry cleanly without depending on pre-existing employee/salary structure setups in the test runner. Force-pushed clean commit. |
… in test_payroll_entry
…nd assert draft entry is excluded in test
|
Hi @iamkhanraheel, thank you for the thorough review! I've addressed both points raised:
The updated commit is: Please let me know if anything else needs to be changed! |
…sserted on method invocation
|
Fixed! Moved the test user setup cleanly before the assertion block and removed the post- Also kept PR #4998 strictly scoped to the overtime slip permission check as requested. |
…ermission_check to correctly assert PermissionError
…inside assertRaises
Summary of Changes
self.check_permission("read")to@frappe.whitelist()methodsget_unsubmitted_overtime_slipsandget_overtime_slip_detailsinPayrollEntry.Payroll Entry.test_get_unsubmitted_overtime_slips_permission_checkintest_payroll_entry.py.