BAEL-3907: spring-security-web-boot-1 cleanup (#10657)

Co-authored-by: Krzysztof Woyke <krzysztof.woyke.sp@lhsystems.com>
This commit is contained in:
kwoyke
2021-04-23 21:35:22 +02:00
committed by GitHub
parent 09defd1b08
commit 96e97ae79b
47 changed files with 123 additions and 227 deletions
@@ -36,12 +36,15 @@ import static org.springframework.util.Assert.isTrue;
@ContextConfiguration
@DirtiesContext
public class SpringDataWithSecurityIntegrationTest {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
@Autowired
private ServletContext servletContext;
private static UserRepository userRepository;
private static TweetRepository tweetRepository;
@Autowired
private ServletContext servletContext;
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
@Before
public void testInit() {
ctx.register(AppConfig.class);
@@ -13,7 +13,7 @@ import io.restassured.specification.RequestSpecification;
import org.junit.Test;
import org.springframework.http.MediaType;
// In order to execute these tests, com.baeldung.custom.Application needs to be running.
// In order to execute these tests, com.baeldung.roles.custom.Application needs to be running.
public class ApplicationLiveTest {
@Test
@@ -36,8 +36,6 @@ public class ApplicationLiveTest {
assertTrue(response.asString().contains("id"));
}
//
@Test
public void givenUserMemberInOrganization_whenGetOrganization_thenOK() {
final Response response = givenAuth("john", "123").get("http://localhost:8082/organizations/1");
@@ -51,8 +49,6 @@ public class ApplicationLiveTest {
assertEquals(403, response.getStatusCode());
}
//
@Test
public void givenDisabledSecurityExpression_whenGetFooByName_thenError() {
final Response response = givenAuth("john", "123").get("http://localhost:8082/foos?name=sample");
@@ -60,7 +56,6 @@ public class ApplicationLiveTest {
assertTrue(response.asString().contains("method hasAuthority() not allowed"));
}
//
private RequestSpecification givenAuth(String username, String password) {
return RestAssured.given().log().uri().auth().form(username, password, new FormAuthConfig("/login","username","password"));
}
@@ -9,7 +9,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import org.apache.http.HttpHeaders;
import com.baeldung.roles.custom.Application;
import com.baeldung.roles.custom.persistence.model.Foo;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
@@ -82,8 +82,7 @@ public class CustomUserDetailsServiceIntegrationTest {
private static String asJsonString(final Object obj) throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final String jsonContent = mapper.writeValueAsString(obj);
return jsonContent;
return mapper.writeValueAsString(obj);
}
}
@@ -8,7 +8,7 @@ import io.restassured.response.Response;
import org.junit.Test;
// In order to execute these tests, com.baeldung.ip.IpApplication needs to be running.
// In order to execute these tests, com.baeldung.roles.ip.IpApplication needs to be running.
public class IpLiveTest {
@Test