From 403ca2d5f4aa2efb186de2d923d7e33deab79c8c Mon Sep 17 00:00:00 2001 From: PengxiWPix Date: Wed, 27 Mar 2024 15:55:23 +0800 Subject: [PATCH 1/5] ADM-834:[frontend]feat: fix rebase --- .../importFile/multiple-done-config-file.ts | 23 +++++++++++++++++++ .../specs/import-project-from-file.spec.ts | 3 +++ 2 files changed, 26 insertions(+) diff --git a/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts b/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts index 78b8e7ff5a..c32d70fddc 100644 --- a/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts +++ b/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts @@ -68,6 +68,29 @@ export const importMultipleDoneProjectFromFile = { Done: 'Done', }, ], + jiraColumnsEmptyByStatus: [ + { + TODO: '----', + }, + { + Doing: '----', + }, + { + Blocked: '----', + }, + { + Review: '----', + }, + { + 'WAIT FOR TEST': '----', + }, + { + Testing: '----', + }, + { + Done: '----', + }, + ], treatFlagCardAsBlock: true, }, doneStatus: ['DONE'], diff --git a/frontend/e2e/specs/import-project-from-file.spec.ts b/frontend/e2e/specs/import-project-from-file.spec.ts index 0f53a243e0..7e197ff945 100644 --- a/frontend/e2e/specs/import-project-from-file.spec.ts +++ b/frontend/e2e/specs/import-project-from-file.spec.ts @@ -5,6 +5,9 @@ import { config as metricsStepData } from '../fixtures/createNew/metricsStep'; import { ProjectCreationType } from 'e2e/pages/metrics/ReportStep'; import { test } from '../fixtures/testWithExtendFixtures'; import { clearTempDir } from 'e2e/utils/clearTempDir'; +import { + config as metricsStepData, +} from "../fixtures/createNew/metricsStep"; test.beforeAll(async () => { await clearTempDir(); From a77a7c161686203ed11e1e8139b4944a8de60220 Mon Sep 17 00:00:00 2001 From: PengxiWPix Date: Tue, 2 Apr 2024 16:53:10 +0800 Subject: [PATCH 2/5] ADM-834:[backend]feat: added api for domain url check --- .../java/heartbeat/client/JiraFeignClient.java | 2 ++ .../heartbeat/service/board/jira/JiraService.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/backend/src/main/java/heartbeat/client/JiraFeignClient.java b/backend/src/main/java/heartbeat/client/JiraFeignClient.java index 402f47008b..c2a0840a49 100644 --- a/backend/src/main/java/heartbeat/client/JiraFeignClient.java +++ b/backend/src/main/java/heartbeat/client/JiraFeignClient.java @@ -51,4 +51,6 @@ CardHistoryResponseDTO getJiraCardHistoryByCount(URI baseUrl, @PathVariable Stri @GetMapping(path = "rest/api/2/project/{projectIdOrKey}") JiraBoardProject getProject(URI baseUrl, @PathVariable String projectIdOrKey, @RequestHeader String authorization); + @GetMapping(path = "/") + void getDomain(URI baseUrl); } diff --git a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java index 8f093f38e9..01bb0096ff 100644 --- a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java +++ b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java @@ -137,11 +137,25 @@ public String verify(BoardType boardType, BoardVerifyRequestParam boardVerifyReq verifyBoardTypeIsJira(boardType); try { + jiraFeignClient.getDomain(baseUrl); + } + catch (NotFoundException e) { + System.out.println(e); + } + + try { + System.out.println(boardVerifyRequestParam.getBoardId()); + System.out.println(boardVerifyRequestParam.getToken()); + JiraBoardVerifyDTO jiraBoardVerifyDTO = jiraFeignClient.getBoard(baseUrl, boardVerifyRequestParam.getBoardId(), boardVerifyRequestParam.getToken()); + + + return jiraBoardVerifyDTO.getLocation().getProjectKey(); } catch (NotFoundException e) { + System.out.println(e); log.error("Failed to call Jira to verify board url, url: {}", baseUrl); throw new NotFoundException("boardId is incorrect"); } From 461af35aca97e6ac87d4c5358862268d87d250fc Mon Sep 17 00:00:00 2001 From: PengxiWPix Date: Wed, 3 Apr 2024 09:08:50 +0800 Subject: [PATCH 3/5] ADM-834:[backend]feat: add dashboard api for site check --- .../src/main/java/heartbeat/client/JiraFeignClient.java | 5 +++-- .../java/heartbeat/service/board/jira/JiraService.java | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/JiraFeignClient.java b/backend/src/main/java/heartbeat/client/JiraFeignClient.java index c2a0840a49..a353eac503 100644 --- a/backend/src/main/java/heartbeat/client/JiraFeignClient.java +++ b/backend/src/main/java/heartbeat/client/JiraFeignClient.java @@ -51,6 +51,7 @@ CardHistoryResponseDTO getJiraCardHistoryByCount(URI baseUrl, @PathVariable Stri @GetMapping(path = "rest/api/2/project/{projectIdOrKey}") JiraBoardProject getProject(URI baseUrl, @PathVariable String projectIdOrKey, @RequestHeader String authorization); - @GetMapping(path = "/") - void getDomain(URI baseUrl); + @GetMapping(path = "/rest/api/3/dashboard") + String getDashboard(URI baseUrl, @RequestHeader String authorization); + } diff --git a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java index 01bb0096ff..e92ca5ff4f 100644 --- a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java +++ b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java @@ -137,15 +137,17 @@ public String verify(BoardType boardType, BoardVerifyRequestParam boardVerifyReq verifyBoardTypeIsJira(boardType); try { - jiraFeignClient.getDomain(baseUrl); + String test = jiraFeignClient.getDashboard(baseUrl, boardVerifyRequestParam.getToken()); + System.out.println(test); + System.out.println("asdfasdfasdfasdfasdfasdfasdf"); } catch (NotFoundException e) { System.out.println(e); + System.out.println("==============================================="); + throw new NotFoundException("site is incorrect"); } try { - System.out.println(boardVerifyRequestParam.getBoardId()); - System.out.println(boardVerifyRequestParam.getToken()); JiraBoardVerifyDTO jiraBoardVerifyDTO = jiraFeignClient.getBoard(baseUrl, boardVerifyRequestParam.getBoardId(), boardVerifyRequestParam.getToken()); From 172f7edd90aab14739f8c3ab1ab6eb4ef098552f Mon Sep 17 00:00:00 2001 From: PengxiWPix Date: Sat, 6 Apr 2024 10:09:07 +0800 Subject: [PATCH 4/5] ADM-834:[backend]feat: added api for domain url check --- .../java/heartbeat/client/JiraFeignClient.java | 1 + .../service/board/jira/JiraService.java | 11 +---------- .../heartbeat/service/jira/JiraServiceTest.java | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/heartbeat/client/JiraFeignClient.java b/backend/src/main/java/heartbeat/client/JiraFeignClient.java index a353eac503..c9c8c24e64 100644 --- a/backend/src/main/java/heartbeat/client/JiraFeignClient.java +++ b/backend/src/main/java/heartbeat/client/JiraFeignClient.java @@ -51,6 +51,7 @@ CardHistoryResponseDTO getJiraCardHistoryByCount(URI baseUrl, @PathVariable Stri @GetMapping(path = "rest/api/2/project/{projectIdOrKey}") JiraBoardProject getProject(URI baseUrl, @PathVariable String projectIdOrKey, @RequestHeader String authorization); + // This api is solely used for site url checking @GetMapping(path = "/rest/api/3/dashboard") String getDashboard(URI baseUrl, @RequestHeader String authorization); diff --git a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java index e92ca5ff4f..b22b29a3dd 100644 --- a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java +++ b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java @@ -137,27 +137,18 @@ public String verify(BoardType boardType, BoardVerifyRequestParam boardVerifyReq verifyBoardTypeIsJira(boardType); try { - String test = jiraFeignClient.getDashboard(baseUrl, boardVerifyRequestParam.getToken()); - System.out.println(test); - System.out.println("asdfasdfasdfasdfasdfasdfasdf"); + jiraFeignClient.getDashboard(baseUrl, boardVerifyRequestParam.getToken()); } catch (NotFoundException e) { - System.out.println(e); - System.out.println("==============================================="); throw new NotFoundException("site is incorrect"); } - try { - JiraBoardVerifyDTO jiraBoardVerifyDTO = jiraFeignClient.getBoard(baseUrl, boardVerifyRequestParam.getBoardId(), boardVerifyRequestParam.getToken()); - - return jiraBoardVerifyDTO.getLocation().getProjectKey(); } catch (NotFoundException e) { - System.out.println(e); log.error("Failed to call Jira to verify board url, url: {}", baseUrl); throw new NotFoundException("boardId is incorrect"); } diff --git a/backend/src/test/java/heartbeat/service/jira/JiraServiceTest.java b/backend/src/test/java/heartbeat/service/jira/JiraServiceTest.java index f2dc06a821..f404d6525e 100644 --- a/backend/src/test/java/heartbeat/service/jira/JiraServiceTest.java +++ b/backend/src/test/java/heartbeat/service/jira/JiraServiceTest.java @@ -127,6 +127,8 @@ class JiraServiceTest { public static final String SITE_ATLASSIAN_NET = "https://site.atlassian.net"; + public static final String INVALID_SITE_ATLASSIAN_NET = "https://unknown.atlassian.net"; + private final BoardType boardTypeJira = BoardType.fromStyle("next-gen"); private final BoardType boardTypeClassicJira = BoardType.fromStyle("classic"); @@ -514,6 +516,20 @@ void shouldCallJiraFeignClientBoardAndThrowNotFoundWhenVerifyJiraBoard() { assertThat(thrown).isInstanceOf(RuntimeException.class).hasMessageContaining("boardId is incorrect"); } + @Test + void shouldCallJiraFeignClientBoardAndThrowNotFoundWhenVerifyJiraBoardSite() { + URI baseUrl = URI.create(INVALID_SITE_ATLASSIAN_NET); + String token = "token"; + BoardVerifyRequestParam boardVerifyRequestParam = BOARD_VERIFY_REQUEST_BUILDER().build(); + + when(urlGenerator.getUri(any())).thenReturn(URI.create(INVALID_SITE_ATLASSIAN_NET)); + doThrow(new NotFoundException("site is incorrect")).when(jiraFeignClient).getDashboard(baseUrl, token); + + Throwable thrown = catchThrowable(() -> jiraService.verify(boardTypeJira, boardVerifyRequestParam)); + assertThat(thrown).isInstanceOf(RuntimeException.class).hasMessageContaining("site is incorrect"); + + } + @Test @Deprecated void shouldCallJiraFeignClientAndThrowNotFoundExceptionWhenGetJiraBoardConfig() throws JsonProcessingException { From ec9228a00ecd0c82574ecf98c9cb1dd50d01c3d0 Mon Sep 17 00:00:00 2001 From: PengxiWPix Date: Sun, 7 Apr 2024 11:34:23 +0800 Subject: [PATCH 5/5] ADM-834:[frontend]fix: fix rebase --- .../importFile/multiple-done-config-file.ts | 23 ------------------- .../specs/import-project-from-file.spec.ts | 3 --- 2 files changed, 26 deletions(-) diff --git a/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts b/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts index c32d70fddc..78b8e7ff5a 100644 --- a/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts +++ b/frontend/e2e/fixtures/importFile/multiple-done-config-file.ts @@ -68,29 +68,6 @@ export const importMultipleDoneProjectFromFile = { Done: 'Done', }, ], - jiraColumnsEmptyByStatus: [ - { - TODO: '----', - }, - { - Doing: '----', - }, - { - Blocked: '----', - }, - { - Review: '----', - }, - { - 'WAIT FOR TEST': '----', - }, - { - Testing: '----', - }, - { - Done: '----', - }, - ], treatFlagCardAsBlock: true, }, doneStatus: ['DONE'], diff --git a/frontend/e2e/specs/import-project-from-file.spec.ts b/frontend/e2e/specs/import-project-from-file.spec.ts index 7e197ff945..0f53a243e0 100644 --- a/frontend/e2e/specs/import-project-from-file.spec.ts +++ b/frontend/e2e/specs/import-project-from-file.spec.ts @@ -5,9 +5,6 @@ import { config as metricsStepData } from '../fixtures/createNew/metricsStep'; import { ProjectCreationType } from 'e2e/pages/metrics/ReportStep'; import { test } from '../fixtures/testWithExtendFixtures'; import { clearTempDir } from 'e2e/utils/clearTempDir'; -import { - config as metricsStepData, -} from "../fixtures/createNew/metricsStep"; test.beforeAll(async () => { await clearTempDir();