Initial commit

This commit is contained in:
jooho
2021-10-20 17:12:00 +09:00
parent 0c884beff8
commit 8caa4bbc5a
487 changed files with 44198 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
package org.egovframe.cloud.userservice;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class UserServiceApplicationTests {
@Test
void contextLoads() {
}
}

View File

@@ -0,0 +1,143 @@
package org.egovframe.cloud.userservice.api;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import org.egovframe.cloud.common.domain.Role;
import org.egovframe.cloud.userservice.api.user.dto.UserResponseDto;
import org.egovframe.cloud.userservice.api.user.dto.UserSaveRequestDto;
import org.egovframe.cloud.userservice.api.user.dto.UserUpdateRequestDto;
import org.egovframe.cloud.userservice.domain.user.User;
import org.egovframe.cloud.userservice.domain.user.UserRepository;
import org.egovframe.cloud.userservice.service.user.UserService;
import org.json.JSONObject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.web.client.RestClientException;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class UserApiControllerTest {
@Autowired
private UserRepository userRepository;
@Autowired
private UserService userService;
@Autowired
private TestRestTemplate restTemplate;
// private static final String USER_SERVICE_URL = "http://localhost:8000/user-service";
private static final String TEST_COM = "@test.com";
private static final String TEST_EMAIL = System.currentTimeMillis() + TEST_COM;
private static final String TEST_PASSWORD = "test1234!";
@Test
@Order(Integer.MAX_VALUE)
public void cleanup() throws Exception {
// 테스트 후 데이터 삭제
List<User> users = userRepository.findByEmailContains("test.com");
users.forEach(user -> userRepository.deleteById(user.getId()));
}
@Test
@Order(Integer.MIN_VALUE)
public void 사용자_등록된다() throws Exception {
// given
UserSaveRequestDto userSaveRequestDto = UserSaveRequestDto.builder()
.userName("사용자")
.email(TEST_EMAIL)
.password(TEST_PASSWORD)
.roleId(Role.USER.getKey())
.userStateCode("01")
.build();
userService.save(userSaveRequestDto);
// when
UserResponseDto findUser = userService.findByEmail(TEST_EMAIL);
// then
assertThat(findUser.getEmail()).isEqualTo(TEST_EMAIL);
}
@Test
@Order(2)
public void 사용자_수정된다() throws Exception {
// given
UserResponseDto findUser = userService.findByEmail(TEST_EMAIL);
UserUpdateRequestDto userUpdateRequestDto = UserUpdateRequestDto.builder()
.userName("사용자수정")
.email(TEST_EMAIL)
.roleId(Role.USER.getKey())
.userStateCode("01")
.build();
// when
userService.update(findUser.getUserId(), userUpdateRequestDto);
UserResponseDto updatedUser = userService.findByEmail(TEST_EMAIL);
// then
assertThat(updatedUser.getUserName()).isEqualTo("사용자수정");
}
@Test
public void 사용자_등록오류() throws Exception {
// given
UserSaveRequestDto userSaveRequestDto = UserSaveRequestDto.builder()
.userName("사용자")
.email("email")
.password("test")
.build();
String url = "/api/v1/users";
RestClientException restClientException = Assertions.assertThrows(RestClientException.class, () -> {
restTemplate.postForEntity(url, userSaveRequestDto, Long.class);
});
System.out.println("restClientException.getMessage() = " + restClientException.getMessage());
}
@Test
public void 사용자_로그인된다() throws Exception {
// given
JSONObject loginJson = new JSONObject();
loginJson.put("email", TEST_EMAIL);
loginJson.put("password", TEST_PASSWORD);
String url = "/login";
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, loginJson.toString(), String.class);
responseEntity.getHeaders().entrySet().forEach(System.out::println);
assertThat(responseEntity.getHeaders().containsKey("access-token")).isTrue();
}
@Test
public void 사용자_로그인_오류발생한다() throws Exception {
// given
JSONObject loginJson = new JSONObject();
loginJson.put("email", TEST_EMAIL);
loginJson.put("password", "test");
String url = "/login";
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, loginJson.toString(), String.class);
System.out.println("responseEntity = " + responseEntity);
assertThat(responseEntity.getHeaders().containsKey("access-token")).isFalse();
}
}

View File

