]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8716 fix check of permissions in DebtModelBackup
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 2 Feb 2017 13:31:06 +0000 (14:31 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 7 Feb 2017 13:22:42 +0000 (14:22 +0100)
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java

index 780b0a1190d405cf81a8db533ae45c32dba6fde6..e8210f16109672252cb25c9d6e3751e0ebb132fc 100644 (file)
@@ -34,7 +34,6 @@ import org.sonar.api.utils.System2;
 import org.sonar.api.utils.ValidationMessages;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
-import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.MyBatis;
@@ -260,7 +259,7 @@ public class DebtModelBackup {
   }
 
   private void checkPermission() {
-    userSession.checkPermission(GlobalPermissions.SYSTEM_ADMIN);
+    userSession.isRoot();
   }
 
   private static class RuleDtoMatchLanguage implements Predicate<RuleDto> {
index f1b87603ddb95695230d31ecb1bdcd8ca00d9458..6055f994d8089a01ec1b57a551ad19e6e423d0ec 100644 (file)
@@ -39,7 +39,6 @@ import org.sonar.api.server.rule.RulesDefinition;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.rule.RuleDao;
@@ -70,41 +69,38 @@ public class DebtModelBackupTest {
   public UserSessionRule userSessionRule = UserSessionRule.standalone();
 
   @Mock
-  DbClient dbClient;
+  private DbClient dbClient;
   @Mock
-  DbSession session;
+  private DbSession session;
   @Mock
-  RuleDao ruleDao;
+  private RuleDao ruleDao;
   @Mock
-  RuleOperations ruleOperations;
+  private RuleOperations ruleOperations;
   @Mock
-  DebtRulesXMLImporter rulesXMLImporter;
+  private DebtRulesXMLImporter rulesXMLImporter;
   @Mock
-  DebtModelXMLExporter debtModelXMLExporter;
+  private DebtModelXMLExporter debtModelXMLExporter;
   @Mock
-  RuleDefinitionsLoader defLoader;
+  private RuleDefinitionsLoader defLoader;
   @Mock
-  System2 system2;
+  private System2 system2;
   @Mock
-  RuleIndexer ruleIndexer;
+  private RuleIndexer ruleIndexer;
   @Captor
-  ArgumentCaptor<RuleDto> ruleCaptor;
+  private ArgumentCaptor<RuleDto> ruleCaptor;
   @Captor
-  ArgumentCaptor<ArrayList<RuleDebt>> ruleDebtListCaptor;
+  private ArgumentCaptor<ArrayList<RuleDebt>> ruleDebtListCaptor;
 
-  Date now = DateUtils.parseDate("2014-03-19");
+  private Date now = DateUtils.parseDate("2014-03-19");
 
-  int currentId;
-
-  DebtModelBackup underTest;
+  private DebtModelBackup underTest;
 
   @Before
   public void setUp() {
-    userSessionRule.setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
+    userSessionRule.login().setRoot();
 
     when(system2.now()).thenReturn(now.getTime());
 
-    currentId = 10;
     when(dbClient.openSession(false)).thenReturn(session);
     when(dbClient.ruleDao()).thenReturn(ruleDao);