@After public void dropTablesAndClearContext() { template.execute("drop table authorities"); template.execute("drop table users"); template.execute("drop table group_authorities"); template.execute("drop table group_members"); template.execute("drop table groups"); SecurityContextHolder.clearContext(); }
@After public final void clearContext() { SecurityContextHolder.clearContext(); } }
@Test public void testNeverReturnsNull() { assertThat(SecurityContextHolder.getContext()).isNotNull(); SecurityContextHolder.clearContext(); }
@After public void closeAppContext() { if (context != null) { context.close(); context = null; } SecurityContextHolder.clearContext(); }
@AfterTransaction public void clearContextAndData() throws Exception { SecurityContextHolder.clearContext(); jdbcTemplate.execute("drop table acl_entry"); jdbcTemplate.execute("drop table acl_object_identity"); jdbcTemplate.execute("drop table acl_class"); jdbcTemplate.execute("drop table acl_sid"); aclCache.clearCache(); }
@Test public void testContextHolderGetterSetterClearer() { SecurityContext sc = new SecurityContextImpl(); sc.setAuthentication(new UsernamePasswordAuthenticationToken("Foobar", "pass")); SecurityContextHolder.setContext(sc); assertThat(SecurityContextHolder.getContext()).isEqualTo(sc); SecurityContextHolder.clearContext(); assertThat(SecurityContextHolder.getContext()).isNotSameAs(sc); SecurityContextHolder.clearContext(); }
@Test public void testNullContextHolderDoesNotCauseInvocationProblems() throws Exception { SecurityContextHolder.clearContext(); // just to be explicit ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation(); SecurityContextHolder.clearContext(); // unnecessary, but for // explicitness assertThat(remoteInvocation.invoke(new TargetObject())).isEqualTo( "some_string Authentication empty"); }
@After public void closeAppContext() { if (appContext != null) { appContext.close(); appContext = null; } SecurityContextHolder.clearContext(); target = null; }
@After public void cleanup() { SecurityContextHolder.clearContext(); RequestContextHolder.resetRequestAttributes(); }
@After public void closeAppContext() { if (appContext != null) { appContext.close(); } SecurityContextHolder.clearContext(); }
@After public void closeAppContext() { SecurityContextHolder.clearContext(); if (appContext != null) { appContext.close(); appContext = null; } }
@Before @After public void clearContext() { SecurityContextHolder.clearContext(); }
@After public void closeAppContext() { if (appContext != null) { appContext.close(); } SecurityContextHolder.clearContext(); }
@Before public void loadContext() { SecurityContextHolder.clearContext(); appContext = new InMemoryXmlApplicationContext( "<b:bean id='target' class='org.springframework.security.access.annotation.BusinessServiceImpl'/>" + "<global-method-security secured-annotations='enabled'/>" + ConfigTestUtils.AUTH_PROVIDER_XML); target = (BusinessService) appContext.getBean("target"); }
@Before public final void setUp() throws Exception { SecurityContextHolder.clearContext(); interceptor = new MethodSecurityInterceptor(); token = new TestingAuthenticationToken("Test", "Password", "ROLE_SOMETHING"); adm = mock(AccessDecisionManager.class); AuthenticationManager authman = mock(AuthenticationManager.class); mds = mock(MethodSecurityMetadataSource.class); interceptor.setAccessDecisionManager(adm); interceptor.setAuthenticationManager(authman); interceptor.setSecurityMetadataSource(mds); }
@Before public void setUp() throws Exception { this.module = new SecurityContextLoginModule(); this.module.initialize(this.subject, null, null, null); SecurityContextHolder.clearContext(); }
@Test public void callDefaultSecurityContext() throws Exception { SecurityContextHolder.setContext(securityContext); callable = new DelegatingSecurityContextCallable<>(delegate); SecurityContextHolder.clearContext(); // ensure callable is what sets up the // SecurityContextHolder assertWrapped(callable); }
@Test public void createNullSecurityContext() throws Exception { SecurityContextHolder.setContext(securityContext); callable = DelegatingSecurityContextCallable.create(delegate, null); SecurityContextHolder.clearContext(); // ensure callable is what sets up the // SecurityContextHolder assertWrapped(callable); }
@Test public void callDefaultSecurityContext() throws Exception { SecurityContextHolder.setContext(securityContext); runnable = new DelegatingSecurityContextRunnable(delegate); SecurityContextHolder.clearContext(); // ensure runnable is what sets up the // SecurityContextHolder assertWrapped(runnable); }
@Test public void createNullSecurityContext() throws Exception { SecurityContextHolder.setContext(securityContext); runnable = DelegatingSecurityContextRunnable.create(delegate, null); SecurityContextHolder.clearContext(); // ensure runnable is what sets up the // SecurityContextHolder assertWrapped(runnable); }