adding security for testing purpose
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
//package com.baeldung.boot;
|
||||
//
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
//
|
||||
//
|
||||
//@Configuration
|
||||
//@EnableWebSecurity
|
||||
//public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
//
|
||||
// @Override
|
||||
// protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// auth.inMemoryAuthentication()
|
||||
// .withUser("john")
|
||||
// .password("{noop}123")
|
||||
// .roles("USER");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void configure(HttpSecurity http) throws Exception {
|
||||
// http.authorizeRequests()
|
||||
// .antMatchers("/hello")
|
||||
// .permitAll()
|
||||
// .anyRequest()
|
||||
// .authenticated()
|
||||
// .and()
|
||||
// .httpBasic();
|
||||
// }
|
||||
//}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.boot.controller.rest;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class HomeController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String salutation() {
|
||||
return "Welcome !";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
# security
|
||||
spring.security.user.name=john
|
||||
spring.security.user.password=123
|
||||
+1
-1
@@ -10,7 +10,7 @@ import spock.lang.Title
|
||||
@Title("Application Specification")
|
||||
@Narrative("Specification which beans are expected")
|
||||
@SpringBootTest
|
||||
class LoadContextTest extends Specification {
|
||||
class LoadContextIntegrationTest extends Specification {
|
||||
|
||||
@Autowired(required = false)
|
||||
private WebController webController
|
||||
+3
-3
@@ -12,9 +12,9 @@ import spock.lang.Title
|
||||
|
||||
@Title("WebController Specification")
|
||||
@Narrative("The Specification of the behaviour of the WebController. It can greet a person, change the name and reset it to 'world'")
|
||||
@AutoConfigureMockMvc
|
||||
@WebMvcTest
|
||||
class WebControllerTest extends Specification {
|
||||
@AutoConfigureMockMvc(secure=false)
|
||||
@WebMvcTest()
|
||||
class WebControllerIntegrationTest extends Specification {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mvc
|
||||
Binary file not shown.
Reference in New Issue
Block a user