SEC-1107: Added test to attempt to reproduce issue.

This commit is contained in:
Luke Taylor 2009-04-27 10:21:31 +00:00
parent 530a7b5d21
commit d0a308c99b
4 changed files with 19 additions and 9 deletions

View File

@ -75,8 +75,7 @@ public class JdbcAclService implements AclService {
Object[] args = {parentIdentity.getIdentifier(), parentIdentity.getJavaType().getName()};
List<ObjectIdentity> objects = jdbcTemplate.query(selectAclObjectWithParent, args,
new RowMapper<ObjectIdentity>() {
public ObjectIdentity mapRow(ResultSet rs, int rowNum)
throws SQLException {
public ObjectIdentity mapRow(ResultSet rs, int rowNum) throws SQLException {
String javaType = rs.getString("class");
Long identifier = new Long(rs.getLong("obj_id"));

View File

@ -143,8 +143,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
Long sidId = createOrRetrieveSidPrimaryKey(owner, true);
Long classId = createOrRetrieveClassPrimaryKey(object.getJavaType(), true);
jdbcTemplate.update(insertObjectIdentity,
new Object[] {classId, object.getIdentifier().toString(), sidId, new Boolean(true)});
jdbcTemplate.update(insertObjectIdentity, classId, object.getIdentifier().toString(), sidId, Boolean.TRUE);
}
/**

View File

@ -27,7 +27,7 @@ import javax.sql.DataSource;
/**
* Seeds the database for {@link JdbcAclServiceTests}.
* Seeds the database for {@link JdbcMutableAclServiceTests}.
*
* @author Ben Alex
* @version $Id$

View File

@ -54,10 +54,10 @@ import org.springframework.transaction.annotation.Transactional;
*
* @author Ben Alex
* @author Andrei Stefan
* @version $Id:JdbcAclServiceTests.java 1754 2006-11-17 02:01:21Z benalex $
* @version $Id:JdbcMutableAclServiceTests.java 1754 2006-11-17 02:01:21Z benalex $
*/
@ContextConfiguration(locations={"/org/springframework/security/acls/jdbc/applicationContext-test.xml"})
public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContextTests {
public class JdbcMutableAclServiceTests extends AbstractTransactionalJUnit4SpringContextTests {
//~ Constant fields ================================================================================================
private final Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_ADMINISTRATOR");
@ -275,7 +275,7 @@ public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContex
}
@Test
public void testConstructorRejectsNullParameters() throws Exception {
public void constructorRejectsNullParameters() throws Exception {
try {
new JdbcMutableAclService(null, lookupStrategy, aclCache);
fail("It should have thrown IllegalArgumentException");
@ -299,7 +299,7 @@ public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContex
}
@Test
public void testCreateAclRejectsNullParameter() throws Exception {
public void createAclRejectsNullParameter() throws Exception {
try {
jdbcMutableAclService.createAcl(null);
fail("It should have thrown IllegalArgumentException");
@ -379,6 +379,18 @@ public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContex
assertNull(aclCache.getFromCache(new Long(102)));
}
/** SEC-1107 */
@Test
@Transactional
@Rollback
public void identityWithIntegerIdIsSupported() throws Exception {
SecurityContextHolder.getContext().setAuthentication(auth);
ObjectIdentity oid = new ObjectIdentityImpl("org.springframework.security.TargetObject", Integer.valueOf(101));
jdbcMutableAclService.createAcl(oid);
assertNotNull(jdbcMutableAclService.readAclById(new ObjectIdentityImpl("org.springframework.security.TargetObject", Long.valueOf(101))));
}
/**
* SEC-655
*/