update to spring-io-plugin:0.0.6
- Update spring-io-plugin - Update Spring Boot because spring-io-plugin now requires non passive dependency management plugin
This commit is contained in:
		
							parent
							
								
									38492a5794
								
							
						
					
					
						commit
						b5e0886bde
					
				| 
						 | 
					@ -1,15 +1,16 @@
 | 
				
			||||||
buildscript {
 | 
					buildscript {
 | 
				
			||||||
	repositories {
 | 
						repositories {
 | 
				
			||||||
		maven { url "https://repo.spring.io/plugins-release" }
 | 
							maven { url "https://repo.spring.io/plugins-release" }
 | 
				
			||||||
 | 
							maven { url "https://repo.spring.io/plugins-snapshot" }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	dependencies {
 | 
						dependencies {
 | 
				
			||||||
		classpath("org.springframework.build.gradle:propdeps-plugin:0.0.7")
 | 
							classpath("org.springframework.build.gradle:propdeps-plugin:0.0.7")
 | 
				
			||||||
		classpath("io.spring.gradle:spring-io-plugin:0.0.5.RELEASE")
 | 
							classpath("io.spring.gradle:spring-io-plugin:0.0.6.RELEASE")
 | 
				
			||||||
		classpath("com.bmuschko:gradle-tomcat-plugin:2.2.4")
 | 
							classpath("com.bmuschko:gradle-tomcat-plugin:2.2.4")
 | 
				
			||||||
		classpath('me.champeau.gradle:gradle-javadoc-hotfix-plugin:0.1')
 | 
							classpath('me.champeau.gradle:gradle-javadoc-hotfix-plugin:0.1')
 | 
				
			||||||
		classpath('org.asciidoctor:asciidoctor-gradle-plugin:1.5.1')
 | 
							classpath('org.asciidoctor:asciidoctor-gradle-plugin:1.5.1')
 | 
				
			||||||
		classpath("io.spring.gradle:docbook-reference-plugin:0.3.1")
 | 
							classpath("io.spring.gradle:docbook-reference-plugin:0.3.1")
 | 
				
			||||||
		classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
 | 
							classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.0.BUILD-SNAPSHOT")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@ ext.springDataCommonsVersion = '1.12.2.RELEASE'
 | 
				
			||||||
ext.springDataJpaVersion = '1.10.2.RELEASE'
 | 
					ext.springDataJpaVersion = '1.10.2.RELEASE'
 | 
				
			||||||
ext.springDataRedisVersion = '1.7.2.RELEASE'
 | 
					ext.springDataRedisVersion = '1.7.2.RELEASE'
 | 
				
			||||||
ext.springSessionVersion = '1.2.1.RELEASE'
 | 
					ext.springSessionVersion = '1.2.1.RELEASE'
 | 
				
			||||||
ext.springBootVersion = '1.4.0.RELEASE'
 | 
					ext.springBootVersion = '1.5.0.BUILD-SNAPSHOT'
 | 
				
			||||||
ext.thymeleafVersion = '3.0.2.RELEASE'
 | 
					ext.thymeleafVersion = '3.0.2.RELEASE'
 | 
				
			||||||
ext.jsonassertVersion = '1.3.0'
 | 
					ext.jsonassertVersion = '1.3.0'
 | 
				
			||||||
ext.validationApiVersion = '1.1.0.Final'
 | 
					ext.validationApiVersion = '1.1.0.Final'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,25 +15,22 @@
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
package org.springframework.security.samples;
 | 
					package org.springframework.security.samples;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.junit.Before;
 | 
					 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
import org.junit.runner.RunWith;
 | 
					import org.junit.runner.RunWith;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
 | 
					import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
 | 
				
			||||||
 | 
					import org.springframework.boot.test.context.SpringBootTest;
 | 
				
			||||||
import org.springframework.mock.web.MockHttpSession;
 | 
					import org.springframework.mock.web.MockHttpSession;
 | 
				
			||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 | 
					import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 | 
				
			||||||
import org.springframework.test.context.web.WebAppConfiguration;
 | 
					 | 
				
			||||||
import org.springframework.test.web.servlet.MockMvc;
 | 
					import org.springframework.test.web.servlet.MockMvc;
 | 
				
			||||||
import org.springframework.test.web.servlet.MvcResult;
 | 
					import org.springframework.test.web.servlet.MvcResult;
 | 
				
			||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 | 
					 | 
				
			||||||
import org.springframework.web.context.WebApplicationContext;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.assertj.core.api.Assertions.assertThat;
 | 
					import static org.assertj.core.api.Assertions.assertThat;
 | 
				
			||||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin;
 | 
					import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin;
 | 
				
			||||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
 | 
					import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
 | 
				
			||||||
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.authenticated;
 | 
					import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.authenticated;
 | 
				
			||||||
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.unauthenticated;
 | 
					import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.unauthenticated;
 | 
				
			||||||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
 | 
					 | 
				
			||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 | 
					import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 | 
				
			||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
 | 
					import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
 | 
				
			||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 | 
					import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 | 
				
			||||||
| 
						 | 
					@ -43,78 +40,79 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 | 
				
			||||||
 * @author Joe Grandja
 | 
					 * @author Joe Grandja
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@RunWith(SpringJUnit4ClassRunner.class)
 | 
					@RunWith(SpringJUnit4ClassRunner.class)
 | 
				
			||||||
@SpringApplicationConfiguration(HelloWorldApplication.class)
 | 
					@SpringBootTest
 | 
				
			||||||
@WebAppConfiguration
 | 
					@AutoConfigureMockMvc
 | 
				
			||||||
public class HelloWorldApplicationTests {
 | 
					public class HelloWorldApplicationTests {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Autowired
 | 
						@Autowired
 | 
				
			||||||
	private WebApplicationContext context;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private MockMvc mockMvc;
 | 
						private MockMvc mockMvc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Before
 | 
					 | 
				
			||||||
	public void setup() {
 | 
					 | 
				
			||||||
		mockMvc = MockMvcBuilders
 | 
					 | 
				
			||||||
				.webAppContextSetup(context)
 | 
					 | 
				
			||||||
				.apply(springSecurity())
 | 
					 | 
				
			||||||
				.build();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void accessUnprotected() throws Exception {
 | 
						public void accessUnprotected() throws Exception {
 | 
				
			||||||
		this.mockMvc.perform(get("/index")).andExpect(status().isOk());
 | 
							// @formatter:off
 | 
				
			||||||
 | 
							this.mockMvc.perform(get("/index"))
 | 
				
			||||||
 | 
									.andExpect(status().isOk());
 | 
				
			||||||
 | 
							// @formatter:on
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void accessProtectedRedirectsToLogin() throws Exception {
 | 
						public void accessProtectedRedirectsToLogin() throws Exception {
 | 
				
			||||||
 | 
							// @formatter:off
 | 
				
			||||||
		MvcResult mvcResult = this.mockMvc.perform(get("/user/index"))
 | 
							MvcResult mvcResult = this.mockMvc.perform(get("/user/index"))
 | 
				
			||||||
				.andExpect(status().is3xxRedirection())
 | 
									.andExpect(status().is3xxRedirection())
 | 
				
			||||||
				.andReturn();
 | 
									.andReturn();
 | 
				
			||||||
 | 
							// @formatter:on
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		assertThat(mvcResult.getResponse().getRedirectedUrl()).endsWith("/login");
 | 
							assertThat(mvcResult.getResponse().getRedirectedUrl()).endsWith("/login");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void loginUser() throws Exception {
 | 
						public void loginUser() throws Exception {
 | 
				
			||||||
 | 
							// @formatter:off
 | 
				
			||||||
		this.mockMvc.perform(formLogin().user("user").password("password"))
 | 
							this.mockMvc.perform(formLogin().user("user").password("password"))
 | 
				
			||||||
				.andExpect(authenticated());
 | 
									.andExpect(authenticated());
 | 
				
			||||||
 | 
							// @formatter:on
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void loginInvalidUser() throws Exception {
 | 
						public void loginInvalidUser() throws Exception {
 | 
				
			||||||
 | 
							// @formatter:off
 | 
				
			||||||
		this.mockMvc.perform(formLogin().user("invalid").password("invalid"))
 | 
							this.mockMvc.perform(formLogin().user("invalid").password("invalid"))
 | 
				
			||||||
				.andExpect(unauthenticated())
 | 
									.andExpect(unauthenticated())
 | 
				
			||||||
				.andExpect(status().is3xxRedirection());
 | 
									.andExpect(status().is3xxRedirection());
 | 
				
			||||||
 | 
							// @formatter:on
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void loginUserAccessProtected() throws Exception {
 | 
						public void loginUserAccessProtected() throws Exception {
 | 
				
			||||||
 | 
							// @formatter:off
 | 
				
			||||||
		MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
 | 
							MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
 | 
				
			||||||
				.andExpect(authenticated())
 | 
									.andExpect(authenticated()).andReturn();
 | 
				
			||||||
				.andReturn();
 | 
							// @formatter:on
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		MockHttpSession httpSession = MockHttpSession.class.cast(mvcResult.getRequest().getSession(false));
 | 
							MockHttpSession httpSession = (MockHttpSession) mvcResult.getRequest().getSession(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.mockMvc.perform(get("/user/index")
 | 
							// @formatter:off
 | 
				
			||||||
				.session(httpSession))
 | 
							this.mockMvc.perform(get("/user/index").session(httpSession))
 | 
				
			||||||
				.andExpect(status().isOk());
 | 
									.andExpect(status().isOk());
 | 
				
			||||||
 | 
							// @formatter:on
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void loginUserValidateLogout() throws Exception {
 | 
						public void loginUserValidateLogout() throws Exception {
 | 
				
			||||||
 | 
							// @formatter:off
 | 
				
			||||||
		MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
 | 
							MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
 | 
				
			||||||
				.andExpect(authenticated())
 | 
									.andExpect(authenticated()).andReturn();
 | 
				
			||||||
				.andReturn();
 | 
							// @formatter:on
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		MockHttpSession httpSession = MockHttpSession.class.cast(mvcResult.getRequest().getSession(false));
 | 
							MockHttpSession httpSession = (MockHttpSession) mvcResult.getRequest().getSession(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.mockMvc.perform(post("/logout").with(csrf())
 | 
							// @formatter:off
 | 
				
			||||||
				.session(httpSession))
 | 
							this.mockMvc.perform(post("/logout").with(csrf()).session(httpSession))
 | 
				
			||||||
				.andExpect(unauthenticated());
 | 
									.andExpect(unauthenticated());
 | 
				
			||||||
 | 
							this.mockMvc.perform(get("/user/index").session(httpSession))
 | 
				
			||||||
		this.mockMvc.perform(get("/user/index")
 | 
					 | 
				
			||||||
				.session(httpSession))
 | 
					 | 
				
			||||||
				.andExpect(unauthenticated())
 | 
									.andExpect(unauthenticated())
 | 
				
			||||||
				.andExpect(status().is3xxRedirection());
 | 
									.andExpect(status().is3xxRedirection());
 | 
				
			||||||
 | 
							// @formatter:on
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,16 +15,14 @@
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
package org.springframework.security.samples;
 | 
					package org.springframework.security.samples;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.junit.Before;
 | 
					 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
import org.junit.runner.RunWith;
 | 
					import org.junit.runner.RunWith;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
 | 
					import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
 | 
				
			||||||
 | 
					import org.springframework.boot.test.context.SpringBootTest;
 | 
				
			||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 | 
					import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 | 
				
			||||||
import org.springframework.test.context.web.WebAppConfiguration;
 | 
					 | 
				
			||||||
import org.springframework.test.web.servlet.MockMvc;
 | 
					import org.springframework.test.web.servlet.MockMvc;
 | 
				
			||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 | 
					 | 
				
			||||||
import org.springframework.web.context.WebApplicationContext;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 | 
					import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 | 
				
			||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 | 
					import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 | 
				
			||||||
| 
						 | 
					@ -34,22 +32,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 | 
				
			||||||
 * @author Joe Grandja
 | 
					 * @author Joe Grandja
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@RunWith(SpringJUnit4ClassRunner.class)
 | 
					@RunWith(SpringJUnit4ClassRunner.class)
 | 
				
			||||||
@SpringApplicationConfiguration(InsecureApplication.class)
 | 
					@SpringBootTest
 | 
				
			||||||
@WebAppConfiguration
 | 
					@AutoConfigureMockMvc
 | 
				
			||||||
public class InsecureApplicationTests {
 | 
					public class InsecureApplicationTests {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Autowired
 | 
						@Autowired
 | 
				
			||||||
	private WebApplicationContext context;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private MockMvc mockMvc;
 | 
						private MockMvc mockMvc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Before
 | 
					 | 
				
			||||||
	public void setup() {
 | 
					 | 
				
			||||||
		mockMvc = MockMvcBuilders
 | 
					 | 
				
			||||||
				.webAppContextSetup(context)
 | 
					 | 
				
			||||||
				.build();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void accessUnprotected() throws Exception {
 | 
						public void accessUnprotected() throws Exception {
 | 
				
			||||||
		this.mockMvc.perform(get("/index")).andExpect(status().isOk());
 | 
							this.mockMvc.perform(get("/index")).andExpect(status().isOk());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue