feat: upgrade to Spring Boot version 3 (#1477)

This commit is contained in:
Nanne Baars
2023-06-04 11:19:47 +02:00
committed by GitHub
parent ff3a2983e2
commit ca886b4818
126 changed files with 520 additions and 479 deletions

View File

@ -2,10 +2,10 @@ package org.owasp.webgoat.container.plugins;
import static org.mockito.Mockito.when;
import jakarta.annotation.PostConstruct;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
import javax.annotation.PostConstruct;
import org.flywaydb.core.Flyway;
import org.junit.jupiter.api.BeforeEach;
import org.owasp.webgoat.container.WebGoat;

View File

@ -28,7 +28,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import javax.servlet.http.Cookie;
import jakarta.servlet.http.Cookie;
import org.hamcrest.core.StringContains;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

View File

@ -30,7 +30,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import javax.servlet.http.Cookie;
import jakarta.servlet.http.Cookie;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

View File

@ -34,8 +34,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import jakarta.servlet.http.Cookie;
import java.util.Map;
import javax.servlet.http.Cookie;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -250,7 +250,7 @@ public class JWTVotesEndpointTest extends LessonTest {
mockMvc
.perform(
MockMvcRequestBuilders.get("/JWT/votings/").cookie(new Cookie("access_token", token)))
MockMvcRequestBuilders.get("/JWT/votings").cookie(new Cookie("access_token", token)))
.andExpect(status().isOk())
.andExpect(jsonPath("$[0].numberOfVotes").doesNotExist())
.andExpect(jsonPath("$[0].votingAllowed").doesNotExist())

View File

@ -30,8 +30,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import jakarta.servlet.http.Cookie;
import java.util.stream.Stream;
import javax.servlet.http.Cookie;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;

View File

@ -78,13 +78,7 @@ class BlindSendFileAssignmentTest extends LessonTest {
.andExpect(
jsonPath("$.feedback", CoreMatchers.is(messages.getMessage("assignment.not.solved"))))
.andExpect(
jsonPath(
"$.output",
CoreMatchers.startsWith(
"javax.xml.bind.UnmarshalException\\n"
+ " - with linked exception:\\n"
+ "[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,22]\\n"
+ "Message:")));
jsonPath("$.output", CoreMatchers.startsWith("jakarta.xml.bind.UnmarshalException")));
}
@Test

View File

@ -87,15 +87,12 @@ public class SimpleXXETest extends LessonTest {
}
@Test
public void postingPlainTextShouldShwoException() throws Exception {
public void postingPlainTextShouldThrowException() throws Exception {
mockMvc
.perform(MockMvcRequestBuilders.post("/xxe/simple").content("test"))
.andExpect(status().isOk())
.andExpect(
jsonPath(
"$.output",
CoreMatchers.startsWith(
"javax.xml.bind.UnmarshalException\\n - with linked exception")))
jsonPath("$.output", CoreMatchers.startsWith("jakarta.xml.bind.UnmarshalException")))
.andExpect(
jsonPath("$.feedback", CoreMatchers.is(messages.getMessage("assignment.not.solved"))));
}

View File

@ -24,6 +24,7 @@ package org.owasp.webgoat.webwolf.mailbox;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
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.result.MockMvcResultMatchers.content;
@ -38,15 +39,18 @@ import java.time.format.DateTimeFormatter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.owasp.webgoat.webwolf.WebSecurityConfig;
import org.owasp.webgoat.webwolf.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
@WebMvcTest(MailboxController.class)
@Import(WebSecurityConfig.class)
public class MailboxControllerTest {
@Autowired private MockMvc mvc;
@ -63,7 +67,6 @@ public class MailboxControllerTest {
}
@Test
@WithMockUser
public void sendingMailShouldStoreIt() throws Exception {
Email email =
Email.builder()
@ -76,6 +79,7 @@ public class MailboxControllerTest {
this.mvc
.perform(
post("/mail")
.with(csrf())
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsBytes(email)))
.andExpect(status().isCreated());