@@ -0,0 +1,403 @@
package org.egovframe.cloud.userservice.api.role;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.egovframe.cloud.userservice.domain.role.Authorization;
import org.egovframe.cloud.userservice.domain.role.AuthorizationRepository;
import org.egovframe.cloud.userservice.domain.role.RoleAuthorization;
import org.egovframe.cloud.userservice.domain.role.RoleAuthorizationRepository;
import org.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* org.egovframe.cloud.userservice.api.role.AuthorizationApiControllerTest
* <p>
* 인가 Rest API 컨트롤러 테스트 클래스
*
* @author 표준프레임워크센터 jooho
* @version 1.0
* @since 2021/07/08
*
* <pre>
* << 개정이력(Modification Information) >>
*
* 수정일 수정자 수정내용
* ---------- -------- ---------------------------
* 2021/07/08 jooho 최초 생성
* </pre>
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class AuthorizationApiControllerTest {
/**
* WebApplicationContext
*/
@Autowired
private WebApplicationContext context;
/**
* MockMvc
*/
private MockMvc mvc;
/**
* ObjectMapper
*/
@Autowired
private ObjectMapper objectMapper;
/**
* test rest template
*/
@Autowired
TestRestTemplate restTemplate;
/**
* 인가 레파지토리 인터페이스
*/
@Autowired
AuthorizationRepository authorizationRepository;
/**
* 권한 인가 레파지토리 인터페이스
*/
@Autowired
RoleAuthorizationRepository roleAuthorizationRepository;
/**
* 인가 API 경로
*/
private static final String URL = "/api/v1/authorizations";
/**
* 테스트 데이터 등록 횟수
*/
private final Integer GIVEN_DATA_COUNT = 10;
/**
* 테스트 데이터
*/
private final String AUTHORIZATION_NAME_PREFIX = "인가 명";
//private final String URL_PATTERN_VALUE_PREFIX = "URL 패턴 값";
private final String URL_PATTERN_VALUE_PREFIX = "/api/v1/authorizations";
//private final String HTTP_METHOD_VALUE_PREFIX = "Http Method 코드";
private final String HTTP_METHOD_VALUE_PREFIX = "GET";
private final String INSERT_AUTHORIZATION_NAME = AUTHORIZATION_NAME_PREFIX + "_1";
private final String INSERT_URL_PATTERN_VALUE = URL_PATTERN_VALUE_PREFIX + "_1";
private final String INSERT_HTTP_METHOD_VALUE = HTTP_METHOD_VALUE_PREFIX + "_1";
private final Integer INSERT_SORT_SEQ = 2;
private final String UPDATE_AUTHORIZATION_NAME = AUTHORIZATION_NAME_PREFIX + "_2";
private final String UPDATE_URL_PATTERN_VALUE = URL_PATTERN_VALUE_PREFIX + "_";
private final String UPDATE_HTTP_METHOD_VALUE = HTTP_METHOD_VALUE_PREFIX + "_";
private final Integer UPDATE_SORT_SEQ = 2;
/**
* 테스트 데이터
*/
private List<Authorization> testDatas = new ArrayList<>();
/**
* 테스트 시작 전 수행
*/
@BeforeEach
void setUp() {
mvc = MockMvcBuilders.webAppContextSetup(context)
.addFilter(new CharacterEncodingFilter("UTF-8"))
.apply(SecurityMockMvcConfigurers.springSecurity())
.build();
}
/**
* 테스트 종료 후 수행
*/
@AfterEach
void tearDown() {
}
/**
* 인가 페이지 목록 조회 테스트
*/
@Test
@WithMockUser(roles = "ADMIN")
void 인가_페이지_목록_조회() throws Exception {
// given
insertTestDatas();
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("keywordType", "authorizationName");
params.add("keyword", AUTHORIZATION_NAME_PREFIX);
params.add("page", "0");
params.add("size", "10");
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.get(URL)
.params(params));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
// .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.numberOfElements").value(GIVEN_DATA_COUNT))
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].authorizationName").value(AUTHORIZATION_NAME_PREFIX + "_1"));
deleteTestDatas();
}
/**
* 인가 상세 조회 테스트
*/
@Test
@WithMockUser(roles = "ADMIN")
void 인가_상세_조회() throws Exception {
// given
Authorization entity = insertTestData();
final Integer authorizationNo = entity.getAuthorizationNo();
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.get(URL + "/" + authorizationNo));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.authorizationNo").value(authorizationNo))
.andExpect(MockMvcResultMatchers.jsonPath("$.authorizationName").value(INSERT_AUTHORIZATION_NAME))
.andExpect(MockMvcResultMatchers.jsonPath("$.urlPatternValue").value(INSERT_URL_PATTERN_VALUE))
.andExpect(MockMvcResultMatchers.jsonPath("$.httpMethodCode").value(INSERT_HTTP_METHOD_VALUE))
.andExpect(MockMvcResultMatchers.jsonPath("$.sortSeq").value(INSERT_SORT_SEQ));
deleteTestData(authorizationNo);
}
/**
* 인가 다음 정렬 순서 조회
*/
@Test
@WithMockUser(roles = "ADMIN")
void 인가_다음정렬순서_조회() throws Exception {
// given
insertTestDatas();
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.get(URL + "/sort-seq/next"));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
// .andExpect(MockMvcResultMatchers.content().string("11"));
.andExpect(MockMvcResultMatchers.content().string("129")); // /src/test/resources/h2/data.sql 초기화 데이터의 마지막 순번 + 1
deleteTestDatas();
}
/**
* 인가 등록 테스트
*/
@Test
@WithMockUser(roles = "ADMIN")
void 인가_등록() throws Exception {
// given
Map<String, Object> params = new HashMap<>();
params.put("authorizationName", INSERT_AUTHORIZATION_NAME);
params.put("urlPatternValue", INSERT_URL_PATTERN_VALUE);
params.put("httpMethodCode", INSERT_HTTP_METHOD_VALUE);
params.put("sortSeq", INSERT_SORT_SEQ);
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.post(URL)
.accept(MediaType.APPLICATION_JSON)
.contentType("application/json;charset=UTF-8")
.content(objectMapper.writeValueAsString(params)));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk());
String responseData = resultActions.andReturn().getResponse().getContentAsString();
JSONObject jsonObject = new JSONObject(responseData);
final Integer authorizationNo = Integer.parseInt(jsonObject.get("authorizationNo").toString());
Optional<Authorization> authorization = selectData(authorizationNo);
assertThat(authorization).isPresent();
Authorization entity = authorization.get();
assertThat(entity.getAuthorizationNo()).isEqualTo(authorizationNo);
assertThat(entity.getAuthorizationName()).isEqualTo(INSERT_AUTHORIZATION_NAME);
assertThat(entity.getUrlPatternValue()).isEqualTo(INSERT_URL_PATTERN_VALUE);
assertThat(entity.getHttpMethodCode()).isEqualTo(INSERT_HTTP_METHOD_VALUE);
assertThat(entity.getSortSeq()).isEqualTo(INSERT_SORT_SEQ);
deleteTestData(authorizationNo);
}
/**
* 인가 수정 테스트
*/
@Test
@WithMockUser(roles = "ADMIN")
void 인가_수정() throws Exception {
// given
Authorization entity = insertTestData();
final Integer authorizationNo = entity.getAuthorizationNo();
Map<String, Object> params = new HashMap<>();
params.put("authorizationName", UPDATE_AUTHORIZATION_NAME);
params.put("urlPatternValue", UPDATE_URL_PATTERN_VALUE);
params.put("httpMethodCode", UPDATE_HTTP_METHOD_VALUE);
params.put("sortSeq", UPDATE_SORT_SEQ);
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.put(URL + "/" + authorizationNo)
.accept(MediaType.APPLICATION_JSON)
.contentType("application/json;charset=UTF-8")
.content(objectMapper.writeValueAsString(params)));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk());
Optional<Authorization> authorization = selectData(authorizationNo);
assertThat(authorization).isPresent();
Authorization updatedAuthorization = authorization.get();
assertThat(updatedAuthorization.getAuthorizationNo()).isEqualTo(authorizationNo);
assertThat(updatedAuthorization.getAuthorizationName()).isEqualTo(UPDATE_AUTHORIZATION_NAME);
assertThat(updatedAuthorization.getUrlPatternValue()).isEqualTo(UPDATE_URL_PATTERN_VALUE);
assertThat(updatedAuthorization.getHttpMethodCode()).isEqualTo(UPDATE_HTTP_METHOD_VALUE);
assertThat(updatedAuthorization.getSortSeq()).isEqualTo(UPDATE_SORT_SEQ);
deleteTestData(authorizationNo);
}
/**
* 인가 삭제 테스트
*/
@Test
@WithMockUser(roles = "ADMIN")
void 인가_삭제() throws Exception {
// given
Authorization entity = insertTestData();
final Integer authorizationNo = entity.getAuthorizationNo();
// 권한 인가 2건 등록 후 같이 삭제
roleAuthorizationRepository.save(RoleAuthorization.builder()
.roleId("ROLE_1")
.authorizationNo(authorizationNo)
.build());
roleAuthorizationRepository.save(RoleAuthorization.builder()
.roleId("ROLE_2")
.authorizationNo(authorizationNo)
.build());
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.delete(URL + "/" + authorizationNo));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk());
Optional<Authorization> authorization = selectData(authorizationNo);
assertThat(authorization).isNotPresent();
}
/**
* 테스트 데이터 등록
*/
private void insertTestDatas() {
for (int i = 1; i <= GIVEN_DATA_COUNT; i++) {
testDatas.add(authorizationRepository.save(Authorization.builder()
.authorizationName(AUTHORIZATION_NAME_PREFIX + "_" + i)
.urlPatternValue(URL_PATTERN_VALUE_PREFIX + "_" + i)
.httpMethodCode(HTTP_METHOD_VALUE_PREFIX + "_" + i)
.sortSeq(i)
.build()));
}
}
/**
* 테스트 데이터 삭제
*/
private void deleteTestDatas() {
if (testDatas != null) {
if (!testDatas.isEmpty()) authorizationRepository.deleteAll(testDatas);
testDatas.clear();
}
}
/**
* 테스트 데이터 단건 등록
*
* @return Authorization 인가 엔티티
*/
private Authorization insertTestData() {
return authorizationRepository.save(Authorization.builder()
.authorizationName(INSERT_AUTHORIZATION_NAME)
.urlPatternValue(INSERT_URL_PATTERN_VALUE)
.httpMethodCode(INSERT_HTTP_METHOD_VALUE)
.sortSeq(INSERT_SORT_SEQ)
.build());
}
/**
* 테스트 데이터 단건 삭제
*/
private void deleteTestData(Integer authorizationNo) {
authorizationRepository.deleteById(authorizationNo);
}
/**
* 테스트 데이터 단건 조회
*
* @param authorizationNo 인가 번호
* @return Optional<Authorization> 인가 엔티티
*/
private Optional<Authorization> selectData(Integer authorizationNo) {
return authorizationRepository.findById(authorizationNo);
}
}

