test 파일 삭제

This commit is contained in:
주수현
2025-07-30 11:00:39 +09:00
parent 0d8afa0f01
commit 55b93705b1
15 changed files with 4 additions and 365 deletions

View File

@@ -1,30 +0,0 @@
package app.module.admin;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.web.filter.CharacterEncodingFilter;
import java.lang.annotation.*;
/**
* MockMvc `application/json` 타입 전송 시 UTF-8 설정 어노테이션
*
* @author Youngmok Kim
* @version 1.0 2022-06-27
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@AutoConfigureMockMvc
@Import(EnableJsonUTF8.Config.class)
public @interface EnableJsonUTF8 {
class Config {
@Bean
public CharacterEncodingFilter characterEncodingFilter() {
return new CharacterEncodingFilter("UTF-8", true);
}
}
}

View File

@@ -6,8 +6,7 @@ import org.jasypt.iv.RandomIvGenerator;
import org.junit.jupiter.api.Test;
public class TestJasyptConfig {
// 운영 서버만 옵션 비꾸기
private String jasyptPassword = "etribe";
// 운영 서버 password
private String jasyptPasswordPrd = "ko-research";
//PBEWithMD5AndDES
@@ -16,29 +15,7 @@ public class TestJasyptConfig {
@Test
void jasypt(){
String url = "jdbc:postgresql://15.165.180.203:5432/korea_research";
String encryptUrl = jasyptEncrypt(url);
System.out.println("encryptUrl : " + encryptUrl);
Assertions.assertThat(url).isEqualTo(jasyptDecryt(encryptUrl));
String username = "ko_research";
String encryptUsername = jasyptEncrypt(username);
System.out.println("encryptUsername : " + encryptUsername);
Assertions.assertThat(username).isEqualTo(jasyptDecryt(encryptUsername));
String password = "koresearch1@#4";
String encryptPassword = jasyptEncrypt(password);
System.out.println("encryptPassword : " + encryptPassword);
Assertions.assertThat(password).isEqualTo(jasyptDecryt(encryptPassword));
System.out.println("--------------------------------" );
System.out.println("운영서버 정보 엔코딩" );
String url2 = "jdbc:postgresql://115.68.193.117:5432/korea_research";
String encryptUrl2 = jasyptEncryptPrd(url2);
@@ -62,41 +39,25 @@ public class TestJasyptConfig {
System.out.println("운영서버 정보 MMS 엔코딩" );
String url3 = "jdbc:postgresql://115.68.193.117:5432/ppurio";
String encryptUrl3 = jasyptEncrypt(url3);
String encryptUrl3 = jasyptEncryptPrd(url3);
System.out.println("encryptUrl3 : " + encryptUrl3);
/* Assertions.assertThat(url3).isEqualTo(jasyptEncrypt(encryptUrl3));*/
String username3 = "etribe";
String encryptUsername3 = jasyptEncrypt(username3);
String encryptUsername3 = jasyptEncryptPrd(username3);
System.out.println("encryptUsername3 : " + encryptUsername3);
/* Assertions.assertThat(username3).isEqualTo(jasyptEncrypt(encryptUsername3));*/
String password3 = "Etribe@3415";
String encryptPassword3 = jasyptEncrypt(password3);
String encryptPassword3 = jasyptEncryptPrd(password3);
System.out.println("encryptPassword3 : " + encryptPassword3);
}
private String jasyptEncrypt(String input) {
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setAlgorithm(jasyptAlgorithm);
encryptor.setPassword(jasyptPassword);
encryptor.setIvGenerator(new RandomIvGenerator());
return encryptor.encrypt(input);
}
private String jasyptDecryt(String input){
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setAlgorithm(jasyptAlgorithm);
encryptor.setPassword(jasyptPassword);
encryptor.setIvGenerator(new RandomIvGenerator());
return encryptor.decrypt(input);
}
private String jasyptEncryptPrd(String input) {
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();

View File

@@ -1,26 +0,0 @@
package app.module.admin.config.initData;
import app.module.core.config.adapters.persistence.repository.RoleRepo;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class InitAdminUserRoleTestData implements ApplicationRunner {
private final RoleRepo roleRepo;
private final Environment env;
@Override
public void run(ApplicationArguments args) {
if (!env.getProperty("admin.initData.test", Boolean.class)) {
return;
}
// roleRepo.save(new Role("ROLE_SUPER"));
// roleRepo.save(new Role("ROLE_STAFF"));
}
}

View File

@@ -1,72 +0,0 @@
package app.module.admin.config.security;
import app.module.core.usecase.admin.saveAdmin.ports.SaveAdminPortIn;
import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.unauthenticated;
@SpringBootTest
@TestPropertySource("classpath:application-override.properties")
@AutoConfigureMockMvc
@TestInstance(Lifecycle.PER_CLASS)
class AdminAuthFailHandlerTest {
/* static {
System.setProperty("com.amazonaws.sdk.disableEc2Metadata", "true");
}
@Autowired
MockMvc mockMvc;
@Autowired
AdminViewPortIn adminViewPortIn;
@Autowired
SaveAdminPortIn saveAdminPortIn;
@Value("${app.admin.auth.fail.permit}")
Integer loginFailPermit;
String testUsername = "testUser";
@BeforeAll
public void beforeAll() {
*//* saveAdminPortIn.connect(
1L,
testUsername,
"test.1@#$",
null,
false,
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));*//*
}
@Test
@DisplayName("operate - 계정 잠김")
void onAuthenticationFailure() throws Exception {
String badPassword = "bad-password.1@#$";
String goodPassword = "test.1@#$";
for (int i = 0; i < loginFailPermit; i++) {
mockMvc.perform(formLogin().user(testUsername).password(badPassword));
}
assertTrue(
adminViewPortIn.connect(testUsername).orElseThrow().getAccountLocked(),
String.format("%s 회 이상 로그인 실패로 계정이 잠김처리되어야 한다.", loginFailPermit));
mockMvc
.perform(formLogin().user(testUsername).password(goodPassword))
.andExpect(unauthenticated());
}*/
}

View File

@@ -1,71 +0,0 @@
package app.module.admin.config.security;
import app.module.core.usecase.admin.saveAdmin.ports.SaveAdminPortIn;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
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.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.authenticated;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.unauthenticated;
@SpringBootTest
@TestPropertySource("classpath:application-override.properties")
@AutoConfigureMockMvc
@TestInstance(Lifecycle.PER_CLASS)
class AdminDetailsServiceTest {
/*
static {
System.setProperty("com.amazonaws.sdk.disableEc2Metadata", "true");
}
@Autowired
MockMvc mockMvc;
@Autowired
SaveAdminPortIn saveAdminPortIn;
String username = "test";
String password = "test.1@#$";
String oldUsername = "admin_for_old_password_test";
@BeforeAll
public void beforeAll() {
*//* saveAdminPortIn.connect(
1L,
username,
password,
null,
false,
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));*//*
}
@Test
@DisplayName("operate - 로그인 성공")
void operate1() throws Exception {
mockMvc.perform(formLogin().user(username).password(password)).andExpect(authenticated());
}
@Test
@DisplayName("operate - 로그인 실패")
void operate2() throws Exception {
String badPassword = "bad-password.1@#$";
mockMvc.perform(formLogin().user(username).password(badPassword))
.andExpect(unauthenticated());
}
// @Test
// @DisplayName("operate - 패스워드 유효기간 지남")
// void operate3() throws Exception {
//
// mockMvc.perform(formLogin().user(oldUsername).password(password)).andExpect(unauthenticated());
// }*/
}

View File

@@ -1,55 +0,0 @@
package app.module.admin.feature.admin.repository.dao;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@Slf4j
class AdminCreateUpdateDaoTest {
static {
System.setProperty("com.amazonaws.sdk.disableEc2Metadata", "true");
}
/* @Autowired
SaveAdminPortOut adminCreateUpdateDao;
@Autowired
AdminViewPortIn adminViewPortIn;
@Autowired
SaveAdminPortIn saveAdminPortIn;*/
@Test
@DisplayName("operate - AdminCreateDao")
void operate() {
/* saveAdminPortIn.connect(
1L,
"admin_for_createDao_test",
"test.1@#$",
null,
false,
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));
adminViewPortIn
.connect("admin_for_createDao_test")
.ifPresent(
retrieveUser ->
assertEquals(
Arrays.asList("ROLE_SUPER", "ROLE_STAFF").size(),
retrieveUser.getRoles().size()));
saveAdminPortIn.connect(
2L,
"admin_for_createDao_test",
"test.1@#$",
null,
false,
List.of("ROLE_STAFF"));
assertEquals(
1,
adminViewPortIn.connect("admin_for_createDao_test").orElseThrow().getRoles().size(),
"기존 권한들을 (내부적으로) 삭제하고 새로이 추가 등록되기에 withRoles 의 size 는 1이다.");*/
}
}

View File

@@ -1,11 +0,0 @@
# disable JNDI lookup
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration
spring.profiles.active=local
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:h2:~/test;
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.properties.hibernate.show_sql=true
logging.level.org.hibernate.type.descriptor.sql=trace
admin.initData.test=true

View File

@@ -1,46 +0,0 @@
package app.module.core.common.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import app.module.core.config.application.util.AESEncryptUtil;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
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.TestPropertySource;
@SpringBootTest
@TestPropertySource("classpath:application-override.properties")
class AESEncryptUtilTest {
/*
static {
System.setProperty("com.amazonaws.sdk.disableEc2Metadata", "true");
}
private final String phoneNo = "01012341234";
private final String encryptedPhoneNo = "dQSU9oEA+WD1WKQZIRaR9g==";
@Autowired
AESEncryptUtil aesEncryptUtil;
@Test
@DisplayName("operate - AESEncryptUtilTest (암호화)")
void encrypt()
throws NoSuchPaddingException, InvalidKeyException, NoSuchAlgorithmException,
IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
assertEquals(encryptedPhoneNo, aesEncryptUtil.encrypt(phoneNo), "operate - encrypt");
}
@Test
@DisplayName("operate - AESEncryptUtilTest (복호화)")
void decrypt()
throws NoSuchPaddingException, InvalidKeyException, NoSuchAlgorithmException,
IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
assertEquals(phoneNo, aesEncryptUtil.decrypt(encryptedPhoneNo), "operate - decrypt");
}*/
}

View File

@@ -1,11 +0,0 @@
# disable JNDI lookup
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration
spring.profiles.active=local
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:h2:~/test;
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.properties.hibernate.show_sql=true
logging.level.org.hibernate.type.descriptor.sql=trace
front-app.initData.test=true