diff --git a/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAllNotAuthenticated.java b/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAllNotAuthenticated.java new file mode 100644 index 0000000..8c62848 --- /dev/null +++ b/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAllNotAuthenticated.java @@ -0,0 +1,37 @@ +package de.szut.lf8_starter.integration.project; + +import de.szut.lf8_starter.project.ProjectEntity; +import de.szut.lf8_starter.project.ProjectRepository; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.test.web.servlet.MockMvc; + +import java.time.LocalDate; +import java.util.List; + +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc(addFilters = true) +public class ProjectFindAllNotAuthenticated { + @Autowired + private ProjectRepository projectRepository; + + @Autowired + private MockMvc mockMvc; + + @Autowired + private TestRestTemplate restTemplate; + + @Test + void findAllProjects() throws Exception { + this.mockMvc.perform(get("/projects")) + .andExpect(status().isUnauthorized()); + } +} diff --git a/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAll.java b/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAllSuccess.java similarity index 96% rename from src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAll.java rename to src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAllSuccess.java index 361e585..906b63f 100644 --- a/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAll.java +++ b/src/test/java/de/szut/lf8_starter/integration/project/ProjectFindAllSuccess.java @@ -5,7 +5,6 @@ import de.szut.lf8_starter.project.ProjectRepository; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.test.web.servlet.MockMvc; @@ -20,7 +19,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc(addFilters = false) -public class ProjectFindAll { +public class ProjectFindAllSuccess { @Autowired private ProjectRepository projectRepository;