ci - 워크플로 정비 및 단위테스트 안정화
- Gitea Generic Package 업로드 단계 추가 - 단위테스트, e2e 워크플로 분리 - systemd 유닛 동기화 단계 제거 - checkout step 이름·주석 정리 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,12 +23,14 @@ jobs:
|
|||||||
working-directory: eapim-portal
|
working-directory: eapim-portal
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout eapim-portal (trigger SHA)
|
- name: Checkout eapim-portal (this branch)
|
||||||
|
# ref 미지정 — 트리거된 브랜치/commit(github.sha) 그대로 빌드.
|
||||||
uses: http://172.30.1.50:3000/actions/checkout@v4
|
uses: http://172.30.1.50:3000/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
path: eapim-portal
|
path: eapim-portal
|
||||||
|
|
||||||
- name: Checkout elink-portal-common (master)
|
- name: Checkout elink-portal-common (master, dependency)
|
||||||
|
# 의존 모듈은 항상 master 고정.
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: |
|
run: |
|
||||||
rm -rf elink-portal-common
|
rm -rf elink-portal-common
|
||||||
@@ -36,7 +38,8 @@ jobs:
|
|||||||
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/elink-portal-common.git \
|
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/elink-portal-common.git \
|
||||||
elink-portal-common
|
elink-portal-common
|
||||||
|
|
||||||
- name: Checkout elink-online-core-jpa (master)
|
- name: Checkout elink-online-core-jpa (master, dependency)
|
||||||
|
# 의존 모듈은 항상 master 고정.
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p eapim-online
|
mkdir -p eapim-online
|
||||||
@@ -62,6 +65,40 @@ jobs:
|
|||||||
eapim-portal/build/libs/eapim-portal-boot.war
|
eapim-portal/build/libs/eapim-portal-boot.war
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Publish WAR to Gitea Generic Package
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
env:
|
||||||
|
GITEA_URL: http://172.30.1.50:3000
|
||||||
|
PKG_OWNER: djb-eapim
|
||||||
|
PKG_NAME: eapim-portal
|
||||||
|
run: |
|
||||||
|
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||||
|
VERSION="$(TZ=Asia/Seoul date +%Y-%m-%d-%H%M)-${SHORT_SHA}"
|
||||||
|
BASE="$GITEA_URL/api/packages/$PKG_OWNER/generic/$PKG_NAME/$VERSION"
|
||||||
|
|
||||||
|
echo "package version: $VERSION"
|
||||||
|
echo "endpoint base : $BASE"
|
||||||
|
|
||||||
|
for WAR in eapim-portal.war eapim-portal-boot.war; do
|
||||||
|
SRC="eapim-portal/build/libs/$WAR"
|
||||||
|
if [ ! -f "$SRC" ]; then
|
||||||
|
echo "::error::missing artifact: $SRC"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
HTTP=$(curl -sS -o "/tmp/pkg-upload-$WAR.log" -w '%{http_code}' \
|
||||||
|
--user "oauth2:${{ secrets.CI_TOKEN }}" \
|
||||||
|
--upload-file "$SRC" \
|
||||||
|
"$BASE/$WAR")
|
||||||
|
if [ "$HTTP" != "201" ] && [ "$HTTP" != "200" ]; then
|
||||||
|
echo "::error::upload failed for $WAR (HTTP $HTTP)"
|
||||||
|
cat "/tmp/pkg-upload-$WAR.log" || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo " uploaded: $WAR (HTTP $HTTP)"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "published: $GITEA_URL/$PKG_OWNER/-/packages/generic/$PKG_NAME/$VERSION"
|
||||||
|
|
||||||
- name: Stop tomcat (pre-clean)
|
- name: Stop tomcat (pre-clean)
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: |
|
run: |
|
||||||
@@ -86,15 +123,6 @@ jobs:
|
|||||||
cp eapim-portal/build/libs/eapim-portal.war "$DEPLOY_DIR/ROOT.war"
|
cp eapim-portal/build/libs/eapim-portal.war "$DEPLOY_DIR/ROOT.war"
|
||||||
ls -la "$DEPLOY_DIR"
|
ls -la "$DEPLOY_DIR"
|
||||||
|
|
||||||
- name: Refresh systemd unit
|
|
||||||
working-directory: ${{ github.workspace }}
|
|
||||||
run: |
|
|
||||||
# repo 의 unit 파일을 사용자 systemd 디렉터리로 sync (정의 변경 자동 반영)
|
|
||||||
install -m 0644 \
|
|
||||||
eapim-portal/deploy/systemd/eapim-portal.service \
|
|
||||||
"$HOME/.config/systemd/user/eapim-portal.service"
|
|
||||||
systemctl --user daemon-reload
|
|
||||||
|
|
||||||
- name: Start tomcat and readiness probe (timeout 120s)
|
- name: Start tomcat and readiness probe (timeout 120s)
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
name: eapim-portal E2E Test
|
||||||
|
|
||||||
|
# 수동 트리거 전용. e2e 태그가 붙은 Selenium/통합 테스트만 실행.
|
||||||
|
# 요구 인프라:
|
||||||
|
# - Chrome + libgbm/libxkbcommon-x11 (Selenium 4종)
|
||||||
|
# - Oracle JDBC 또는 testcontainers (SignupFileTest)
|
||||||
|
# 미설치 환경에서는 SessionNotCreated/DB 에러로 일부 케이스가 실패할 수 있음.
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
e2e:
|
||||||
|
runs-on: [self-hosted, linux, eapim-portal]
|
||||||
|
env:
|
||||||
|
JAVA_HOME: /apps/opts/jdk8
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: eapim-portal
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout eapim-portal (this branch)
|
||||||
|
uses: http://172.30.1.50:3000/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: eapim-portal
|
||||||
|
|
||||||
|
- name: Checkout elink-portal-common (master, dependency)
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: |
|
||||||
|
rm -rf elink-portal-common
|
||||||
|
git clone --depth=1 --branch master \
|
||||||
|
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/elink-portal-common.git \
|
||||||
|
elink-portal-common
|
||||||
|
|
||||||
|
- name: Checkout elink-online-core-jpa (master, dependency)
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: |
|
||||||
|
mkdir -p eapim-online
|
||||||
|
rm -rf eapim-online/elink-online-core-jpa
|
||||||
|
git clone --depth=1 --branch master \
|
||||||
|
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/elink-online-core-jpa.git \
|
||||||
|
eapim-online/elink-online-core-jpa
|
||||||
|
|
||||||
|
- name: Verify toolchain
|
||||||
|
run: |
|
||||||
|
java -version
|
||||||
|
gradle --version
|
||||||
|
|
||||||
|
- name: Gradle e2e test
|
||||||
|
run: gradle test --no-daemon -PincludeE2E=true
|
||||||
|
|
||||||
|
- name: Upload test results
|
||||||
|
if: always()
|
||||||
|
uses: http://172.30.1.50:3000/actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: eapim-portal-e2e-${{ github.sha }}
|
||||||
|
path: |
|
||||||
|
eapim-portal/build/reports/tests/test/
|
||||||
|
eapim-portal/build/test-results/test/
|
||||||
|
if-no-files-found: warn
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
name: eapim-portal Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- stage
|
||||||
|
- feats/ci-test
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: [self-hosted, linux, eapim-portal]
|
||||||
|
env:
|
||||||
|
JAVA_HOME: /apps/opts/jdk8
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: eapim-portal
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout eapim-portal (this branch)
|
||||||
|
# ref 미지정 — 트리거된 브랜치/commit(github.sha) 그대로 빌드.
|
||||||
|
uses: http://172.30.1.50:3000/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: eapim-portal
|
||||||
|
|
||||||
|
- name: Checkout elink-portal-common (master, dependency)
|
||||||
|
# 의존 모듈은 항상 master 고정.
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: |
|
||||||
|
rm -rf elink-portal-common
|
||||||
|
git clone --depth=1 --branch master \
|
||||||
|
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/elink-portal-common.git \
|
||||||
|
elink-portal-common
|
||||||
|
|
||||||
|
- name: Checkout elink-online-core-jpa (master, dependency)
|
||||||
|
# 의존 모듈은 항상 master 고정.
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: |
|
||||||
|
mkdir -p eapim-online
|
||||||
|
rm -rf eapim-online/elink-online-core-jpa
|
||||||
|
git clone --depth=1 --branch master \
|
||||||
|
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/elink-online-core-jpa.git \
|
||||||
|
eapim-online/elink-online-core-jpa
|
||||||
|
|
||||||
|
- name: Verify toolchain
|
||||||
|
run: |
|
||||||
|
java -version
|
||||||
|
gradle --version
|
||||||
|
|
||||||
|
- name: Gradle test
|
||||||
|
run: gradle test --no-daemon
|
||||||
|
|
||||||
|
- name: Upload test results
|
||||||
|
# 실패해도 결과 리포트는 올려서 원인 분석 가능하게.
|
||||||
|
if: always()
|
||||||
|
uses: http://172.30.1.50:3000/actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: eapim-portal-test-${{ github.sha }}
|
||||||
|
path: |
|
||||||
|
eapim-portal/build/reports/tests/test/
|
||||||
|
eapim-portal/build/test-results/test/
|
||||||
|
if-no-files-found: warn
|
||||||
+7
-1
@@ -158,7 +158,13 @@ processResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform {
|
||||||
|
if (project.hasProperty('includeE2E') && project.includeE2E.toBoolean()) {
|
||||||
|
includeTags 'e2e'
|
||||||
|
} else {
|
||||||
|
excludeTags 'e2e'
|
||||||
|
}
|
||||||
|
}
|
||||||
enabled = true
|
enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
package com.eactive.apim.portal.apps.user;
|
package com.eactive.apim.portal.apps.user;
|
||||||
|
|
||||||
|
|
||||||
|
import com.eactive.apim.portal.apps.agreements.service.AgreementsFacade;
|
||||||
import com.eactive.apim.portal.apps.user.controller.AccountController;
|
import com.eactive.apim.portal.apps.user.controller.AccountController;
|
||||||
import com.eactive.apim.portal.apps.user.dto.PasswordChangeRequestDTO;
|
import com.eactive.apim.portal.apps.user.dto.PortalUserDTO;
|
||||||
import com.eactive.apim.portal.apps.user.dto.PortalOrgDTO;
|
import com.eactive.apim.portal.apps.user.facade.AuthFacade;
|
||||||
import com.eactive.apim.portal.apps.user.service.PortalUserService;
|
import com.eactive.apim.portal.apps.user.facade.OrgRegisterFacade;
|
||||||
|
import com.eactive.apim.portal.apps.user.facade.UserFacade;
|
||||||
import com.eactive.apim.portal.common.user.PortalAuthenticatedUser;
|
import com.eactive.apim.portal.common.user.PortalAuthenticatedUser;
|
||||||
import com.eactive.apim.portal.common.util.SecurityUtil;
|
import com.eactive.apim.portal.common.util.SecurityUtil;
|
||||||
import com.eactive.apim.portal.file.service.FileService;
|
import com.eactive.apim.portal.invitation.entity.UserInvitationEnums.InvitationStatus;
|
||||||
|
import com.eactive.apim.portal.invitation.repository.UserInvitationRepository;
|
||||||
|
import com.eactive.apim.portal.portaluser.entity.PortalUserEnums.ApprovalStatus;
|
||||||
|
import com.eactive.apim.portal.portaluser.entity.PortalUserEnums.RoleCode;
|
||||||
|
import com.eactive.apim.portal.portaluser.entity.PortalUserEnums.UserStatus;
|
||||||
|
import java.util.Optional;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
@@ -17,29 +24,38 @@ import org.mockito.MockedStatic;
|
|||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.validation.Validator;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.doThrow;
|
||||||
|
import static org.mockito.Mockito.mockStatic;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
class AccountControllerTest {
|
class AccountControllerTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Validator validator;
|
private UserFacade userFacade;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PortalUserService userService;
|
private OrgRegisterFacade orgRegisterFacade;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private FileService fileService;
|
private AgreementsFacade agreementsFacade;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AuthFacade authFacade;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private UserInvitationRepository userInvitationRepository;
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
private AccountController accountController;
|
private AccountController accountController;
|
||||||
@@ -52,110 +68,101 @@ class AccountControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testChangePassword() throws Exception {
|
void testShowChangePasswordPage() throws Exception {
|
||||||
mockMvc.perform(get("/change_password.do"))
|
mockMvc.perform(get("/change_password"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(view().name("apps/main/myUpdatePw"))
|
.andExpect(view().name("apps/mypage/passwordChangeEntry"))
|
||||||
.andExpect(model().attributeExists("passwordChangeRequest"));
|
.andExpect(model().attributeExists("passwordChangeRequest"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdatePassword() throws Exception {
|
void testUpdatePasswordRedirectsToLogin() throws Exception {
|
||||||
PasswordChangeRequestDTO dto = new PasswordChangeRequestDTO();
|
|
||||||
dto.setOldPassword("old");
|
|
||||||
dto.setNewPassword("new");
|
|
||||||
dto.setNewPassword2("new");
|
|
||||||
|
|
||||||
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
||||||
securityUtil.when(SecurityUtil::getCurrentLoginId).thenReturn("testUser");
|
securityUtil.when(SecurityUtil::getCurrentLoginId).thenReturn("testUser");
|
||||||
|
|
||||||
// when(userService.findByLoginId("testUser")).thenReturn(true);
|
mockMvc.perform(post("/mypage/change_new_password")
|
||||||
|
.param("newPassword", "NewPass!1")
|
||||||
|
.param("confirmPassword", "NewPass!1"))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(redirectedUrl("/login"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mockMvc.perform(post("/update_password.do")
|
@Test
|
||||||
.flashAttr("passwordChangeRequest", dto))
|
void testUpdatePasswordWithIllegalArgument() throws Exception {
|
||||||
|
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
||||||
|
securityUtil.when(SecurityUtil::getCurrentLoginId).thenReturn("testUser");
|
||||||
|
doThrow(new IllegalArgumentException("invalid password"))
|
||||||
|
.when(userFacade).updatePassword(eq("testUser"), anyString(), anyString());
|
||||||
|
|
||||||
|
mockMvc.perform(post("/mypage/change_new_password")
|
||||||
|
.param("newPassword", "NewPass!1")
|
||||||
|
.param("confirmPassword", "Different!1"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(view().name("apps/main/myUpdatePw"))
|
.andExpect(view().name("apps/mypage/passwordChange"))
|
||||||
|
.andExpect(model().attributeExists("error"))
|
||||||
.andExpect(model().attributeExists("passwordChangeRequest"));
|
.andExpect(model().attributeExists("passwordChangeRequest"));
|
||||||
|
|
||||||
verify(validator).validate(any(), any());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdatePasswordWithErrors() throws Exception {
|
void testMypageForUser() throws Exception {
|
||||||
PasswordChangeRequestDTO dto = new PasswordChangeRequestDTO();
|
PortalAuthenticatedUser authenticatedUser = new PortalAuthenticatedUser();
|
||||||
dto.setOldPassword("old");
|
authenticatedUser.setId("user-1");
|
||||||
dto.setNewPassword("new");
|
authenticatedUser.setLoginId("testUser");
|
||||||
dto.setNewPassword2("different");
|
authenticatedUser.setRoleCode(RoleCode.ROLE_USER);
|
||||||
|
authenticatedUser.setUserStatus(UserStatus.ACTIVE);
|
||||||
|
authenticatedUser.setApprovalStatus(ApprovalStatus.COMPLETED);
|
||||||
|
|
||||||
doAnswer(invocation -> {
|
PortalUserDTO dto = new PortalUserDTO();
|
||||||
BindingResult bindingResult = invocation.getArgument(1);
|
dto.setId("user-1");
|
||||||
bindingResult.rejectValue("newPassword2", "error.password", "Passwords do not match");
|
dto.setLoginId("testUser");
|
||||||
return null;
|
dto.setUserName("테스트유저");
|
||||||
}).when(validator).validate(any(), any(BindingResult.class));
|
dto.setMobileNumber("01012345678");
|
||||||
|
dto.setEmailAddr("test@example.com");
|
||||||
|
dto.setRoleCode(RoleCode.ROLE_USER);
|
||||||
|
|
||||||
mockMvc.perform(post("/update_password.do")
|
|
||||||
.flashAttr("passwordChangeRequest", dto))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(view().name("apps/main/myUpdatePw"))
|
|
||||||
.andExpect(model().attributeExists("errors"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testMypage() {
|
|
||||||
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
||||||
PortalAuthenticatedUser user = new PortalAuthenticatedUser();
|
securityUtil.when(SecurityUtil::getPortalAuthenticatedUser).thenReturn(authenticatedUser);
|
||||||
securityUtil.when(SecurityUtil::getPortalAuthenticatedUser).thenReturn(user);
|
when(userFacade.findById("user-1")).thenReturn(dto);
|
||||||
|
when(userInvitationRepository.findFirstByInvitationEmailAndStatus(
|
||||||
|
"test@example.com", InvitationStatus.PENDING))
|
||||||
|
.thenReturn(Optional.empty());
|
||||||
|
|
||||||
ModelAndView mav = accountController.mypage();
|
mockMvc.perform(get("/mypage"))
|
||||||
|
|
||||||
assertEquals("apps/main/myPageEnt", mav.getViewName());
|
|
||||||
assertEquals(user, mav.getModel().get("user"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testMyCompanyInfo() throws Exception {
|
|
||||||
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
|
||||||
securityUtil.when(SecurityUtil::getPortalAuthenticatedUser).thenReturn(new PortalAuthenticatedUser());
|
|
||||||
|
|
||||||
mockMvc.perform(get("/my_company_info.do"))
|
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(view().name("apps/main/myPageEntCompany"))
|
.andExpect(view().name("apps/mypage/updatePersonalUser"))
|
||||||
|
.andExpect(model().attributeExists("user"))
|
||||||
|
.andExpect(model().attribute("loginId", "testUser"))
|
||||||
|
.andExpect(model().attribute("hasPendingInvitation", false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMypageForCorporateManager() throws Exception {
|
||||||
|
PortalAuthenticatedUser authenticatedUser = new PortalAuthenticatedUser();
|
||||||
|
authenticatedUser.setId("manager-1");
|
||||||
|
authenticatedUser.setLoginId("manager");
|
||||||
|
authenticatedUser.setRoleCode(RoleCode.ROLE_CORP_MANAGER);
|
||||||
|
authenticatedUser.setUserStatus(UserStatus.ACTIVE);
|
||||||
|
authenticatedUser.setApprovalStatus(ApprovalStatus.COMPLETED);
|
||||||
|
|
||||||
|
PortalUserDTO dto = new PortalUserDTO();
|
||||||
|
dto.setId("manager-1");
|
||||||
|
dto.setLoginId("manager");
|
||||||
|
dto.setUserName("매니저");
|
||||||
|
dto.setMobileNumber("01098765432");
|
||||||
|
dto.setEmailAddr("manager@example.com");
|
||||||
|
dto.setRoleCode(RoleCode.ROLE_CORP_MANAGER);
|
||||||
|
|
||||||
|
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
||||||
|
securityUtil.when(SecurityUtil::getPortalAuthenticatedUser).thenReturn(authenticatedUser);
|
||||||
|
when(userFacade.findById("manager-1")).thenReturn(dto);
|
||||||
|
|
||||||
|
mockMvc.perform(get("/mypage"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(view().name("apps/mypage/updateCorporateManager"))
|
||||||
.andExpect(model().attributeExists("user"));
|
.andExpect(model().attributeExists("user"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testUpdateCompanyInfo() throws Exception {
|
|
||||||
PortalOrgDTO dto = new PortalOrgDTO();
|
|
||||||
dto.setOrgName("Test Company");
|
|
||||||
|
|
||||||
try (MockedStatic<SecurityUtil> securityUtil = mockStatic(SecurityUtil.class)) {
|
|
||||||
securityUtil.when(SecurityUtil::getCurrentLoginId).thenReturn("testUser");
|
|
||||||
|
|
||||||
mockMvc.perform(post("/update_my_company_info.do")
|
|
||||||
.flashAttr("user", dto))
|
|
||||||
.andExpect(status().is3xxRedirection())
|
|
||||||
.andExpect(redirectedUrl("/my_company_info.do"));
|
|
||||||
|
|
||||||
verify(validator).validate(eq(dto), any());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testUpdateCompanyInfoWithErrors() throws Exception {
|
|
||||||
PortalOrgDTO dto = new PortalOrgDTO();
|
|
||||||
|
|
||||||
doAnswer(invocation -> {
|
|
||||||
BindingResult bindingResult = invocation.getArgument(1);
|
|
||||||
bindingResult.rejectValue("companyName", "error.companyName", "Company name is required");
|
|
||||||
return null;
|
|
||||||
}).when(validator).validate(any(), any(BindingResult.class));
|
|
||||||
|
|
||||||
mockMvc.perform(post("/update_my_company_info.do")
|
|
||||||
.flashAttr("user", dto))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andExpect(view().name("apps/main/myPageEntCompany"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ public abstract class BaseWebTest {
|
|||||||
options.addArguments("--no-sandbox");
|
options.addArguments("--no-sandbox");
|
||||||
options.addArguments("--disable-dev-shm-usage");
|
options.addArguments("--disable-dev-shm-usage");
|
||||||
options.addArguments("--remote-allow-origins=*");
|
options.addArguments("--remote-allow-origins=*");
|
||||||
|
options.addArguments("--headless=new");
|
||||||
|
options.addArguments("--disable-gpu");
|
||||||
|
options.addArguments("--window-size=1280,800");
|
||||||
|
|
||||||
ChromeDriverService service = new ChromeDriverService.Builder()
|
ChromeDriverService service = new ChromeDriverService.Builder()
|
||||||
.usingAnyFreePort()
|
.usingAnyFreePort()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
@@ -17,6 +18,7 @@ import org.openqa.selenium.WebElement;
|
|||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
@Tag("e2e")
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
public class PortalOrgRegistrationRetainTest extends BaseWebTest {
|
public class PortalOrgRegistrationRetainTest extends BaseWebTest {
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
@@ -17,6 +18,7 @@ import org.openqa.selenium.WebElement;
|
|||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
@Tag("e2e")
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
public class PortalOrgRegistrationTest extends BaseWebTest {
|
public class PortalOrgRegistrationTest extends BaseWebTest {
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import io.github.bonigarcia.wdm.WebDriverManager;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
@@ -14,6 +15,7 @@ import org.openqa.selenium.WebElement;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@Tag("e2e")
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
public class PortalUserRegisterFieldTest extends BaseWebTest{
|
public class PortalUserRegisterFieldTest extends BaseWebTest{
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import com.eactive.apim.portal.PortalApplication;
|
import com.eactive.apim.portal.PortalApplication;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
@@ -17,6 +18,7 @@ import org.springframework.test.context.ActiveProfiles;
|
|||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
@Tag("e2e")
|
||||||
@SpringBootTest(classes = PortalApplication.class)
|
@SpringBootTest(classes = PortalApplication.class)
|
||||||
@ActiveProfiles({"dev", "unittest"})
|
@ActiveProfiles({"dev", "unittest"})
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ import java.nio.file.Paths;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.DynamicTest;
|
import org.junit.jupiter.api.DynamicTest;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.TestFactory;
|
import org.junit.jupiter.api.TestFactory;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
@Tag("e2e")
|
||||||
class SignupPageTest extends BaseWebTest {
|
class SignupPageTest extends BaseWebTest {
|
||||||
|
|
||||||
private final String USER_ID_FILE = "user_id_counter.txt";
|
private final String USER_ID_FILE = "user_id_counter.txt";
|
||||||
|
|||||||
Reference in New Issue
Block a user