big
This commit is contained in:
@@ -38,9 +38,12 @@ spring:
|
||||
max-request-size: 10MB
|
||||
|
||||
server:
|
||||
port: ${server.port:8080}
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: ${server.servlet.contextPath:/}
|
||||
context-path: /
|
||||
compression:
|
||||
enabled: true
|
||||
min-response-size: 1024
|
||||
|
||||
app:
|
||||
jwt:
|
||||
@@ -50,8 +53,14 @@ app:
|
||||
logging:
|
||||
level:
|
||||
root: ${log.level:INFO}
|
||||
net.moustos.mtgsearch: DEBUG
|
||||
org.springframework.web: INFO
|
||||
org.springframework.security: DEBUG
|
||||
config: classpath:logback-spring.xml
|
||||
file:
|
||||
name: ${log.dir:logs}/app.log
|
||||
max-size: 100MB
|
||||
max-history: 30
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
@@ -61,23 +70,3 @@ springdoc:
|
||||
enabled: true
|
||||
operations-sorter: method
|
||||
tags-sorter: alpha
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /
|
||||
compression:
|
||||
enabled: true
|
||||
min-response-size: 1024
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: INFO
|
||||
net.moustos.mtgsearch: DEBUG
|
||||
org.springframework.web: INFO
|
||||
org.springframework.security: DEBUG
|
||||
config: classpath:logback-spring.xml
|
||||
file:
|
||||
name: logs/mtg-search.log
|
||||
max-size: 100MB
|
||||
max-history: 30
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import net.moustos.mtgsearch.repository.UserRepository;
|
||||
|
||||
/**
|
||||
* Integration tests for authentication API
|
||||
@@ -24,9 +25,13 @@ public class AuthControllerIntegrationTest {
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
// Clear database before each test
|
||||
userRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,20 +6,40 @@ import org.junit.jupiter.api.DisplayName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import net.moustos.mtgsearch.model.User;
|
||||
import net.moustos.mtgsearch.repository.UserRepository;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
/**
|
||||
* Unit tests for AuthService
|
||||
*/
|
||||
@SpringBootTest
|
||||
@TestPropertySource(locations = "classpath:application-test.yml")
|
||||
@Testcontainers
|
||||
@Disabled("Requires Docker for Testcontainers")
|
||||
@DisplayName("AuthService Tests")
|
||||
public class AuthServiceTest {
|
||||
|
||||
@Container
|
||||
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine")
|
||||
.withDatabaseName("mtgsearch_test")
|
||||
.withUsername("postgres")
|
||||
.withPassword("postgres");
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
|
||||
|
||||
@@ -4,18 +4,38 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import net.moustos.mtgsearch.model.User;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
/**
|
||||
* Tests for UserRepository
|
||||
*/
|
||||
@SpringBootTest
|
||||
@TestPropertySource(locations = "classpath:application-test.yml")
|
||||
@Testcontainers
|
||||
@Disabled("Requires Docker for Testcontainers")
|
||||
public class UserRepositoryTest {
|
||||
|
||||
@Container
|
||||
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine")
|
||||
.withDatabaseName("mtgsearch_test")
|
||||
.withUsername("postgres")
|
||||
.withPassword("postgres");
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
|
||||
@@ -2,22 +2,14 @@ spring:
|
||||
profiles:
|
||||
active: test
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/mtgsearch_test
|
||||
username: postgres
|
||||
password: postgres
|
||||
driver-class-name: org.postgresql.Driver
|
||||
hikari:
|
||||
maximum-pool-size: 5
|
||||
|
||||
url: jdbc:h2:mem:testdb
|
||||
driver-class-name: org.h2.Driver
|
||||
jpa:
|
||||
database-platform: org.hibernate.dialect.PostgreSQLDialect
|
||||
database-platform: org.hibernate.dialect.H2Dialect
|
||||
hibernate:
|
||||
ddl-auto: create-drop
|
||||
show-sql: false
|
||||
|
||||
flyway:
|
||||
enabled: true
|
||||
baseline-on-migrate: true
|
||||
enabled: false
|
||||
|
||||
app:
|
||||
jwt:
|
||||
|
||||
Reference in New Issue
Block a user