aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGatesWsSupport.java4
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json20
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ListActionTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ShowActionTest.java16
-rw-r--r--sonar-ws/src/main/protobuf/ws-qualitygates.proto4
6 files changed, 49 insertions, 27 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGatesWsSupport.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGatesWsSupport.java
index e0cf37f5798..b8e08178f04 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGatesWsSupport.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGatesWsSupport.java
@@ -60,7 +60,9 @@ public class QualityGatesWsSupport {
boolean isQualityGateAdmin = isQualityGateAdmin();
return Qualitygates.Actions.newBuilder()
.setCopy(isQualityGateAdmin)
- .setEdit(!isBuiltIn && isQualityGateAdmin)
+ .setRename(!isBuiltIn && isQualityGateAdmin)
+ .setManageConditions(!isBuiltIn && isQualityGateAdmin)
+ .setDelete(!isDefault && !isBuiltIn && isQualityGateAdmin)
.setSetAsDefault(!isDefault && isQualityGateAdmin)
.setAssociateProjects(!isDefault && isQualityGateAdmin)
.build();
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json
index 270dc554203..e29de1d7dfa 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json
+++ b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json
@@ -1,32 +1,36 @@
{
"qualitygates": [
{
- "id": 2,
+ "id": 8,
"name": "Sonar way",
"isDefault": true,
"isBuiltIn": true,
"actions": {
- "edit": false,
+ "rename": false,
"setAsDefault": false,
"copy": true,
- "associateProjects": false
+ "associateProjects": false,
+ "delete": false,
+ "manageConditions": false
}
},
{
- "id": 4,
+ "id": 9,
"name": "Sonar way - Without Coverage",
"isDefault": false,
"isBuiltIn": false,
"actions": {
- "edit": true,
+ "rename": true,
"setAsDefault": true,
"copy": true,
- "associateProjects": true
+ "associateProjects": true,
+ "delete": true,
+ "manageConditions": true
}
}
],
+ "default": 8,
"actions": {
"create": true
- },
- "default": 2
+ }
}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json
index 6f0a06b2700..be112e2d24f 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json
+++ b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json
@@ -1,26 +1,28 @@
{
- "id": 2,
+ "id": 5,
"name": "My Quality Gate",
- "isBuiltIn": false,
"conditions": [
{
- "id": 9,
+ "id": 2,
"metric": "blocker_violations",
"op": "GT",
"error": "0"
},
{
- "id": 10,
+ "id": 3,
"metric": "critical_violations",
"period": 1,
"op": "LT",
"warning": "0"
}
],
+ "isBuiltIn": false,
"actions": {
- "edit": true,
+ "rename": true,
"setAsDefault": true,
"copy": true,
- "associateProjects": true
+ "associateProjects": true,
+ "delete": true,
+ "manageConditions": true
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ListActionTest.java
index f4f78c3f605..edc04d97103 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ListActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ListActionTest.java
@@ -141,7 +141,8 @@ public class ListActionTest {
@Test
public void actions_with_quality_gate_administer_permission() {
userSession.logIn("john").addPermission(ADMINISTER_QUALITY_GATES, defaultOrganizationProvider.get().getUuid());
- QualityGateDto defaultQualityGate = db.qualityGates().insertQualityGate(qg -> qg.setName("Sonar way").setBuiltIn(true));
+ QualityGateDto defaultQualityGate = db.qualityGates().insertQualityGate(qg -> qg.setName("Default").setBuiltIn(false));
+ QualityGateDto builtInQualityGate = db.qualityGates().insertQualityGate(qg -> qg.setName("Sonar way").setBuiltIn(true));
QualityGateDto otherQualityGate = db.qualityGates().insertQualityGate(qg -> qg.setName("Sonar way - Without Coverage").setBuiltIn(false));
db.qualityGates().setDefaultQualityGate(defaultQualityGate);
@@ -152,10 +153,12 @@ public class ListActionTest {
.containsExactlyInAnyOrder(true);
assertThat(response.getQualitygatesList())
.extracting(QualityGate::getName,
- qg -> qg.getActions().getEdit(), qp -> qp.getActions().getCopy(), qp -> qp.getActions().getSetAsDefault(), qp -> qp.getActions().getAssociateProjects())
+ qg -> qg.getActions().getRename(), qg -> qg.getActions().getDelete(), qg -> qg.getActions().getManageConditions(),
+ qp -> qp.getActions().getCopy(), qp -> qp.getActions().getSetAsDefault(), qp -> qp.getActions().getAssociateProjects())
.containsExactlyInAnyOrder(
- tuple(defaultQualityGate.getName(), false, true, false, false),
- tuple(otherQualityGate.getName(), true, true, true, true));
+ tuple(defaultQualityGate.getName(), true, false, true, true, false, false),
+ tuple(builtInQualityGate.getName(), false, false, false, true, true, true),
+ tuple(otherQualityGate.getName(), true, true, true, true, true, true));
}
@Test
@@ -172,10 +175,11 @@ public class ListActionTest {
.containsExactlyInAnyOrder(false);
assertThat(response.getQualitygatesList())
.extracting(QualityGate::getName,
- qg -> qg.getActions().getEdit(), qp -> qp.getActions().getCopy(), qp -> qp.getActions().getSetAsDefault(), qp -> qp.getActions().getAssociateProjects())
+ qg -> qg.getActions().getRename(), qg -> qg.getActions().getDelete(), qg -> qg.getActions().getManageConditions(),
+ qp -> qp.getActions().getCopy(), qp -> qp.getActions().getSetAsDefault(), qp -> qp.getActions().getAssociateProjects())
.containsExactlyInAnyOrder(
- tuple(defaultQualityGate.getName(), false, false, false, false),
- tuple(otherQualityGate.getName(), false, false, false, false));
+ tuple(defaultQualityGate.getName(), false, false, false, false, false, false),
+ tuple(otherQualityGate.getName(), false, false, false, false, false, false));
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ShowActionTest.java
index 07da702aeac..074b8934762 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ShowActionTest.java
@@ -156,7 +156,9 @@ public class ShowActionTest {
.executeProtobuf(ShowWsResponse.class);
Actions actions = response.getActions();
- assertThat(actions.getEdit()).isTrue();
+ assertThat(actions.getRename()).isTrue();
+ assertThat(actions.getManageConditions()).isTrue();
+ assertThat(actions.getDelete()).isTrue();
assertThat(actions.getCopy()).isTrue();
assertThat(actions.getSetAsDefault()).isTrue();
assertThat(actions.getAssociateProjects()).isTrue();
@@ -172,7 +174,9 @@ public class ShowActionTest {
.executeProtobuf(ShowWsResponse.class);
Actions actions = response.getActions();
- assertThat(actions.getEdit()).isTrue();
+ assertThat(actions.getRename()).isTrue();
+ assertThat(actions.getManageConditions()).isTrue();
+ assertThat(actions.getDelete()).isFalse();
assertThat(actions.getCopy()).isTrue();
assertThat(actions.getSetAsDefault()).isFalse();
assertThat(actions.getAssociateProjects()).isFalse();
@@ -187,7 +191,9 @@ public class ShowActionTest {
.executeProtobuf(ShowWsResponse.class);
Actions actions = response.getActions();
- assertThat(actions.getEdit()).isFalse();
+ assertThat(actions.getRename()).isFalse();
+ assertThat(actions.getManageConditions()).isFalse();
+ assertThat(actions.getDelete()).isFalse();
assertThat(actions.getCopy()).isTrue();
assertThat(actions.getSetAsDefault()).isTrue();
assertThat(actions.getAssociateProjects()).isTrue();
@@ -202,7 +208,9 @@ public class ShowActionTest {
.executeProtobuf(ShowWsResponse.class);
Actions actions = response.getActions();
- assertThat(actions.getEdit()).isFalse();
+ assertThat(actions.getRename()).isFalse();
+ assertThat(actions.getManageConditions()).isFalse();
+ assertThat(actions.getDelete()).isFalse();
assertThat(actions.getCopy()).isFalse();
assertThat(actions.getSetAsDefault()).isFalse();
assertThat(actions.getAssociateProjects()).isFalse();
diff --git a/sonar-ws/src/main/protobuf/ws-qualitygates.proto b/sonar-ws/src/main/protobuf/ws-qualitygates.proto
index e7355755459..08e1c4570dd 100644
--- a/sonar-ws/src/main/protobuf/ws-qualitygates.proto
+++ b/sonar-ws/src/main/protobuf/ws-qualitygates.proto
@@ -157,10 +157,12 @@ message ListWsResponse {
}
message Actions {
- optional bool edit = 1;
+ optional bool rename = 1;
optional bool setAsDefault = 2;
optional bool copy = 3;
optional bool associateProjects = 4;
+ optional bool delete = 5;
+ optional bool manageConditions = 6;
}