aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-23 14:56:07 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-23 15:09:58 +0200
commit6a4f6808d2afe98483a5b6b3a1f84c3c62f0860d (patch)
tree8cee94bea2c31fee0efa7746c3417fd695a5e8a1
parentf8976f55db6ad52c437a2a41f1b609f4c936ff2c (diff)
downloadsonarqube-6a4f6808d2afe98483a5b6b3a1f84c3c62f0860d.tar.gz
sonarqube-6a4f6808d2afe98483a5b6b3a1f84c3c62f0860d.zip
SONAR-5559 Do not select views, devs, and tech projects when indexing issue authorization
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueAuthorizationDaoTest.java11
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueAuthorizationDaoTest/not_synchronize_view_dev_or_tech_projects.xml27
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml16
3 files changed, 49 insertions, 5 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueAuthorizationDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueAuthorizationDaoTest.java
index d036288669b..1779efa134c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueAuthorizationDaoTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueAuthorizationDaoTest.java
@@ -87,4 +87,15 @@ public class IssueAuthorizationDaoTest extends AbstractDaoTestCase {
assertThat(session.getActionCount()).isEqualTo(2);
}
+ @Test
+ public void not_synchronize_view_dev_or_tech_projects() throws Exception {
+ setupData("not_synchronize_view_dev_or_tech_projects");
+
+ assertThat(session.getActionCount()).isEqualTo(0);
+
+ dao.synchronizeAfter(session, new Date(0));
+ // SynchronizeAfter adds an implicit action (refresh) after execution of synchronization
+ assertThat(session.getActionCount()).isEqualTo(1);
+ }
+
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueAuthorizationDaoTest/not_synchronize_view_dev_or_tech_projects.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueAuthorizationDaoTest/not_synchronize_view_dev_or_tech_projects.xml
new file mode 100644
index 00000000000..11a70553a2d
--- /dev/null
+++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueAuthorizationDaoTest/not_synchronize_view_dev_or_tech_projects.xml
@@ -0,0 +1,27 @@
+<dataset>
+
+ <!-- view -->
+ <projects id="1" kee="VIEW" name="View" long_name="View" scope="PRJ" qualifier="VW" root_id="[null]" description="[null]"
+ uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]"
+ enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]"
+ created_at="2014-09-01" authorization_updated_at="2014-01-01"/>
+
+ <!-- developer -->
+ <projects id="2" kee="DEV:developer@company.net" name="developer@company.net" long_name="Developer" scope="PRJ" qualifier="DEV" root_id="[null]" description="[null]"
+ uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]"
+ enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]"
+ created_at="2014-09-01" authorization_updated_at="2014-01-01"/>
+
+ <!-- Tech project -->
+ <projects id="3" kee="VIEWorg.codehaus.sonar-plugins:sonar-piwik-plugin" name="Piwik" long_name="Piwik" scope="FIL" qualifier="TRK" root_id="[null]" description="[null]"
+ uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]"
+ enabled="[true]" language="[null]" copy_resource_id="3" person_id="[null]" path="[null]" deprecated_kee="[null]"
+ created_at="2014-09-01" authorization_updated_at="2014-01-01"/>
+
+ <!-- Anyone group -->
+
+ <group_roles id="1" group_id="[null]" resource_id="1" role="user"/>
+ <group_roles id="2" group_id="[null]" resource_id="2" role="user"/>
+
+
+</dataset>
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml
index 2a7b3ecb06d..6ef0e709145 100644
--- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml
@@ -32,8 +32,10 @@
INNER JOIN users ON users.id = user_roles.user_id
WHERE
projects.authorization_updated_at &gt;= #{date}
+ AND projects.qualifier = 'TRK'
+ AND projects.copy_resource_id is NULL
<if test="project != null">
- and projects.uuid = #{project}
+ AND projects.uuid = #{project}
</if>
UNION
-- groups without Anyone
@@ -47,9 +49,11 @@
INNER JOIN group_roles ON group_roles.resource_id = projects.id AND group_roles.role = #{permission}
INNER JOIN groups ON groups.id = group_roles.group_id
WHERE
- projects.authorization_updated_at &gt;= #{date}
+ projects.authorization_updated_at &gt;= #{date}
+ AND projects.qualifier = 'TRK'
+ AND projects.copy_resource_id is NULL
<if test="project != null">
- and projects.uuid = #{project}
+ AND projects.uuid = #{project}
</if>
AND group_id IS NOT NULL
UNION
@@ -63,9 +67,11 @@
FROM projects
INNER JOIN group_roles ON group_roles.resource_id = projects.id AND group_roles.role = #{permission}
WHERE
- projects.authorization_updated_at &gt;= #{date}
+ projects.authorization_updated_at &gt;= #{date}
+ AND projects.qualifier = 'TRK'
+ AND projects.copy_resource_id is NULL
<if test="project != null">
- and projects.uuid = #{project}
+ AND projects.uuid = #{project}
</if>
AND group_roles.group_id IS NULL
) project_authorization