]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15075 - Add analysis warning if missing contents read permission for GH private...
authorAntoine Vinot <antoine.vinot@sonarsource.com>
Fri, 16 Jun 2023 14:24:01 +0000 (16:24 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 20 Jun 2023 15:13:44 +0000 (15:13 +0000)
server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java
server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/config/GithubProvisioningConfigValidatorTest.java

index a7c53ee975a35960228999ba378fd67048b824a9..779fefbadd53a53d036f2ae13d753e6d5bb3def0 100644 (file)
@@ -148,11 +148,14 @@ public class GithubBinding {
     String members;
     @SerializedName("emails")
     String emails;
+    @SerializedName("contents")
+    String contents;
 
-    public Permissions(@Nullable String checks, @Nullable String members, @Nullable String emails) {
+    public Permissions(@Nullable String checks, @Nullable String members, @Nullable String emails, @Nullable String contents) {
       this.checks = checks;
       this.members = members;
       this.emails = emails;
+      this.contents = contents;
     }
 
     public Permissions() {
@@ -175,6 +178,11 @@ public class GithubBinding {
     public String getEmails() {
       return emails;
     }
+
+    @CheckForNull
+    public String getContents() {
+      return contents;
+    }
   }
 
   public static class GsonRepositorySearch {
index 6adc346797341254a8eac33d30c1e425fa658eac..2d64e2b4a5ca060b4d127d3d4a9bc4efcda4e122 100644 (file)
@@ -166,7 +166,7 @@ public class GithubProvisioningConfigValidatorTest {
     ArgumentCaptor<GithubAppConfiguration> appConfigurationCaptor = ArgumentCaptor.forClass(GithubAppConfiguration.class);
 
     GsonApp githubApp = mockGithubApp(appConfigurationCaptor);
-    when(githubApp.getPermissions()).thenReturn(new Permissions(null, null, "read"));
+    when(githubApp.getPermissions()).thenReturn(new Permissions(null, null, "read", null));
     mockOrganizations(appConfigurationCaptor, "org1", "org2");
 
     ConfigCheckResult checkResult = configValidator.checkConfig();
@@ -268,7 +268,7 @@ public class GithubProvisioningConfigValidatorTest {
   private GsonApp mockGithubAppWithValidConfig(ArgumentCaptor<GithubAppConfiguration> appConfigurationCaptor) {
     GsonApp githubApp = mock(GsonApp.class);
     when(githubClient.getApp(appConfigurationCaptor.capture())).thenReturn(githubApp);
-    when(githubApp.getPermissions()).thenReturn(new Permissions(null, "read", "read"));
+    when(githubApp.getPermissions()).thenReturn(new Permissions(null, "read", "read", null));
 
     return githubApp;
   }
@@ -299,7 +299,7 @@ public class GithubProvisioningConfigValidatorTest {
 
   private static GithubAppInstallation mockInstallationWithMembersPermission(String org) {
     GithubAppInstallation installation = mockInstallation(org);
-    when(installation.permissions()).thenReturn(new Permissions(null, "read", "read"));
+    when(installation.permissions()).thenReturn(new Permissions(null, "read", "read", null));
     return installation;
   }