|
|
|
|
@ -14,11 +14,17 @@ 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.http.HttpEntity;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
|
|
|
|
|
|
|
|
import egovframework.let.cop.bbs.service.BoardMaster;
|
|
|
|
|
import egovframework.let.cop.bbs.service.EgovBBSAttributeManageService;
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.Setter;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -29,8 +35,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
* @since 2024-09-20
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@SpringBootTest
|
|
|
|
|
@AutoConfigureMockMvc(addFilters = false)
|
|
|
|
|
//@SpringBootTest
|
|
|
|
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
|
|
|
@AutoConfigureMockMvc
|
|
|
|
|
//@AutoConfigureMockMvc(addFilters = false)
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Slf4j
|
|
|
|
|
class EgovBBSAttributeManageApiControllerTestInsertBBSMasterInfTest {
|
|
|
|
|
@ -41,6 +49,12 @@ class EgovBBSAttributeManageApiControllerTestInsertBBSMasterInfTest {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MockMvc mockMvc;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private TestRestTemplate restTemplate;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 게시판 속성정보 관리를 위한 데이터 접근 클래스
|
|
|
|
|
*/
|
|
|
|
|
@ -62,6 +76,8 @@ class EgovBBSAttributeManageApiControllerTestInsertBBSMasterInfTest {
|
|
|
|
|
|
|
|
|
|
// given
|
|
|
|
|
|
|
|
|
|
JwtResponse jwtResponse = getJwtResponse();
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
|
mockMvc.perform(
|
|
|
|
|
|
|
|
|
|
@ -71,6 +87,8 @@ class EgovBBSAttributeManageApiControllerTestInsertBBSMasterInfTest {
|
|
|
|
|
|
|
|
|
|
.param("searchWrd", boardMaster.getBbsNm())
|
|
|
|
|
|
|
|
|
|
.header("Authorization", jwtResponse.getJToken())
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
.andDo(print())
|
|
|
|
|
@ -112,4 +130,39 @@ class EgovBBSAttributeManageApiControllerTestInsertBBSMasterInfTest {
|
|
|
|
|
assertEquals("", "", "게시판 마스터 목록을 조회한다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
|
@Setter
|
|
|
|
|
static class JwtRequest {
|
|
|
|
|
private String userSe;
|
|
|
|
|
private String id;
|
|
|
|
|
private String password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
|
@Setter
|
|
|
|
|
static class JwtResponse {
|
|
|
|
|
private int resultCode;
|
|
|
|
|
private String jToken;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JwtResponse getJwtResponse() {
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
final JwtRequest jwtRequest = new JwtRequest();
|
|
|
|
|
jwtRequest.setUserSe("USR");
|
|
|
|
|
jwtRequest.setId("admin");
|
|
|
|
|
jwtRequest.setPassword("1");
|
|
|
|
|
HttpEntity<JwtRequest> request = new HttpEntity<>(jwtRequest, headers);
|
|
|
|
|
// final JwtResponse jwtResponse = restTemplate.postForObject("/auth/login-jwt", request, JwtResponse.class);
|
|
|
|
|
final String content = restTemplate.postForObject("/auth/login-jwt", request, String.class);
|
|
|
|
|
final String content2 = content.substring(content.indexOf("\"jToken\":\"") + 10);
|
|
|
|
|
final String content3 = content2.substring(0, content2.indexOf("\""));
|
|
|
|
|
// final ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
// mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
|
|
|
|
// final JwtResponse jwtResponse = mapper.readValue(content, JwtResponse.class);
|
|
|
|
|
final JwtResponse jwtResponse = new JwtResponse();
|
|
|
|
|
jwtResponse.setJToken(content3);
|
|
|
|
|
return jwtResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|