diff --git a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java index 6c523a20f9..16ad0426e6 100644 --- a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java @@ -10,6 +10,7 @@ import io.metersphere.commons.utils.Pager; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.issue.domain.zentao.ZentaoBuild; +import io.metersphere.track.request.testcase.AuthUserIssueRequest; import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesUpdateRequest; import io.metersphere.track.service.IssuesService; @@ -59,6 +60,11 @@ public class IssuesController { issuesService.testAuth(orgId, platform); } + @PostMapping("/user/auth") + public void userAuth(@RequestBody AuthUserIssueRequest authUserIssueRequest) { + issuesService.userAuth(authUserIssueRequest); + } + @GetMapping("/close/{id}") public void closeLocalIssue(@PathVariable String id) { issuesService.closeLocalIssue(id); diff --git a/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java b/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java index 72418c4151..4bc61c55a6 100644 --- a/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java @@ -2,6 +2,7 @@ package io.metersphere.track.issue; import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.Project; +import io.metersphere.dto.UserDTO; import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.request.testcase.IssuesRequest; @@ -46,6 +47,11 @@ public interface IssuesPlatform { */ void testAuth(); + /** + * 用户信息测试 + */ + void userAuth(UserDTO.PlatformInfo userInfo); + /** * 获取缺陷平台项目下的相关人员 * @return platform user list diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index b521e78764..38db31b2f8 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -268,7 +268,18 @@ public class JiraPlatform extends AbstractIssuePlatform { @Override public void testAuth() { setConfig(); - jiraClientV2.getIssueCreateMetadata(); + jiraClientV2.auth(); + } + + @Override + public void userAuth(UserDTO.PlatformInfo userInfo) { + String config = getPlatformConfig(IssuesManagePlatform.Jira.toString()); + JiraConfig jiraConfig = JSONObject.parseObject(config, JiraConfig.class); + jiraConfig.setAccount(userInfo.getJiraAccount()); + jiraConfig.setPassword(userInfo.getJiraPassword()); + validateConfig(jiraConfig); + jiraClientV2.setConfig(jiraConfig); + jiraClientV2.auth(); } @Override diff --git a/backend/src/main/java/io/metersphere/track/issue/LocalAbstractPlatform.java b/backend/src/main/java/io/metersphere/track/issue/LocalAbstractPlatform.java new file mode 100644 index 0000000000..f105d2b669 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/issue/LocalAbstractPlatform.java @@ -0,0 +1,29 @@ +package io.metersphere.track.issue; + +import io.metersphere.base.domain.IssuesDao; +import io.metersphere.base.domain.Project; +import io.metersphere.dto.UserDTO; +import io.metersphere.track.issue.domain.PlatformUser; +import io.metersphere.track.request.testcase.IssuesRequest; + +import java.util.List; + +public abstract class LocalAbstractPlatform extends AbstractIssuePlatform { + + public LocalAbstractPlatform(IssuesRequest issuesRequest) { super(issuesRequest); } + + @Override + public void testAuth() {} + + @Override + public void userAuth(UserDTO.PlatformInfo userInfo) {} + + @Override + public List getPlatformUser() { return null; } + + @Override + public void syncIssues(Project project, List tapdIssues) {} + + @Override + String getProjectId(String projectId) { return null; } +} diff --git a/backend/src/main/java/io/metersphere/track/issue/LocalPlatform.java b/backend/src/main/java/io/metersphere/track/issue/LocalPlatform.java index 196ca6d59c..df8a94f289 100644 --- a/backend/src/main/java/io/metersphere/track/issue/LocalPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/LocalPlatform.java @@ -2,13 +2,11 @@ package io.metersphere.track.issue; import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.IssuesWithBLOBs; -import io.metersphere.base.domain.Project; import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.track.dto.DemandDTO; -import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesUpdateRequest; import org.apache.commons.lang3.StringUtils; @@ -16,7 +14,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.UUID; -public class LocalPlatform extends AbstractIssuePlatform { +public class LocalPlatform extends LocalAbstractPlatform { protected String key = IssuesManagePlatform.Local.toString(); @@ -67,31 +65,4 @@ public class LocalPlatform extends AbstractIssuePlatform { public void deleteIssue(String id) { issuesMapper.deleteByPrimaryKey(id); } - - @Override - public void testAuth() { - - } - - @Override - public List getPlatformUser() { - return null; - } - - @Override - public void syncIssues(Project project, List tapdIssues) { - - } - - @Override - String getProjectId(String projectId) { - return null; - } - - public void closeIssue(String issueId) { - IssuesWithBLOBs issues = new IssuesWithBLOBs(); - issues.setId(issueId); - issues.setStatus("closed"); - issuesMapper.updateByPrimaryKeySelective(issues); - } } diff --git a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java index 39865112d0..6a4d55b3b9 100644 --- a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java @@ -159,6 +159,11 @@ public class TapdPlatform extends AbstractIssuePlatform { } } + @Override + public void userAuth(UserDTO.PlatformInfo userInfo) { + testAuth(); + } + @Override public List getPlatformUser() { List users = new ArrayList<>(); diff --git a/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java b/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java index 9ae57dc5aa..cc4df0d6b7 100644 --- a/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java @@ -234,6 +234,16 @@ public class ZentaoPlatform extends AbstractIssuePlatform { zentaoClient.login(); } + @Override + public void userAuth(UserDTO.PlatformInfo userInfo) { + String config = getPlatformConfig(IssuesManagePlatform.Zentao.toString()); + ZentaoConfig zentaoConfig = JSONObject.parseObject(config, ZentaoConfig.class); + zentaoConfig.setAccount(userInfo.getZentaoUserName()); + zentaoConfig.setPassword(userInfo.getZentaoPassword()); + zentaoClient.setConfig(zentaoConfig); + zentaoClient.login(); + } + public ZentaoConfig setConfig() { ZentaoConfig config = getConfig(); zentaoClient.setConfig(config); diff --git a/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java b/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java index 6262f9a267..55233f885c 100644 --- a/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java +++ b/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java @@ -49,9 +49,13 @@ public abstract class JiraAbstractClient extends BaseClient { return (JiraAddIssueResponse) getResultForObject(JiraAddIssueResponse.class, response); } - public String getIssueCreateMetadata() { - ResponseEntity response = restTemplate.exchange(getBaseUrl() + "/issue/createmeta", HttpMethod.GET, getAuthHttpEntity(), String.class); - return (String) getResultForObject(String.class, response); + public void auth() { + try { + restTemplate.exchange(getBaseUrl() + "/permissions", HttpMethod.GET, getAuthHttpEntity(), String.class); + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + MSException.throwException(e.getMessage()); + } } protected HttpEntity getAuthHttpEntity() { diff --git a/backend/src/main/java/io/metersphere/track/issue/client/ZentaoClient.java b/backend/src/main/java/io/metersphere/track/issue/client/ZentaoClient.java index f1c42c5507..b1491772db 100644 --- a/backend/src/main/java/io/metersphere/track/issue/client/ZentaoClient.java +++ b/backend/src/main/java/io/metersphere/track/issue/client/ZentaoClient.java @@ -56,8 +56,14 @@ public class ZentaoClient extends BaseClient { String sessionId = login(); HttpEntity> requestEntity = new HttpEntity<>(paramMap, new HttpHeaders()); RestTemplate restTemplate = new RestTemplate(); - ResponseEntity response = restTemplate.exchange(getBaseUrl() + "/api-getModel-bug-create.json?zentaosid=" + sessionId, - HttpMethod.POST, requestEntity, String.class); + ResponseEntity response = null; + try { + response = restTemplate.exchange(getBaseUrl() + "/api-getModel-bug-create.json?zentaosid=" + sessionId, + HttpMethod.POST, requestEntity, String.class); + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + MSException.throwException(e.getMessage()); + } AddIssueResponse addIssueResponse = (AddIssueResponse) getResultForObject(AddIssueResponse.class, response); return JSONObject.parseObject(addIssueResponse.getData(), AddIssueResponse.Issue.class); } diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/AuthUserIssueRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/AuthUserIssueRequest.java new file mode 100644 index 0000000000..cc2958ab9e --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/request/testcase/AuthUserIssueRequest.java @@ -0,0 +1,13 @@ +package io.metersphere.track.request.testcase; + + +import io.metersphere.dto.UserDTO; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class AuthUserIssueRequest extends UserDTO.PlatformInfo { + private String orgId; + private String platform; +} diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index c2407b72a4..f0dde8e419 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -26,6 +26,7 @@ import io.metersphere.service.ProjectService; import io.metersphere.track.issue.*; import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.issue.domain.zentao.ZentaoBuild; +import io.metersphere.track.request.testcase.AuthUserIssueRequest; import io.metersphere.track.request.testcase.IssuesRequest; import io.metersphere.track.request.testcase.IssuesUpdateRequest; import org.apache.commons.collections.CollectionUtils; @@ -484,4 +485,11 @@ public class IssuesService { public List relateList(IssuesRequest request) { return extIssuesMapper.getRelateIssues(request); } + + public void userAuth(AuthUserIssueRequest authUserIssueRequest) { + IssuesRequest issuesRequest = new IssuesRequest(); + issuesRequest.setOrganizationId(authUserIssueRequest.getOrgId()); + AbstractIssuePlatform abstractPlatform = IssueFactory.createPlatform(authUserIssueRequest.getPlatform(), issuesRequest); + abstractPlatform.userAuth(authUserIssueRequest); + } } diff --git a/frontend/src/business/components/settings/organization/components/JiraSetting.vue b/frontend/src/business/components/settings/organization/components/JiraSetting.vue index 39b838bbfe..155f658717 100644 --- a/frontend/src/business/components/settings/organization/components/JiraSetting.vue +++ b/frontend/src/business/components/settings/organization/components/JiraSetting.vue @@ -52,6 +52,12 @@ {{ $t('organization.integration.link_the_project_now') }} +
+ 3. {{ $t('organization.integration.use_tip_three') }} + + {{ $t('organization.integration.link_the_info_now') }} + +
diff --git a/frontend/src/business/components/settings/organization/components/TapdSetting.vue b/frontend/src/business/components/settings/organization/components/TapdSetting.vue index 3f351540e6..31f369b690 100644 --- a/frontend/src/business/components/settings/organization/components/TapdSetting.vue +++ b/frontend/src/business/components/settings/organization/components/TapdSetting.vue @@ -33,6 +33,12 @@ {{ $t('organization.integration.link_the_project_now') }} +
+ 3. {{ $t('organization.integration.use_tip_three') }} + + {{ $t('organization.integration.link_the_info_now') }} + +
diff --git a/frontend/src/business/components/settings/organization/components/ZentaoSetting.vue b/frontend/src/business/components/settings/organization/components/ZentaoSetting.vue index a4bb9877be..0e4ea89727 100644 --- a/frontend/src/business/components/settings/organization/components/ZentaoSetting.vue +++ b/frontend/src/business/components/settings/organization/components/ZentaoSetting.vue @@ -36,6 +36,12 @@ {{ $t('organization.integration.link_the_project_now') }} +
+ 3. {{ $t('organization.integration.use_tip_three') }} + + {{ $t('organization.integration.link_the_info_now') }} + +
diff --git a/frontend/src/business/components/settings/personal/JiraUserInfo.vue b/frontend/src/business/components/settings/personal/JiraUserInfo.vue index 5028c9d4e8..2815b091d0 100644 --- a/frontend/src/business/components/settings/personal/JiraUserInfo.vue +++ b/frontend/src/business/components/settings/personal/JiraUserInfo.vue @@ -10,6 +10,11 @@ + + + {{$t('commons.validate')}} + + diff --git a/frontend/src/business/components/settings/personal/PersonSetting.vue b/frontend/src/business/components/settings/personal/PersonSetting.vue index 7481191861..3215e65aa8 100644 --- a/frontend/src/business/components/settings/personal/PersonSetting.vue +++ b/frontend/src/business/components/settings/personal/PersonSetting.vue @@ -34,7 +34,7 @@ - @@ -51,9 +51,9 @@ - - - + + +