From fbcfb02931aee43eb827e074a3aff9fc36fce975 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Wed, 6 Jul 2022 18:44:16 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20cors=20Sesurity=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xit/core/config/SecurityConfig.java | 2 + .../IMinJudge680RepositoryTest.java | 113 --------- .../ctgy/repository/RecallRepositoryTest.java | 236 ------------------ .../biz/ctgy/repository/RepositoryTest.java | 55 ---- 4 files changed, 2 insertions(+), 404 deletions(-) delete mode 100644 src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java delete mode 100644 src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java delete mode 100644 src/test/java/com/xit/biz/ctgy/repository/RepositoryTest.java diff --git a/src/main/java/com/xit/core/config/SecurityConfig.java b/src/main/java/com/xit/core/config/SecurityConfig.java index b02444d..d17145c 100644 --- a/src/main/java/com/xit/core/config/SecurityConfig.java +++ b/src/main/java/com/xit/core/config/SecurityConfig.java @@ -17,6 +17,7 @@ import com.xit.core.oauth2.oauth.JwtTokenProvider; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.BeanIds; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; @@ -183,6 +184,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { // GET, POST 요청시 : OPTIONS preflight 요청 - 실제 서버가 살아있는지를 사전에 확인하는 요청 // Spring에서 OPTIONS에 대한 요청을 막고 있어 OPTIONS 요청이 왔을 때도 오류를 리턴하지 않도록 설정 .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() + .mvcMatchers(HttpMethod.OPTIONS, "/**").permitAll() .antMatchers( "/", "/favicon.ico", diff --git a/src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java b/src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java deleted file mode 100644 index cfee85e..0000000 --- a/src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.xit.biz.ctgy.repository; - -import com.querydsl.core.BooleanBuilder; -import com.querydsl.core.types.Projections; -import com.querydsl.jpa.impl.JPAQueryFactory; -import com.xit.core.util.DateUtil; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -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.ActiveProfiles; - -import javax.persistence.EntityManager; -import javax.transaction.Transactional; - -import java.time.LocalDate; -import java.util.List; - -import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680; -import static com.xit.biz.ctgy.entity.QMinSimsaUser680.minSimsaUser680; -import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo; - -@SpringBootTest -@Transactional -@ActiveProfiles({"dev"}) -class IMinJudge680RepositoryTest { - - @Autowired - EntityManager em; - - private JPAQueryFactory queryFactory; - - @BeforeEach - void beforeEach(){ - queryFactory = new JPAQueryFactory(em); - } - - @AfterEach - void afterEach(){ - } - - @Test - @DisplayName("sim_result:심사목록에서 기간 클릭시") - void sim_result() { - - //LocalDate now = LocalDate.now(); - LocalDate now = LocalDate.of(2021, 12, 11); - LocalDate now2 = LocalDate.of(2021, 12, 12); - - - queryFactory - .select(minSimsa680.msSeq, - minSimsa680.msCarnum, - minSimsa680.msMaincode) - .from(minSimsaUser680) - .join(minSimsa680) - .on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode)) - .join(minUserinfo) - .on(minSimsaUser680.msuUserid.eq(minUserinfo.userid)) - .where(minSimsaUser680.msuTeam.eq(""), - minSimsa680.msChasu.eq(1L), - minSimsa680.msSdate.eq(now), - minSimsa680.msEdate.eq(now2)) - .groupBy(minSimsa680.msCarnum, - minSimsa680.msSeq, - minSimsa680.msMaincode) - .orderBy(minSimsa680.msSeq.asc()) - .offset(0L) - .limit(10L) - //, minSimsa680.msSdate.eq(java.sql.Date.valueOf(now))) - .fetchResults(); - - } - - @Test - void judgeDetailsTest() { - BooleanBuilder builder = new BooleanBuilder(); - builder.and(minSimsa680.msSdate.gt(DateUtil.parseLocalDate("2021-09-10")).or(minSimsa680.msSdate.eq(DateUtil.parseLocalDate("2021-09-10")))); - builder.and(minSimsa680.msEdate.lt(DateUtil.parseLocalDate("2021-09-11")).or(minSimsa680.msEdate.eq(DateUtil.parseLocalDate("2021-09-11")))); - - // builder.and(minSimsaUser680.msuTeam.eq(dto.getMsuTeam())); - List rslt = - queryFactory - .select(Projections.fields(MinSimsa680.class, - minSimsa680.msSeq, - minSimsa680.msCarnum, - minSimsa680.msMaincode)) - .from(minSimsaUser680) - .join(minSimsa680) - .on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode)) - .join(minUserinfo) - .on(minSimsaUser680.msuUserid.eq(minUserinfo.userid)) - .where(builder) - .groupBy(minSimsa680.msCarnum, - minSimsa680.msSeq, - minSimsa680.msMaincode) - .orderBy(minSimsa680.msSeq.asc()) - .fetch(); - - } - -// @BeforeAll -// void beforeAll(){ -// log.debug("initializing..."); -// } - -// @AfterAll -// void afterAll(){ -// log.debug("...shutdown"); -// } -} \ No newline at end of file diff --git a/src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java b/src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java deleted file mode 100644 index d6eb447..0000000 --- a/src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java +++ /dev/null @@ -1,236 +0,0 @@ -package com.xit.biz.ctgy.repository; - -import com.querydsl.core.types.Expression; -import com.querydsl.jpa.impl.JPAQueryFactory; -import com.xit.biz.ctgy.entity.QGnRecallSc; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -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.ActiveProfiles; - -import javax.persistence.EntityManager; -import javax.transaction.Transactional; -import java.lang.reflect.Modifier; -import java.sql.Date; -import java.time.LocalDate; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680; -import static com.xit.biz.ctgy.entity.QMinSimsaUser680.minSimsaUser680; -import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo; - -@SpringBootTest -@Transactional -@ActiveProfiles({"dev"}) -@Slf4j -class RecallRepositoryTest { - - @Autowired - EntityManager em; - - private JPAQueryFactory queryFactory; - - @BeforeEach - void beforeEach(){ - queryFactory = new JPAQueryFactory(em); - } - - @AfterEach - void afterEach(){ - } - - @Test - void dddd(){ - QGnRecallSc qGnRecallSc = QGnRecallSc.gnRecallSc; - final List> columns = Arrays.stream(QGnRecallSc.class.getDeclaredFields()) - .filter(field -> !Modifier.isStatic(field.getModifiers())) - .map(field -> { - try { - return (Expression) field.get(qGnRecallSc); - } - catch (final Exception e) { - log.trace("should never happen", e); - return null; - } - }) - .collect(Collectors.toList()); - - log.debug("{}", qGnRecallSc); - - - -// Adding transient fields - // CollectionUtils.addAll(columns, new Expression[] { qOtherBean, qStupidJoinBean }); - } - - @Test - @DisplayName("sim_result:심사목록에서 기간 클릭시") - void sim_reg() { - - /* - "SELECT COUNT(*) CNT FROM TF680_MAIN INNER JOIN TF680_RECALL ON (MM_CODE=RC_MAINCODE) -WHERE MM_DBGB = '11' AND MM_LSTATE != '75' AND RC_GB = '1' AND RC_STATE = '0' -AND RC_SEQ >= '""& rtxtsNum &""' AND RC_SEQ <= '""& rtxteNum &""' AND RC_IR_TRANSFER = '""& rstTrans &""'""" - - */ - - - /* - 주정차의견진술상세자료 - SELECTROWNUM, RC_SEQ, MM_OCARNO, MM_NCARNO, RC_NAME, GET_RECALL_CONTID(RC_CONT_DOC) CONTDOC, -RC_DATE, Get_Recall_Ingb_Str(RC_INGB) INGB -FROM TF680_MAIN INNER JOIN TF680_RECALL ON (MM_CODE=RC_MAINCODE) -WHERE MM_DBGB = '11' AND MM_LSTATE != '75' -AND RC_GB = '1' AND RC_STATE = '0' AND RC_SEQ >= '"& rtxtsNum &"' AND RC_SEQ <= '"& rtxteNum &"' " -AND RC_IR_TRANSFER = '"& rstTrans &"' ORDER BY RC_SEQ - */ - - - //LocalDate now = LocalDate.now(); - LocalDate now = LocalDate.of(2021, 12, 11); - LocalDate now2 = LocalDate.of(2021, 12, 12); - - - queryFactory - .select(minSimsa680.msSeq, - minSimsa680.msCarnum, - minSimsa680.msMaincode) - .from(minSimsaUser680) - .join(minSimsa680) - .on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode)) - .join(minUserinfo) - .on(minSimsaUser680.msuUserid.eq(minUserinfo.userid)) - .where(minSimsaUser680.msuTeam.eq(""), - minSimsa680.msChasu.eq(1L), - minSimsa680.msSdate.eq(now), - minSimsa680.msEdate.eq(now2)) - .groupBy(minSimsa680.msCarnum, - minSimsa680.msSeq, - minSimsa680.msMaincode) - .orderBy(minSimsa680.msSeq.asc()) - .offset(0L) - .limit(10L) - //, minSimsa680.msSdate.eq(java.sql.Date.valueOf(now))) - .fetchResults(); -// jpaQueryFactory.selectFrom(minSimsa680) -// .leftJoin(minSimsa680.msMaincode, minSimsaUser680).fetchJoin() -// .groupBy(minSimsa680.msEdate, minSimsaUser680.msuTeam, qMinUserinfo.name) -// .orderBy(minSimsa680.msChasu.desc()) -// //.where(minSimsa680.name.eq(name)) - // .fetch(); - - } - - - @Test - void resultMapReturn(){ - - /* - SELECT TM.MM_CODE, - TR.RC_CODE, - TR.RC_SEQ, - TM.MM_OCARNO, - TM.MM_NCARNO, - TR.RC_NAME, - TR.RC_CONT_DOC, - -- 진술유형(1:재판독, 2:기타, 3:공무수행, 4:응급환자수송및치료, 5:장애인관련, 6:고장, 7:수사차량, 8:이의인정, 9:취재차량, 10:착오단속, 11:거주자우선, 12:물건상하차, 13:공공업무수행, 14:공사차량) - CASE WHEN TR.RC_CONT_DOC = '1' THEN '재판독' - WHEN TR.RC_CONT_DOC = '2' THEN '기타' - WHEN TR.RC_CONT_DOC = '3' THEN '공무수행' - WHEN TR.RC_CONT_DOC = '4' THEN '응급환자수송및치료' - WHEN TR.RC_CONT_DOC = '5' THEN '장애인관련' - WHEN TR.RC_CONT_DOC = '6' THEN '고장' - WHEN TR.RC_CONT_DOC = '7' THEN '수사차량' - WHEN TR.RC_CONT_DOC = '8' THEN '이의인정' - WHEN TR.RC_CONT_DOC = '9' THEN '취재차량' - WHEN TR.RC_CONT_DOC = '10' THEN '착오단속' - WHEN TR.RC_CONT_DOC = '11' THEN '거주자우선' - WHEN TR.RC_CONT_DOC = '12' THEN '물건상하차' - WHEN TR.RC_CONT_DOC = '13' THEN '공공업무수행' - WHEN TR.RC_CONT_DOC = '14' THEN '공사차량' - ELSE '' - END AS RC_COND_DOC_STR, - TCCS2.CODE_NM, - TR.RC_DATE, - -- 접수방법(1:방문, 2:인터넷, 3:상급기관인터넷, 4:팩스, 5:우편, 6:전화, 7:ARS, 8:터치스크린, 9:공문) - TR.RC_INGB, - CASE WHEN TR.RC_INGB = '1' THEN '방문' - WHEN TR.RC_INGB = '2' THEN '인터넷' - WHEN TR.RC_INGB = '3' THEN '상급기관인터넷' - WHEN TR.RC_INGB = '4' THEN '팩스' - WHEN TR.RC_INGB = '5' THEN '우편' - WHEN TR.RC_INGB = '6' THEN '전화' - WHEN TR.RC_INGB = '7' THEN 'ARS' - WHEN TR.RC_INGB = '8' THEN '터치스크린' - WHEN TR.RC_INGB = '9' THEN '공문' - ELSE '' - END AS RC_INGB_STR, - TCCS1.CODE_NM - FROM TF680_MAIN TM - JOIN TF680_RECALL TR ON TM.MM_CODE = TR.RC_MAINCODE - LEFT JOIN TB_CMM_CODE_S TCCS1 ON TR.RC_INGB = TCCS1.CODE_CD - AND TCCS1.CODE_GRP_ID = 'TRAFFIC' - AND TCCS1.CODE_LCD = 'GANGNAM_SIMSA' - AND TCCS1.CODE_MCD = 'RC_INGB' - LEFT JOIN TB_CMM_CODE_S TCCS2 ON TR.RC_CONT_DOC = TCCS2.CODE_CD - AND TCCS2.CODE_GRP_ID = 'TRAFFIC' - AND TCCS2.CODE_LCD = 'GANGNAM_SIMSA' - AND TCCS2.CODE_MCD = 'RC_CONT_DOC' - WHERE MM_DBGB = '11' -- 과태료 코드 : 11-'주정차위반과태료 12-버스전용차로위반과태료 - AND MM_LSTATE != '75' -- 10:단속,11:부과,12:독촉,13:압류예정,21:압류,49:대납,51:자납,52:수시분수납,53:독촉분수납,54:압류예정분수납,55:압류해제수납,61:시효결손취소수납,62:불납결손취소수납,65:충당수납,71:서손,72:의견진술수용,73:이의신청수용,74:부과취소,75:자납고지부과등록,81:시효결손,82:불납결손,91:법원이송,92:경찰서이첩,98:면제차량,99:삭제자료) - AND RC_GB = '1' -- 미원 구분 : 1-의견진술 2-이의신청 - AND RC_STATE = '0' -- 심의결과(0:심의전, 1:미부과, 2:재판독, 3:심의제외-OCR수납등록에서 생성, 5:부과, 7:자진취하, 8:법원이송, 9:경찰이첩) - -- AND RC_SEQ >= '"& rtxtsNum &"' - -- AND RC_SEQ <= '"& rtxteNum &"' - AND RC_IR_TRANSFER = '1' -- 인터넷 심사 전송상태 : 1-미전송 2-전송 - order by RC_SEQ; - */ - -// Map rsltMap = em.createQuery("SELECT new map(TM.MM_CODE as mmCode," + -// " TR.RC_CODE as rcCode, " + -// " TR.RC_SEQ as rcSeq, " + -// " TM.MM_OCARNO as mmOcarno, " + -// " TM.MM_NCARNO as mmNcarno " + -// " FROM TF680_MAIN TM " + -// " JOIN TF680_RECALL TR ON TM.MM_CODE = TR.RC_MAINCODE " + -// " LEFT JOIN TB_CMM_CODE_S TCCS1 ON TR.RC_INGB = TCCS1.CODE_CD " + -// " AND TCCS1.CODE_GRP_ID = 'TRAFFIC' " + -// " AND TCCS1.CODE_LCD = 'GANGNAM_SIMSA' " + -// " AND TCCS1.CODE_MCD = 'RC_INGB' " + -// " LEFT JOIN TB_CMM_CODE_S TCCS2 ON TR.RC_CONT_DOC = TCCS2.CODE_CD " + -// " AND TCCS2.CODE_GRP_ID = 'TRAFFIC' " + -// " AND TCCS2.CODE_LCD = 'GANGNAM_SIMSA' " + -// " AND TCCS2.CODE_MCD = 'RC_CONT_DOC' " + -// " WHERE MM_DBGB = '11' " + -// " AND MM_LSTATE != '75' " + -// " AND RC_GB = '1' " + -// " AND RC_STATE = '0' " + -// " AND RC_IR_TRANSFER = '1' " + -// " order by RC_SEQ " -// , Tuple.class -// ).getResultList() -// .stream() -// .collect( -// Collectors.toMap( -// tuple -> ((Long) tuple.get("MM_CODE"))., -// tuple -> ((Long) tuple.get("RC_CODE"), -// ) -// ) -// -// } -// @BeforeAll -// void beforeAll(){ -// log.debug("initializing..."); -// } - -// @AfterAll -// void afterAll(){ -// log.debug("...shutdown"); - } -} \ No newline at end of file diff --git a/src/test/java/com/xit/biz/ctgy/repository/RepositoryTest.java b/src/test/java/com/xit/biz/ctgy/repository/RepositoryTest.java deleted file mode 100644 index ef16e64..0000000 --- a/src/test/java/com/xit/biz/ctgy/repository/RepositoryTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.xit.biz.ctgy.repository; - -import com.querydsl.jpa.impl.JPAQueryFactory; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; - -import javax.persistence.EntityManager; -import javax.transaction.Transactional; - -import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680; - -@SpringBootTest -@Transactional -@ActiveProfiles({"dev"}) -@Slf4j -public class RepositoryTest { - - @Autowired - EntityManager em; - - private JPAQueryFactory queryFactory; - -// @BeforeAll -// void beforeAll(){ -// log.debug("initializing..."); -// } - -// @AfterAll -// void afterAll(){ -// log.debug("...shutdown"); -// } - - @BeforeEach - void beforeEach(){ - log.debug("biz start..."); - queryFactory = new JPAQueryFactory(em); - } - - @AfterEach - void afterEach(){ - log.debug("... biz end"); - } - - @Test - void querydslTest() { - //QMinSimsa680 qMinSimsa680 = new QMinSimsa680("minSimsa680"); - MinSimsa680 simsa680 = queryFactory.selectFrom(minSimsa680) - .where(minSimsa680.msMaincode.eq(300297013L)) - .fetchOne(); - System.out.println("##################################"+simsa680); - } -}