Spring security disable while testing -
Spring security disable while testing -
i have app written jsf , spring (transactions , ioc). app secured spring security (pretty complex due fact utilize acls). flow through app is: jsf managed bean -> service class -> dao class -> db , other way around.
the interface implemented tested method looks :
public interface myservice extends genericservice { @preauthorize("haspermission(#oid,'com.mycompany.core.entity.myobject','read')") public abstract myobject getmyobject(long oid); }
the test specified method:
@runwith(springjunit4classrunner.class) @contextconfiguration({ "classpath:/applicationcontext.xml","classpath: /applicationcontext-test.xml" }) @transactionconfiguration(transactionmanager = "transactionmanager", defaultrollback = true) @transactional(propagation = propagation.required) public class myserviceimplintegrationtest { @inject private myservice myservice; @test public void testgetmyobject(){ myservice.getmyobject(); } }
as can seen utilize 2 xml files configuring spring (one tests , 1 non test). problem entire test class want eliminate spring security annotations on real methods. first override element looks :
<security:global-method-security pre-post-annotations="enabled"> <security:expression-handler ref="methodexpressionhandler" /> </security:global-method-security>
with
<security:global-method-security pre-post-annotations="disabled"> <security:expression-handler ref="methodexpressionhandler" /> </security:global-method-security>
but seems element cannot overridden in other files. other ideas of how can accomplish same effect ?
ps. components versions :
<org.springframework.version>4.0.7.release</org.springframework.version> <org.springframework.security.version>3.2.4.release</org.springframework.security.version>
spring spring-security
Comments
Post a Comment