Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ spring.datasource.driver-class-name=org.postgresql.Driver
spring.flyway.locations=classpath:db/migration,classpath:db/dev-data-migration
spring.flyway.schemas=public

springdoc.api-docs.enabled=true
springdoc.api-docs.enabled=true
springdoc.show-actuator=true
5 changes: 4 additions & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ spring.flyway.locations=classpath:db/migration
# debug options
logging.level.org.flywaydb.core=warn

springdoc.api-docs.enabled=false
springdoc.api-docs.enabled=false

management.endpoint.health.show-details=when_authorized
management.endpoint.health.probes.enabled=true
Binary file added backend/src/main/resources/static/favicon.ico
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package ch.puzzle.pcts;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import org.junit.jupiter.api.DisplayName;
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.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

@SpringBootTest
@ActiveProfiles("test")
@AutoConfigureMockMvc
@Testcontainers
class ApplicationAvailabilityTest {
private static final String BASEURL = "/actuator/health/";
@Container
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:17-alpine");
@Autowired
private MockMvc mvc;

@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
}

@DisplayName("Should be healthy")
@Test
void shouldBeHealthy() throws Exception {
mvc
.perform(get(BASEURL))
.andExpect(status().isOk())
.andExpect(jsonPath("$.status").value("UP"))
.andExpect(content().string("{\"status\":\"UP\",\"groups\":[\"liveness\",\"readiness\"]}"));
}

@DisplayName("Should accept traffic")
@Test
void shouldAcceptTraffic() throws Exception {
mvc
.perform(get(BASEURL + "readiness"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.status").value("UP"))
.andExpect(content().string("{\"status\":\"UP\"}"));
}

@DisplayName("Should be live")
@Test
void shouldBeLive() throws Exception {
mvc
.perform(get(BASEURL + "liveness"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.status").value("UP"))
.andExpect(content().string("{\"status\":\"UP\"}"));
}
}
Loading