View File

@@ -0,0 +1,182 @@
package org.egovframe.cloud.userservice.api.role;
import java.util.ArrayList;
import java.util.List;
import org.egovframe.cloud.userservice.domain.role.Role;
import org.egovframe.cloud.userservice.domain.role.RoleRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
/**
* org.egovframe.cloud.userservice.api.role.RoleApiControllerTest
* <p>
* 권한 Rest API 컨트롤러 테스트 클래스
*
* @author 표준프레임워크센터 jooho
* @version 1.0
* @since 2021/07/07
*
* <pre>
* << 개정이력(Modification Information) >>
*
* 수정일 수정자 수정내용
* ---------- -------- ---------------------------
* 2021/07/07 jooho 최초 생성
* </pre>
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class RoleApiControllerTest {
/**
* WebApplicationContext
*/
@Autowired
private WebApplicationContext context;
/**
* MockMvc
*/
private MockMvc mvc;
/**
* 권한 레파지토리 인터페이스
*/
@Autowired
private RoleRepository roleRepository;
/**
* 권한 API 경로
*/
private static final String URL = "/api/v1/roles";
private static final Integer GIVEN_DATA_COUNT = 4;
private static final String ROLE_ID_PREFIX = "_ROLE_";
private static final String ROLE_NAME_PREFIX = "권한 명 테스트";
private static final String ROLE_CONTENT_PREFIX = "권한 내용";
/**
* 테스트 데이터
*/
private List<Role> testDatas = new ArrayList<>();
/**
* 테스트 시작 전
*/
@BeforeEach
void setUp() {
mvc = MockMvcBuilders.webAppContextSetup(context)
.addFilter(new CharacterEncodingFilter("UTF-8"))
.apply(SecurityMockMvcConfigurers.springSecurity())
.build();
}
/**
* 테스트 종료 후
*/
@BeforeEach
void tearDown() {
}
/**
* 권한 페이지 목록 조회 테스트
*/
@Test
@WithMockUser(roles = "ADMIN")
void 권한_페이지_목록_조회() throws Exception {
// given
insertTestDatas();
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("keywordType", "roleName");
params.add("keyword", ROLE_NAME_PREFIX);
params.add("page", "0");
params.add("size", "10");
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.get(URL)
.params(params));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.numberOfElements").value(GIVEN_DATA_COUNT))
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].roleId").value(ROLE_ID_PREFIX + "_1"));
deleteTestDatas();
}
/**
* 권한 전체 목록 조회 테스트
*/
@Test
@WithMockUser(roles = "ADMIN")
void 권한_전체_목록_조회() throws Exception {
// given
insertTestDatas();
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.get(URL + "/all"));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].roleId").value(ROLE_ID_PREFIX + "_1"));
deleteTestDatas();
}
/**
* 테스트 데이터 등록
*/
private void insertTestDatas() {
for (int i = 1; i <= GIVEN_DATA_COUNT; i++) {
String roleId = ROLE_ID_PREFIX + "_" + i;
String roleName = ROLE_NAME_PREFIX + "_" + i;
String roleContent = ROLE_CONTENT_PREFIX + "_" + i;
testDatas.add(roleRepository.save(Role.builder()
.roleId(roleId)
.roleName(roleName)
.roleContent(roleContent)
.sortSeq(i)
.build()));
}
}
/**
* 테스트 데이터 삭제
*/
private void deleteTestDatas() {
roleRepository.deleteAll(testDatas);
testDatas.clear();
}
}

View File

@@ -0,0 +1,370 @@
package org.egovframe.cloud.userservice.api.role;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.assertj.core.api.Condition;
import org.egovframe.cloud.userservice.domain.role.Authorization;
import org.egovframe.cloud.userservice.domain.role.AuthorizationRepository;
import org.egovframe.cloud.userservice.domain.role.Role;
import org.egovframe.cloud.userservice.domain.role.RoleAuthorization;
import org.egovframe.cloud.userservice.domain.role.RoleAuthorizationId;
import org.egovframe.cloud.userservice.domain.role.RoleAuthorizationRepository;
import org.egovframe.cloud.userservice.domain.role.RoleRepository;
import org.json.JSONArray;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* org.egovframe.cloud.userservice.api.role.RoleAuthorizationApiControllerTest
* <p>
* 권한 인가 Rest API 컨트롤러 테스트 클래스
*
* @author 표준프레임워크센터 jooho
* @version 1.0
* @since 2021/07/12
*
* <pre>
* << 개정이력(Modification Information) >>
*
* 수정일 수정자 수정내용
* ---------- -------- ---------------------------
* 2021/07/12 jooho 최초 생성
* </pre>
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnableConfigurationProperties
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
@ActiveProfiles(profiles = "test")
class RoleAuthorizationApiControllerTest {
/**
* WebApplicationContext
*/
@Autowired
private WebApplicationContext context;
/**
* MockMvc
*/
private MockMvc mvc;
/**
* ObjectMapper
*/
@Autowired
private ObjectMapper objectMapper;
/**
* 권한 레파지토리 인터페이스
*/
@Autowired
RoleRepository roleRepository;
/**
* 인가 레파지토리 인터페이스
*/
@Autowired
AuthorizationRepository authorizationRepository;
/**
* 권한 인가 레파지토리 인터페이스
*/
@Autowired
RoleAuthorizationRepository roleAuthorizationRepository;
/**
* 인가 API 경로
*/
private static final String URL = "/api/v1/role-authorizations";
/**
* 테스트 데이터 등록 횟수
*/
private final Integer GIVEN_AUTHORIZATION_COUNT = 5;
private final String ROLE_ID = "_ROLE_1";
private final String ROLE_NAME = "권한 명_1";
private final String ROLE_CONTENT = "권한 내용_1";
private final String AUTHORIZATION_NAME_PREFIX = "인가 명";
private final String URL_PATTERN_VALUE_PREFIX = "/api/v1/test";
private final String HTTP_METHOD_VALUE_PREFIX = "GET";
/**
* 테스트 데이터
*/
private Role role = null;
private final List<Authorization> authorizations = new ArrayList<>();
private final List<RoleAuthorization> testDatas = new ArrayList<>();
/**
* 테스트 시작 전 수행
*/
@BeforeEach
void setUp() {
mvc = MockMvcBuilders.webAppContextSetup(context)
.addFilter(new CharacterEncodingFilter("UTF-8"))
.apply(SecurityMockMvcConfigurers.springSecurity())
.build();
// 권한 등록
role = roleRepository.save(Role.builder()
.roleId(ROLE_ID)
.roleName(ROLE_NAME)
.roleContent(ROLE_CONTENT)
.sortSeq(1)
.build());
// 인가 등록
for (int i = 1; i <= GIVEN_AUTHORIZATION_COUNT; i++) {
authorizations.add(authorizationRepository.save(Authorization.builder()
.authorizationName(AUTHORIZATION_NAME_PREFIX + "_" + i)
.urlPatternValue(URL_PATTERN_VALUE_PREFIX + "_" + i)
.httpMethodCode(HTTP_METHOD_VALUE_PREFIX + "_" + i)
.sortSeq(i)
.build()));
}
}
/**
* 테스트 종료 후 수행
*/
@AfterEach
void tearDown() {
// 인가 삭제
authorizationRepository.deleteAll(authorizations);
authorizations.clear();
// 권한 삭제
roleRepository.delete(role);
}
/**
* 권한 인가 페이지 목록 조회
*/
@Test
@WithMockUser(roles = "ADMIN")
void 권한_인가_페이지_목록_조회() throws Exception {
// given
insertTestDatas();
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("roleId", role.getRoleId());
params.add("keywordType", "urlPatternValue");
params.add("keyword", URL_PATTERN_VALUE_PREFIX);
params.add("page", "0");
params.add("size", "10");
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.get(URL)
.params(params));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.numberOfElements").value(authorizations.size()))
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].roleId").value(role.getRoleId()))
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].authorizationNo").value(authorizations.get(0).getAuthorizationNo()))
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].createdAt").value(true));
deleteTestDatas();
}
/**
* 권한 인가 다건 등록
*/
@Test
@WithMockUser(roles = "ADMIN")
void 권한_인가_다건_등록() throws Exception {
// given
List<Map<String, Object>> requestDtoList = new ArrayList<>();
for (int i = 1; i <= authorizations.size(); i++) {
if (i % 2 == 0) continue; //홀수만 등록
Map<String, Object> params = new HashMap<>();
params.put("roleId", role.getRoleId());
params.put("authorizationNo", authorizations.get(i - 1).getAuthorizationNo());
requestDtoList.add(params);
}
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.post(URL)
.accept(MediaType.APPLICATION_JSON)
.contentType("application/json;charset=UTF-8")
.content(objectMapper.writeValueAsString(requestDtoList)));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk());
String responseData = resultActions.andReturn().getResponse().getContentAsString();
JSONArray jsonArray = new JSONArray(responseData);
assertThat(jsonArray.length()).isEqualTo(requestDtoList.size());
List<RoleAuthorization> entityList = roleAuthorizationRepository.findAll(Sort.by(Sort.Direction.ASC, "roleAuthorizationId.authorizationNo"));
for (int i = entityList.size() - 1; i >= 0; i--) {
if (!entityList.get(i).getRoleAuthorizationId().getRoleId().equals(role.getRoleId())) {
entityList.remove(i);
}
}
assertThat(entityList).isNotNull();
assertThat(entityList.size()).isEqualTo(requestDtoList.size());
assertThat(entityList)
.isNotEmpty()
.has(new Condition<>(l -> l.get(0).getRoleAuthorizationId().getRoleId().equals(role.getRoleId()) && l.get(0).getRoleAuthorizationId().getAuthorizationNo().compareTo(authorizations.get(0).getAuthorizationNo()) == 0,
"RoleAuthorizationApiControllerTest.saveList authorizationNo eq 1"))
.has(new Condition<>(l -> l.get(1).getRoleAuthorizationId().getRoleId().equals(role.getRoleId()) && l.get(1).getRoleAuthorizationId().getAuthorizationNo().compareTo(authorizations.get(2).getAuthorizationNo()) == 0,
"RoleAuthorizationApiControllerTest.saveList authorizationNo eq 3"));
for (int i = entityList.size() - 1; i >= 0; i--) {
deleteTestData(entityList.get(i).getRoleAuthorizationId().getRoleId(), entityList.get(i).getRoleAuthorizationId().getAuthorizationNo());
}
}
/**
* 권한 인가 다건 삭제
*/
@Test
@WithMockUser(roles = "ADMIN")
void 권한_인가_다건_삭제() throws Exception {
// given
insertTestDatas();
List<Map<String, Object>> requestDtoList = new ArrayList<>();
for (RoleAuthorization testData : testDatas) {
Map<String, Object> params = new HashMap<>();
params.put("roleId", testData.getRoleAuthorizationId().getRoleId());
params.put("authorizationNo", testData.getRoleAuthorizationId().getAuthorizationNo());
requestDtoList.add(params);
}
// when
ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.put(URL)
.accept(MediaType.APPLICATION_JSON)
.contentType("application/json;charset=UTF-8")
.content(objectMapper.writeValueAsString(requestDtoList)));
// then
resultActions
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk());
List<RoleAuthorization> entityList = roleAuthorizationRepository.findAll(Sort.by(Sort.Direction.ASC, "roleAuthorizationId.authorizationNo"));
for (int i = entityList.size() - 1; i >= 0; i--) {
if (!entityList.get(i).getRoleAuthorizationId().getRoleId().equals(role.getRoleId())) {
entityList.remove(i);
}
}
assertThat(entityList).isNotNull();
assertThat(entityList.size()).isZero();
}
/**
* 권한 인가 레파지토리 등록/조회 테스트
*/
@Test
@Disabled
void 권한_인가_등록_조회() {
// given
final Integer authorizationNo = authorizations.get(0).getAuthorizationNo();
roleAuthorizationRepository.save(RoleAuthorization.builder()
.roleId(role.getRoleId())
.authorizationNo(authorizationNo)
.build());
// when
Optional<RoleAuthorization> roleAuthorization = selectData(role.getRoleId(), authorizationNo);
// then
assertThat(roleAuthorization).isPresent();
RoleAuthorization entity = roleAuthorization.get();
assertThat(entity.getRoleAuthorizationId().getRoleId()).isEqualTo(role.getRoleId());
assertThat(entity.getRoleAuthorizationId().getAuthorizationNo()).isEqualTo(authorizationNo);
}
/**
* 테스트 데이터 등록
*/
private void insertTestDatas() {
// 권한 인가 등록
for (int i = 1; i <= authorizations.size(); i++) {
if (i % 2 == 0) continue; //인가 번호 홀수만 등록
testDatas.add(roleAuthorizationRepository.save(RoleAuthorization.builder()
.roleId(role.getRoleId())
.authorizationNo(authorizations.get(i - 1).getAuthorizationNo())
.build()));
}
}
/**
* 테스트 데이터 삭제
*/
private void deleteTestDatas() {
// 권한 인가 삭제
roleAuthorizationRepository.deleteAll(testDatas);
testDatas.clear();
}
/**
* 테스트 데이터 단건 삭제
*/
private void deleteTestData(String roleId, Integer authorizationNo) {
roleAuthorizationRepository.deleteById(RoleAuthorizationId.builder()
.roleId(roleId)
.authorizationNo(authorizationNo)
.build());
}
/**
* 테스트 데이터 단건 조회
*
* @param roleId 권한 id
* @param authorizationNo 인가 번호
* @return Optional<RoleAuthorization> 권한 인가 엔티티
*/
private Optional<RoleAuthorization> selectData(String roleId, Integer authorizationNo) {
return roleAuthorizationRepository.findById(RoleAuthorizationId.builder()
.roleId(roleId)
.authorizationNo(authorizationNo)
.build());
}
}

