From: Simon Brandhof Date: Thu, 2 Feb 2017 13:31:06 +0000 (+0100) Subject: SONAR-8716 fix check of permissions in DebtModelBackup X-Git-Tag: 6.3-RC1~164 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6a05c7517af946e6112cd7e80dcb74368f50d134;p=sonarqube.git SONAR-8716 fix check of permissions in DebtModelBackup --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java index 780b0a1190d..e8210f16109 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java @@ -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 { diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java index f1b87603ddb..6055f994d80 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java @@ -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 ruleCaptor; + private ArgumentCaptor ruleCaptor; @Captor - ArgumentCaptor> ruleDebtListCaptor; + private ArgumentCaptor> 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);