问题描述
- shiro的Testing怎么用?
-
dao层:
if(SecurityUtils.getSubject().hasRole("role_case_agent")){
buf.append("SELECT * FROM (SELECT t1.*, t2.receive_document_num, t2.case_title, t3.agent_department, t4.department_id FROM borrow_management_audit_info t1 LEFT JOIN case_audit_info t2 ON t1.case_id = t2.id LEFT JOIN document_base_info t3 ON t1.document_id = t3.id LEFT JOIN pos_department t4 ON t3.agent_department = t4.short_name WHERE (borrow_status = '6' OR borrow_status = '7' OR borrow_status = '9') AND operator_read_status = '0' AND operator_username = '")
.append(username)
.append("'")
.append(term.addEqual(borrowManagementAuditInfo.getDepartmentId(), "t4.department_id"))
.append(" ) a WHERE 1 = 1");
}
请问: 如何才能在写单元测试类的时候让进入到上面的if中(if中用到了shiro授权)?
补充:我查了许多shiro的资料,都是说如何进行hasRole,但是没有说如何将shiro中的subject和roles进行关联。
时间: 2025-01-29 23:34:01