View File

@@ -0,0 +1,28 @@
package org.egovframe.cloud.userservice.config;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.MessageSource;
import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@SpringBootTest(webEnvironment = RANDOM_PORT)
class MessageSourceConfigTest {
@Autowired
TestRestTemplate restTemplate;
@Test
public void 메세지를_외부위치에서_읽어온다() throws Exception {
// when
String message = restTemplate.getForObject("http://localhost:8000/user-service/api/v1/messages/common.login/ko", String.class);
// then
assertThat(message).isEqualTo("로그인");
}
}

View File

@@ -0,0 +1,87 @@
package org.egovframe.cloud.userservice.util;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import java.util.Collections;
import java.util.List;
/**
* org.egovframe.cloud.userservice.util.RestResponsePage
* <p>
* 페이지 API 조회 시 JSON 형식의 응답 데이터를 페이지 객체를 구현하여 마이그레이션 해주는 클래스
*
* @author 표준프레임워크센터 jooho
* @version 1.0
* @since 2021/07/08
*
* <pre>
* << 개정이력(Modification Information) >>
*
* 수정일 수정자 수정내용
* ---------- -------- ---------------------------
* 2021/07/08 jooho 최초 생성
* </pre>
*/
public class RestResponsePage<T> extends PageImpl<T> {
/**
* Rest 응답 페이지 생성자
*
* @param content 목록
* @param number 페이지 번호
* @param size 조회할 데이터 수
* @param totalElements 총 데이터 수
* @param pageable 페이지 정보
* @param last 마지막
* @param totalPages 총 페이지
* @param sort 정렬
* @param first 처음
* @param numberOfElements 조회된 데이터 수
*/
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public RestResponsePage(@JsonProperty("content") List<T> content,
@JsonProperty("number") int number,
@JsonProperty("size") int size,
@JsonProperty("totalElements") Long totalElements,
@JsonProperty("pageable") JsonNode pageable,
@JsonProperty("last") boolean last,
@JsonProperty("totalPages") int totalPages,
@JsonProperty("sort") JsonNode sort,
@JsonProperty("first") boolean first,
@JsonProperty("numberOfElements") int numberOfElements) {
super(content, PageRequest.of(number, size), totalElements);
}
/**
* Rest 응답 페이지 생성자
*
* @param content 목록
* @param pageable 페이지 정보
* @param total 총 데이터 수
*/
public RestResponsePage(List<T> content, Pageable pageable, long total) {
super(content, pageable, total);
}
/**
* Rest 응답 페이지 생성자
*
* @param content 목록
*/
public RestResponsePage(List<T> content) {
super(content);
}
/**
* Rest 응답 페이지 생성자
*/
public RestResponsePage() {
super(Collections.emptyList());
}
}

