📄 securitytests.java
字号:
if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact2")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep2 has reassign permission for DemoContact2", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } // DemoSalesRep3 for DemoContact1 public void testDemoContact1DemoSalesRep3View() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_VIEW", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has view permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep3Update() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_UPDATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has update permission for DemoContact1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep3Deactivate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_DEACTIVATE", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has deactivate permission for DemoContact1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact1DemoSalesRep3Reassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has reassign permission for DemoContact1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoContact2DemoSalesRep3Reassign() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep3")); boolean hasPermission = false; if (CrmsfaSecurity.hasPartyRelationSecurity(security, "CRMSFA_CONTACT", "_REASSIGN", userLogin, "DemoContact2")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep3 has reassign permission for DemoContact2", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } /** * Test the CrmsfaSecurity.hasActivityPermission() method. */ public void testDemoTask1DemoSalesManagerView() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasActivityPermission(security, "_VIEW", userLogin, "DemoTask1", "DemoAccount1", null, null)) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager can view DemoTask1 which is associated with DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoTask1DemoSalesManagerUpdate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasActivityPermission(security, "_UPDATE", userLogin, "DemoTask1", "DemoAccount1", null, null)) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager can update DemoTask1 which is associated with DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoTask1DemoSalesManagerClose() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasActivityPermission(security, "_CLOSE", userLogin, "DemoTask1", "DemoAccount1", null, null)) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager can close DemoTask1 which is associated with DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoTask1DemoSalesRep1View() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasActivityPermission(security, "_VIEW", userLogin, "DemoTask1", "DemoAccount1", null, null)) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 can view DemoTask1 which is associated with DemoAccount1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoTask1DemoSalesRep1Update() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasActivityPermission(security, "_UPDATE", userLogin, "DemoTask1", "DemoAccount1", null, null)) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 can update DemoTask1 which is associated with DemoAccount1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoTask1DemoSalesRep1Close() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasActivityPermission(security, "_CLOSE", userLogin, "DemoTask1", "DemoAccount1", null, null)) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 can close DemoTask1 which is associated with DemoAccount1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } /** * Test the CrmsfaSecurity.hasCasePermission() method. */ public void testDemoCase1DemoSalesManagerView() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasCasePermission(security, "_VIEW", userLogin, "DemoCase1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager can view DemoCase1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoCase1DemoSalesManagerUpdate() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasCasePermission(security, "_UPDATE", userLogin, "DemoCase1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager can update DemoCase1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoCase1DemoSalesManagerClose() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesManager")); boolean hasPermission = false; if (CrmsfaSecurity.hasCasePermission(security, "_CLOSE", userLogin, "DemoCase1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesManager can close DemoCase1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoCase1DemoSalesRep1View() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasCasePermission(security, "_VIEW", userLogin, "DemoCase1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 can view DemoCase1", true, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoCase1DemoSalesRep1Update() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasCasePermission(security, "_UPDATE", userLogin, "DemoCase1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 can update DemoCase1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } } public void testDemoCase1DemoSalesRep1Close() throws Exception { try { GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "DemoSalesRep1")); boolean hasPermission = false; if (CrmsfaSecurity.hasCasePermission(security, "_CLOSE", userLogin, "DemoCase1")) { hasPermission = true; } TestCase.assertEquals("DemoSalesRep1 can close DemoCase1", false, hasPermission); } catch (GenericEntityException ex) { TestCase.fail(ex.getMessage()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -