Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ev.v2 into 232-fix-admin-게임-관리-페이지에서-점수-수정-시-승패-수정-안되는-문제
  • Loading branch information
AYoungSn committed Jan 4, 2024
2 parents 6217113 + c895a3c commit 4c2acc2
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.java text=auto
*.sql text=auto
*.md text=auto
*.txt text=auto
*.gradle text=auto
Dockerfile text=auto
*.yml text=auto
*.yaml text=auto
*.sh text=auto

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
Expand All @@ -14,9 +15,11 @@
@AllArgsConstructor
public class TournamentAdminCreateRequestDto {
@NotNull(message = "제목이 필요합니다.")
@Length(max = 30, message = "제목은 30자 이내로 작성해주세요.")
private String title;

@NotNull(message = "내용이 필요합니다.")
@Length(max = 1000, message = "내용은 1000자 이내로 작성해주세요.")
private String contents;

@NotNull(message = "시작 시간이 필요합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

Expand All @@ -17,9 +18,11 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class TournamentAdminUpdateRequestDto {
@NotNull(message = "제목이 필요합니다.")
@Length(max = 30, message = "제목은 30자 이내로 작성해주세요.")
private String title;

@NotNull(message = "내용이 필요합니다.")
@Length(max = 1000, message = "내용은 1000자 이내로 작성해주세요.")
private String contents;

@NotNull(message = "시작 시간이 필요합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers("/pingpong/admin/**").hasRole("ADMIN")
.antMatchers(HttpMethod.PUT, "/pingpong/users/{intraId}").hasAnyRole("USER", "ADMIN")
.antMatchers(HttpMethod.POST, "/pingpong/match").hasAnyRole("USER", "ADMIN")
.antMatchers("/login", "/oauth2/authorization/**", "/","/pingpong/users/oauth/**",
.antMatchers(HttpMethod.POST, "/pingpong/tournaments/{tournamentId}/users").hasAnyRole("USER", "ADMIN")
.antMatchers("/login", "/oauth2/authorization/**", "/","/pingpong/users/oauth/**",
"/pingpong/users/accesstoken", "/actuator/**",
"/swagger-ui/**", "/swagger-ui**", "/v3/api-docs/**", "/v3/api-docs**", "/api-docs").permitAll()
.anyRequest().authenticated()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE tournament MODIFY COLUMN contents VARCHAR(3000);
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.gg.server.utils.TestDataUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Random;

import lombok.RequiredArgsConstructor;
import org.apache.http.HttpHeaders;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -530,6 +532,38 @@ void gameAlreadyExist() throws Exception {

System.out.println(contentAsString);
}

@Test
@DisplayName("잘못된 DTO - 길이 초과")
void invalidLength() throws Exception {
//given
String accessToken = testDataUtils.getAdminLoginAccessToken();
int leftLimit = 97; // letter 'a'
int rightLimit = 122; // letter 'z'
int targetStringLength = 3100;
Random random = new Random();
String contents = random.ints(leftLimit, rightLimit + 1)
.limit(targetStringLength)
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
.toString();
TournamentAdminCreateRequestDto createDto = new TournamentAdminCreateRequestDto(
"1st rookie tournament",
contents,
LocalDateTime.now().plusDays(3).withHour(14).withMinute(0),
LocalDateTime.now().plusDays(3).withHour(16).withMinute(0),
TournamentType.ROOKIE);

String url = "/pingpong/admin/tournaments";
String content = objectMapper.writeValueAsString(createDto);

//when, then
String contentAsString = mockMvc.perform(post(url)
.header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)
.contentType(MediaType.APPLICATION_JSON)
.content(content))
.andExpect(status().isBadRequest())
.andReturn().getResponse().getContentAsString();
}
}

@Nested
Expand Down

0 comments on commit 4c2acc2

Please sign in to comment.