View File

@@ -0,0 +1,107 @@
spring:
application:
name: user-service
datasource:
url: jdbc:h2:mem:testdb;MODE=MYSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false
username: sa
password:
driver-class-name: org.h2.Driver
initialization-mode: always
# schema: classpath:h2/schema.sql
data: classpath:h2/data.sql
jpa:
hibernate:
generate-ddl: true
ddl-auto: create-drop
dialect: org.hibernate.dialect.MySQL5Dialect
properties:
hibernate:
format_sql: true
default_batch_fetch_size: 1000
show-sql: true
h2:
console:
enabled: true
path: /h2
cache:
jcache:
config: classpath:ehcache.xml
mail: # 비밀번호 변경 이메일 발송
host: smtp.gmail.com # smtp host
port: 587 # smtp port
username: email_username # 계정
password: 'email_password' # 비밀번호 - 구글 보안 2단계 인증 해제, 보안 수준이 낮은 앱의 액세스 허용(https://myaccount.google.com/lesssecureapps)
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
security:
# oauth2 를 사용하려면 아래 google, naver, kakao 의 client-id, client-secret 을 발급받아야 한다.
oauth2:
client:
registration:
# /oauth2/authorization/google
google:
client-id: google_client_id # TODO
client-secret: google_client_secret # TODO
scope: profile,email
# 네이버는 Spring Security를 공식 지원하지 않기 때문에 CommonOAuth2Provider 에서 해주는 값들을 수동으로 입력한다.
# /oauth2/authorization/naver
naver:
client-id: naver_client_id # TODO
client-secret: naver_client_secret # TODO
redirect_uri: "{baseUrl}/{action}/oauth2/code/{registrationId}"
authorization_grant_type: authorization_code
scope: name,email,profile_image
client-name: Naver
# /oauth2/authorization/kakao
kakao:
client-id: kakao_client_id # TODO
client-secret: kakao_client_secret # TODO
redirect-uri: "{baseUrl}/{action}/oauth2/code/{registrationId}"
client-authentication-method: POST
authorization-grant-type: authorization_code
scope: profile_nickname, account_email
client-name: Kakao
provider:
naver:
authorization_uri: https://nid.naver.com/oauth2.0/authorize
token_uri: https://nid.naver.com/oauth2.0/token
user-info-uri: https://openapi.naver.com/v1/nid/me
# 기준이 되는 user_name 의 이름을 네이버에서는 response로 지정해야한다. (네이버 회원 조회시 반환되는 JSON 형태 때문이다)
# response를 user_name으로 지정하고 이후 자바 코드로 response의 id를 user_name으로 지정한다. (스프링 시큐리티에서 하위 필드를 명시할 수 없기 때문)
user_name_attribute: response
kakao:
authorization_uri: https://kauth.kakao.com/oauth/authorize
token_uri: https://kauth.kakao.com/oauth/token
user-info-uri: https://kapi.kakao.com/v2/user/me
user_name_attribute: id
logging.level:
org.hibernate.SQL: debug
org.hibernate.type: trace
file:
directory: ${user.home}/msa-attach-volume
messages:
directory: ${file.directory}/messages
# jwt token
token:
expiration_time: 7200000
refresh_time: 86400000
secret: egovframe_token_secret
# ftp server
ftp:
enabled: false # ftp 사용 여부, FTP 서버에 최상위 디렉토리 자동 생성 및 구현체를 결정하게 된다.
# eureka 가 포함되면 eureka server 도 등록되므로 해제한다.
eureka:
client:
register-with-eureka: false
fetch-registry: false

