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
16 changes: 16 additions & 0 deletions src/main/java/org/runimo/runimo/config/ModelResolverConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.runimo.runimo.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import io.swagger.v3.core.jackson.ModelResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
class ModelResolverConfig {

@Bean
public ModelResolver modelResolver(ObjectMapper objectMapper) {
return new ModelResolver(objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE));
}
}
10 changes: 0 additions & 10 deletions src/main/java/org/runimo/runimo/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
.oauth2Login(oAuth2Login -> {
oAuth2Login
.loginPage("/api/v1/users/auth/login")
.failureHandler(customAuthenticationFailureHandler);
})
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/api/v1/users/auth/**").permitAll()
.anyRequest().authenticated()
Expand All @@ -51,11 +46,6 @@ public SecurityFilterChain devSecurityFilterChain(HttpSecurity http) throws Exce
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
.oauth2Login(oAuth2Login -> {
oAuth2Login
.loginPage("/api/v1/users/auth/login")
.failureHandler(customAuthenticationFailureHandler);
})
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/api/v1/users/auth/**").permitAll()
.requestMatchers("/swagger-ui/**", "/swagger-ui.html", "/v3/api-docs/**").permitAll()
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/runimo/runimo/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package org.runimo.runimo.config;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;

@Configuration
public class SwaggerConfig {

@Bean
public OpenAPI customOpenAPI() {

Server server = new Server();
server.setUrl("https://toy.hyeonjae.dev");

return new OpenAPI()
.info(new Info()
.title("Runimo User API")
Expand All @@ -26,6 +35,7 @@ public OpenAPI customOpenAPI() {
.name("Apache 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0"))
).addSecurityItem(new SecurityRequirement().addList("JWT"))
.servers(Collections.singletonList(server))
.components(new io.swagger.v3.oas.models.Components()
.addSecuritySchemes("JWT",
new SecurityScheme()
Expand All @@ -34,5 +44,10 @@ public OpenAPI customOpenAPI() {
.scheme("bearer")
.bearerFormat("JWT")));
}

@Bean
public Jackson2ObjectMapperBuilderCustomizer customizer() {
return builder -> builder.propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public ResponseEntity<ErrorResponse> handleNoSuchElementException(NoSuchElementE
@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<ErrorResponse> handleIllegalArgumentException(IllegalArgumentException e) {
log.debug("ERROR: {}}", e.getMessage(), e);
return ResponseEntity.badRequest().build();
return ResponseEntity.badRequest().body(ErrorResponse.of("잘못된 요청입니다.", e.getMessage()));
}

@ExceptionHandler(IllegalStateException.class)
public ResponseEntity<ErrorResponse> handleIllegalStateException(IllegalStateException e) {
log.debug("ERROR: {}}", e.getMessage(), e);
return ResponseEntity.badRequest().build();
return ResponseEntity.badRequest().body(ErrorResponse.of("잘못된 요청입니다.", e.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AuthResponse validateAndLogin(final String rawToken, final SocialProvider
String pid = oidcService.validateOidcTokenAndGetProviderId(token, provider);
OAuthInfo oAuthInfo = oAuthInfoRepository.findByProviderAndProviderId(provider, pid)
.orElseThrow(() -> new SignUpException(UserHttpResponseCode.LOGIN_FAIL_NOT_SIGN_IN));
oidcNonceService.useNonce(token, provider);
//oidcNonceService.useNonce(token, provider);
TokenPair tokenPair = jwtfactory.generateTokenPair(oAuthInfo.getUser());
return new AuthResponse(oAuthInfo.getUser(), tokenPair);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.jdbc.Sql;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;

Expand Down Expand Up @@ -44,7 +47,7 @@ void tearDown() {
void 마이페이지_조회_시_프로필정보와_최근_달리기가_표시된다() {

String accessToken = "Bearer " + jwtTokenFactory.generateAccessToken("test-user-uuid-1");

int diff = (int) LocalDateTime.parse("2025-03-29T13:00:00").until(LocalDateTime.now(), ChronoUnit.DAYS);
given()
.header("Authorization", accessToken)
.contentType(ContentType.JSON)
Expand All @@ -57,7 +60,7 @@ void tearDown() {
.body("payload.nickname", equalTo("Daniel"))
.body("payload.profile_image_url", equalTo("https://example.com/images/user1.png"))
.body("payload.total_distance_in_meters", equalTo(10000))
.body("payload.latest_run_date_before", equalTo(2))
.body("payload.latest_run_date_before", equalTo(diff))
.body("payload.latest_running_record.title", equalTo("record-title-2"))
.body("payload.latest_running_record.start_date_time", equalTo("2025-03-29T13:00:00"))
.body("payload.latest_running_record.distance_in_meters", equalTo(2345))
Expand Down