SEC-1107: Added test to attempt to reproduce issue.
This commit is contained in:
parent
530a7b5d21
commit
d0a308c99b
|
@ -75,8 +75,7 @@ public class JdbcAclService implements AclService {
|
||||||
Object[] args = {parentIdentity.getIdentifier(), parentIdentity.getJavaType().getName()};
|
Object[] args = {parentIdentity.getIdentifier(), parentIdentity.getJavaType().getName()};
|
||||||
List<ObjectIdentity> objects = jdbcTemplate.query(selectAclObjectWithParent, args,
|
List<ObjectIdentity> objects = jdbcTemplate.query(selectAclObjectWithParent, args,
|
||||||
new RowMapper<ObjectIdentity>() {
|
new RowMapper<ObjectIdentity>() {
|
||||||
public ObjectIdentity mapRow(ResultSet rs, int rowNum)
|
public ObjectIdentity mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
throws SQLException {
|
|
||||||
String javaType = rs.getString("class");
|
String javaType = rs.getString("class");
|
||||||
Long identifier = new Long(rs.getLong("obj_id"));
|
Long identifier = new Long(rs.getLong("obj_id"));
|
||||||
|
|
||||||
|
|
|
@ -143,8 +143,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
|
||||||
protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
|
protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
|
||||||
Long sidId = createOrRetrieveSidPrimaryKey(owner, true);
|
Long sidId = createOrRetrieveSidPrimaryKey(owner, true);
|
||||||
Long classId = createOrRetrieveClassPrimaryKey(object.getJavaType(), true);
|
Long classId = createOrRetrieveClassPrimaryKey(object.getJavaType(), true);
|
||||||
jdbcTemplate.update(insertObjectIdentity,
|
jdbcTemplate.update(insertObjectIdentity, classId, object.getIdentifier().toString(), sidId, Boolean.TRUE);
|
||||||
new Object[] {classId, object.getIdentifier().toString(), sidId, new Boolean(true)});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,7 @@ import javax.sql.DataSource;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seeds the database for {@link JdbcAclServiceTests}.
|
* Seeds the database for {@link JdbcMutableAclServiceTests}.
|
||||||
*
|
*
|
||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
|
|
@ -54,10 +54,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
*
|
*
|
||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
* @author Andrei Stefan
|
* @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"})
|
@ContextConfiguration(locations={"/org/springframework/security/acls/jdbc/applicationContext-test.xml"})
|
||||||
public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContextTests {
|
public class JdbcMutableAclServiceTests extends AbstractTransactionalJUnit4SpringContextTests {
|
||||||
//~ Constant fields ================================================================================================
|
//~ Constant fields ================================================================================================
|
||||||
|
|
||||||
private final Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_ADMINISTRATOR");
|
private final Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_ADMINISTRATOR");
|
||||||
|
@ -275,7 +275,7 @@ public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContex
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructorRejectsNullParameters() throws Exception {
|
public void constructorRejectsNullParameters() throws Exception {
|
||||||
try {
|
try {
|
||||||
new JdbcMutableAclService(null, lookupStrategy, aclCache);
|
new JdbcMutableAclService(null, lookupStrategy, aclCache);
|
||||||
fail("It should have thrown IllegalArgumentException");
|
fail("It should have thrown IllegalArgumentException");
|
||||||
|
@ -299,7 +299,7 @@ public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContex
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAclRejectsNullParameter() throws Exception {
|
public void createAclRejectsNullParameter() throws Exception {
|
||||||
try {
|
try {
|
||||||
jdbcMutableAclService.createAcl(null);
|
jdbcMutableAclService.createAcl(null);
|
||||||
fail("It should have thrown IllegalArgumentException");
|
fail("It should have thrown IllegalArgumentException");
|
||||||
|
@ -379,6 +379,18 @@ public class JdbcAclServiceTests extends AbstractTransactionalJUnit4SpringContex
|
||||||
assertNull(aclCache.getFromCache(new Long(102)));
|
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
|
* SEC-655
|
||||||
*/
|
*/
|
Loading…
Reference in New Issue