View File

@@ -0,0 +1,38 @@
INSERT INTO `authorization` (authorization_name,url_pattern_value,http_method_code,sort_seq,created_by,created_date,last_modified_by,modified_date) VALUES
('사용자 목록 조회','/user-service/api/v1/users','GET',101,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 단건 조회','/user-service/api/v1/users/?*','GET',102,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 등록','/user-service/api/v1/users','POST',103,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 수정','/user-service/api/v1/users/?*','PUT',104,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 토큰 갱신','/user-service/api/v1/users/token/refresh','GET',105,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('권한 페이지 목록 조회','/user-service/api/v1/roles','GET',106,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('권한 전체 목록 조회','/user-service/api/v1/roles/all','GET',107,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('인가 페이지 목록 조회','/user-service/api/v1/authorizations','GET',108,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('인가 단건 조회','/user-service/api/v1/authorizations/?*','GET',109,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('인가 다음 정렬 순서 조회','/user-service/api/v1/authorizations/sort-seq/next','GET',110,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('인가 등록','/user-service/api/v1/authorizations','POST',111,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('인가 수정','/user-service/api/v1/authorizations/?*','PUT',112,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('인가 삭제','/user-service/api/v1/authorizations/?*','DELETE',113,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('인가 여부 확인','/user-service/api/v1/authorizations/check','GET',114,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('권한 인가 페이지 목록 조회','/user-service/api/v1/role-authorizations','GET',115,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('권한 인가 다건 등록','/user-service/api/v1/role-authorizations','POST',116,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('권한 인가 다건 삭제','/user-service/api/v1/role-authorizations','PUT',117,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 이메일 중복 확인','/user-service/api/v1/users/exists','POST',118,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 회원 가입','/user-service/api/v1/users/join','POST',119,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 비밀번호 찾기','/user-service/api/v1/users/password/find','POST',120,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 비밀번호 찾기 유효성 확인','/user-service/api/v1/users/password/valid/?*','GET',121,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 비밀번호 찾기 변경','/user-service/api/v1/users/password/change','PUT',122,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 비밀번호 변경','/user-service/api/v1/users/password/update','PUT',123,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 비밀번호 확인','/user-service/api/v1/users/password/match','POST',124,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('예약지역 사용여부 토글','/reserve-item-service/api/v1/locations/?*/?*','PUT',125,'87638675-11fa-49e5-9bd1-d2524bf6fa45',now(),'87638675-11fa-49e5-9bd1-d2524bf6fa45',now()),
('사용자 정보 수정','/user-service/api/v1/users/info/?*','PUT',126,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 회원탈퇴','/user-service/api/v1/users/leave','POST',127,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now()),
('사용자 삭제','/user-service/api/v1/users/delete/?*','DELETE',128,'65a00f65-8460-49af-98ec-042977e56f4b',now(),'65a00f65-8460-49af-98ec-042977e56f4b',now());
INSERT INTO `role` (role_id,role_name,role_content,sort_seq,created_date) VALUES
('ROLE_ADMIN','시스템 관리자','시스템 관리자 권한',101,'2021-10-20 13:39:15'),
('ROLE_ANONYMOUS','손님','손님 권한',104,'2021-10-20 13:39:15'),
('ROLE_EMPLOYEE','내부 사용자','내부 사용자 권한',102,'2021-10-20 13:39:15'),
('ROLE_USER','일반 사용자','일반 사용자 권한',103,'2021-10-20 13:39:15');
INSERT INTO role_authorization (role_id,authorization_no,created_by,created_date)
select 'ROLE_ADMIN', authorization_no, '65a00f65-8460-49af-98ec-042977e56f4b', now() from `authorization`;