From bc1e2754d1d79c50e029d7d78fa2c654ccfad2e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 24 Jun 2019 10:28:06 +0200 Subject: [PATCH] SONAR-11923 resolve issue as fixed now requires "administer issue" --- .../server/issue/workflow/IssueWorkflow.java | 18 +++++++++++++----- .../server/issue/TransitionServiceTest.java | 2 +- .../load_additional_fields.json | 3 +-- .../resources/org/sonar/l10n/core.properties | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/IssueWorkflow.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/IssueWorkflow.java index eca4e74b473..daf58dbbaa5 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/IssueWorkflow.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/IssueWorkflow.java @@ -73,6 +73,7 @@ public class IssueWorkflow implements Startable { private static void buildManualTransitions(StateMachine.Builder builder) { builder + // confirm .transition(Transition.builder(DefaultTransitions.CONFIRM) .from(STATUS_OPEN).to(STATUS_CONFIRMED) .conditions(IsNotHotspotNorManualVulnerability.INSTANCE) @@ -83,25 +84,32 @@ public class IssueWorkflow implements Startable { .conditions(IsNotHotspotNorManualVulnerability.INSTANCE) .functions(new SetResolution(null)) .build()) - .transition(Transition.builder(DefaultTransitions.UNCONFIRM) - .from(STATUS_CONFIRMED).to(STATUS_REOPENED) - .conditions(IsNotHotspotNorManualVulnerability.INSTANCE) - .functions(new SetResolution(null)) - .build()) + + // resolve as fixed .transition(Transition.builder(DefaultTransitions.RESOLVE) .from(STATUS_OPEN).to(STATUS_RESOLVED) .conditions(IsNotHotspotNorManualVulnerability.INSTANCE) .functions(new SetResolution(RESOLUTION_FIXED)) + .requiredProjectPermission(UserRole.ISSUE_ADMIN) .build()) .transition(Transition.builder(DefaultTransitions.RESOLVE) .from(STATUS_REOPENED).to(STATUS_RESOLVED) .conditions(IsNotHotspotNorManualVulnerability.INSTANCE) .functions(new SetResolution(RESOLUTION_FIXED)) + .requiredProjectPermission(UserRole.ISSUE_ADMIN) .build()) .transition(Transition.builder(DefaultTransitions.RESOLVE) .from(STATUS_CONFIRMED).to(STATUS_RESOLVED) .conditions(IsNotHotspotNorManualVulnerability.INSTANCE) .functions(new SetResolution(RESOLUTION_FIXED)) + .requiredProjectPermission(UserRole.ISSUE_ADMIN) + .build()) + + // reopen + .transition(Transition.builder(DefaultTransitions.UNCONFIRM) + .from(STATUS_CONFIRMED).to(STATUS_REOPENED) + .conditions(IsNotHotspotNorManualVulnerability.INSTANCE) + .functions(new SetResolution(null)) .build()) .transition(Transition.builder(DefaultTransitions.REOPEN) .from(STATUS_RESOLVED).to(STATUS_REOPENED) diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/TransitionServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/TransitionServiceTest.java index 682e07eaac1..69729235480 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/TransitionServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/TransitionServiceTest.java @@ -98,7 +98,7 @@ public class TransitionServiceTest { List result = underTest.listTransitions(issue.toDefaultIssue()); - assertThat(result).extracting(Transition::key).containsOnly("confirm", "resolve"); + assertThat(result).extracting(Transition::key).containsOnly("confirm"); } @Test diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields.json index 8f8c7fd0eb3..1011cf465d7 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields.json @@ -8,8 +8,7 @@ "set_tags" ], "transitions": [ - "confirm", - "resolve" + "confirm" ] } ], diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 2d49a5c84f3..52d8534b768 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2109,11 +2109,11 @@ projects_role.groups=Groups projects_role.admin=Administer projects_role.admin.desc=Access project settings and perform administration tasks. (Users will also need "Browse" permission) projects_role.issueadmin=Administer Issues -projects_role.issueadmin.desc=Change the type and severity of issues, resolve issues as being "won't fix" or "false-positive" (users also need "Browse" permission). +projects_role.issueadmin.desc=Change the type and severity of issues, resolve issues as being "fixed", "won't fix" or "false-positive" (users also need "Browse" permission). projects_role.securityhotspotadmin=Administer Security Hotspots projects_role.securityhotspotadmin.desc=Open a Vulnerability from a Security Hotspot. Resolved a Security Hotspot as reviewed, set it as in review or reset it as to review (users also need Browse permission). projects_role.user=Browse -projects_role.user.desc=Access a project, browse its measures and issues, confirm or resolve issues as "fixed", change the assignee, comment on issues and change tags. +projects_role.user.desc=Access a project, browse its measures and issues, confirm issues, change the assignee, comment on issues and change tags. projects_role.codeviewer=See Source Code projects_role.codeviewer.desc=View the project's source code. (Users will also need "Browse" permission) projects_role.scan=Execute Analysis -- 2.39.5