]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14395 Validate permissions for BitBucket PR decoration settings
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 25 Jan 2021 22:30:11 +0000 (16:30 -0600)
committersonartech <sonartech@sonarsource.com>
Mon, 8 Feb 2021 20:07:44 +0000 (20:07 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java

index 0e71eb9633e75756c3402a06c4b79816a617c6b1..1e66f542c5de5ebde7c9174f55cb7632c5b7f220 100644 (file)
@@ -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;
 
index 5966cda57736b3a3d9e81bb289de7ff711e00de5..34cbe3814f0c84e6eca5744705c3b82063250f88 100644 (file)
@@ -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());
+  }
 }