|
| 1 | +/* |
| 2 | + * Copyright 2017 Stormpath, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.stormpath.spring.boot.autoconfigure |
| 17 | + |
| 18 | +import autoconfigure.DisabledSpringSecurityDisablesStormpathSSAutoConfigurationTestApplication |
| 19 | +import com.stormpath.sdk.api.ApiKey |
| 20 | +import com.stormpath.sdk.application.Application |
| 21 | +import com.stormpath.sdk.cache.CacheManager |
| 22 | +import com.stormpath.sdk.client.Client |
| 23 | +import com.stormpath.sdk.servlet.csrf.CsrfTokenManager |
| 24 | +import com.stormpath.sdk.servlet.csrf.DefaultCsrfTokenManager |
| 25 | +import com.stormpath.sdk.servlet.event.RequestEventListener |
| 26 | +import com.stormpath.sdk.servlet.http.authc.HeaderAuthenticator |
| 27 | +import com.stormpath.sdk.servlet.mvc.Controller |
| 28 | +import com.stormpath.spring.config.TwoAppTenantStormpathTestConfiguration |
| 29 | +import com.stormpath.spring.security.provider.GroupPermissionResolver |
| 30 | +import com.stormpath.spring.security.provider.StormpathAuthenticationProvider |
| 31 | +import org.springframework.beans.factory.annotation.Autowired |
| 32 | +import org.springframework.boot.test.context.SpringBootTest |
| 33 | +import org.springframework.boot.web.servlet.FilterRegistrationBean |
| 34 | +import org.springframework.security.config.annotation.SecurityConfigurerAdapter |
| 35 | +import org.springframework.security.web.FilterChainProxy |
| 36 | +import org.springframework.security.web.authentication.logout.LogoutHandler |
| 37 | +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests |
| 38 | +import org.springframework.test.context.web.WebAppConfiguration |
| 39 | +import org.testng.annotations.Test |
| 40 | + |
| 41 | +import static org.testng.Assert.assertNotNull |
| 42 | +import static org.testng.Assert.assertNull |
| 43 | +import static org.testng.Assert.assertTrue |
| 44 | + |
| 45 | +/** |
| 46 | + * Disabling Spring Security must also disable Stormpath's Spring Security integration |
| 47 | + * |
| 48 | + * @since 1.3.2 |
| 49 | + */ |
| 50 | +@SpringBootTest(classes = [DisabledSpringSecurityDisablesStormpathSSAutoConfigurationTestApplication.class, TwoAppTenantStormpathTestConfiguration.class]) |
| 51 | +@WebAppConfiguration |
| 52 | +class DisabledSpringSecurityDisablesStormpathSSAutoConfigurationIT extends AbstractTestNGSpringContextTests { |
| 53 | + |
| 54 | + @Autowired |
| 55 | + Client client |
| 56 | + |
| 57 | + @Autowired |
| 58 | + ApiKey apiKey; |
| 59 | + |
| 60 | + @Autowired |
| 61 | + CacheManager stormpathCacheManager; |
| 62 | + |
| 63 | + @Autowired |
| 64 | + Application application; |
| 65 | + |
| 66 | + @Autowired |
| 67 | + FilterRegistrationBean stormpathFilter |
| 68 | + |
| 69 | + @Autowired(required = false) |
| 70 | + SecurityConfigurerAdapter stormpathSecurityConfigurerAdapter |
| 71 | + |
| 72 | + @Autowired |
| 73 | + FilterChainProxy springSecurityFilterChain |
| 74 | + |
| 75 | + @Autowired |
| 76 | + HeaderAuthenticator stormpathAuthorizationHeaderAuthenticator |
| 77 | + |
| 78 | + @Autowired(required = false) |
| 79 | + Controller stormpathForgotPasswordController |
| 80 | + |
| 81 | + //Spring Security Beans |
| 82 | + @Autowired(required = false) |
| 83 | + StormpathAuthenticationProvider stormpathAuthenticationProvider |
| 84 | + |
| 85 | + @Autowired(required = false) |
| 86 | + GroupPermissionResolver stormpathGroupPermissionResolver |
| 87 | + |
| 88 | + @Autowired |
| 89 | + RequestEventListener stormpathRequestEventListener |
| 90 | + |
| 91 | + @Autowired |
| 92 | + CsrfTokenManager stormpathCsrfTokenManager |
| 93 | + |
| 94 | + @Autowired(required = false) |
| 95 | + LogoutHandler stormpathLogoutHandler |
| 96 | + |
| 97 | + @Test |
| 98 | + void test() { |
| 99 | + assertNotNull client |
| 100 | + assertNotNull apiKey |
| 101 | + assertNotNull stormpathCacheManager |
| 102 | + assertNotNull stormpathFilter |
| 103 | + assertNull stormpathSecurityConfigurerAdapter |
| 104 | + assertNotNull application |
| 105 | + assertNotNull springSecurityFilterChain |
| 106 | + assertNull stormpathAuthenticationProvider |
| 107 | + assertNull stormpathGroupPermissionResolver |
| 108 | + assertNotNull stormpathRequestEventListener |
| 109 | + assertTrue stormpathCsrfTokenManager instanceof DefaultCsrfTokenManager |
| 110 | + assertNotNull stormpathAuthorizationHeaderAuthenticator |
| 111 | + assertNotNull stormpathForgotPasswordController |
| 112 | + assertNull stormpathLogoutHandler //when Spring Security is disabled we do not need our logout handler |
| 113 | + } |
| 114 | + |
| 115 | +} |
0 commit comments