aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-01-25 16:30:11 -0600
committersonartech <sonartech@sonarsource.com>2021-02-08 20:07:44 +0000
commit8b5ec8c3375adfa1a5e2e9ffa134c4f153614147 (patch)
tree332073556ff12d0da2f62c95f690c2d9b842489e
parenteaa3c931777204492328dc49c93e2cfca3d9c307 (diff)
downloadsonarqube-8b5ec8c3375adfa1a5e2e9ffa134c4f153614147.tar.gz
sonarqube-8b5ec8c3375adfa1a5e2e9ffa134c4f153614147.zip
SONAR-14395 Validate permissions for BitBucket PR decoration settings
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java1
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java8
2 files changed, 9 insertions, 0 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java
index 0e71eb9633e..1e66f542c5d 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java
@@ -33,6 +33,7 @@ import org.sonar.db.DbSession;
import org.sonar.db.alm.setting.ALM;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.server.user.UserSession;
+import org.sonarqube.ws.AlmSettings;
import org.sonarqube.ws.AlmSettings.AlmSettingBitbucketCloud;
import org.sonarqube.ws.AlmSettings.AlmSettingGithub;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java
index 5966cda5773..34cbe3814f0 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java
@@ -96,6 +96,8 @@ public class ValidateAction implements AlmSettingsWsAction {
case BITBUCKET:
validateBitbucketServer(almSettingDto);
break;
+ case BITBUCKET_CLOUD:
+ validateBitbucketCloud(almSettingDto);
case AZURE_DEVOPS:
validateAzure(almSettingDto);
break;
@@ -142,4 +144,10 @@ public class ValidateAction implements AlmSettingsWsAction {
bitbucketServerRestClient.validateToken(almSettingDto.getUrl(), almSettingDto.getPersonalAccessToken());
bitbucketServerRestClient.validateReadPermission(almSettingDto.getUrl(), almSettingDto.getPersonalAccessToken());
}
+
+ private void validateBitbucketCloud(AlmSettingDto almSettingDto) {
+ bitbucketServerRestClient.validateUrl(almSettingDto.getUrl());
+ bitbucketServerRestClient.validateToken(almSettingDto.getUrl(), almSettingDto.getPersonalAccessToken());
+ bitbucketServerRestClient.validateReadPermission(almSettingDto.getUrl(), almSettingDto.getPersonalAccessToken());
+ }
}