📄 securitytests.java
字号:
// DemoSalesRep3 for DemoAccount1 public void testDemoAccount1DemoSalesRep3View() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_ACCOUNT", "_VIEW", userLogin, "DemoAccount1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has view permission for DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoAccount1DemoSalesRep3Update() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_ACCOUNT", "_UPDATE", userLogin, "DemoAccount1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has update permission for DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoAccount1DemoSalesRep3Deactivate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_ACCOUNT", "_DEACTIVATE", userLogin, "DemoAccount1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has deactivate permission for DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoAccount1DemoSalesRep3Reassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_ACCOUNT", "_REASSIGN", userLogin, "DemoAccount1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has reassign permission for DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } // DemoSalesManager for DemoContact1 public void testDemoContact1DemoSalesManagerView() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_VIEW", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager has view permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesManagerUpdate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_UPDATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager has update permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesManagerDeactivate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_DEACTIVATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager has deactivate permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesManagerReassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager has reassign permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact2DemoSalesManagerReassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager has reassign permission for DemoContact2", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } // DemoSalesRep1 for DemoContact1 public void testDemoContact1DemoSalesRep1View() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_VIEW", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 has view permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep1Update() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_UPDATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 has update permission for DemoContact1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep1Deactivate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_DEACTIVATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 has deactivate permission for DemoContact1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep1Reassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 has reassign permission for DemoContact1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact2DemoSalesRep1Reassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact2")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 has reassign permission for DemoContact2", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } // DemoSalesRep2 for DemoContact1 public void testDemoContact1DemoSalesRep2View() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep2")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_VIEW", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep2 has view permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep2Update() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep2")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_UPDATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep2 has update permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep2Deactivate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep2")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_DEACTIVATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep2 has deactivate permission for DemoContact1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep2Reassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep2")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep2 has reassign permission for DemoContact1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact2DemoSalesRep2Reassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep2")); boolean hasPermission = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -