public void testIsWritable() throws Exception { authorizerControl.expectAndReturn(authorizer.hasPermission(0, 0, project, "edit"), true); writableTableTag.setPermissions("edit,delete"); authorizerControl.replay(); boolean isWritable = writableTableTag.isWritable(); assertEquals("table should be writable", true, isWritable); authorizerControl.verify(); }
public void setUp() throws Exception { super.setUp(); writableTableTag = new WritableTableTag(); support = new XPlannerTestSupport(); support.pageContext.setAttribute(TableTag.PAGE_ATTRIBUTE_MEDIA, MediaTypeEnum.HTML); writableTableTag.setPageContext(support.pageContext); authorizerControl = MockControl.createControl(Authorizer.class); authorizer = (Authorizer) authorizerControl.getMock(); Collection projectCol = new ArrayList(); writableTableTag.setWholeCollection(projectCol); project = new Project(); projectCol.add(project); Set principalSet = new HashSet(); Person person = new Person(); principalSet.add(new PersonPrincipal(person)); Subject subject = new Subject(false, principalSet, new HashSet(), new HashSet()); SecurityHelper.setSubject(support.request, subject); SystemAuthorizer.set(authorizer); }
public void testIsWritable_emptyPermissionList() throws Exception { writableTableTag.setPermissions(null); boolean isWritable = writableTableTag.isWritable(); assertEquals("table should be writable", true, isWritable); }