return mapper(dbSession).countByQuery(query);
}
+ public void deleteByGroup(DbSession dbSession, GroupDto group) {
+ mapper(dbSession).deleteByGroup(group.getUuid());
+ }
+
public void deleteByQualityGateAndGroup(DbSession dbSession, QualityGateDto qualityGate, GroupDto group) {
mapper(dbSession).delete(qualityGate.getUuid(), group.getUuid());
}
int countByQuery(@Param("query") SearchPermissionQuery query);
+ void deleteByGroup(@Param("groupUuid") String groupUuid);
+
void delete(@Param("qualityGateUuid") String qualityGateUuid, @Param("groupUuid") String groupUuid);
}
and group_uuid = #{groupUuid, jdbcType=VARCHAR}
</delete>
+ <delete id="deleteByGroup" parameterType="map">
+ delete from qgate_group_permissions
+ where group_uuid = #{groupUuid, jdbcType=VARCHAR}
+ </delete>
+
</mapper>
.containsExactly(group1.getUuid(), group2.getUuid(), group3.getUuid());
}
+ @Test
+ public void deleteByGroup() {
+ QualityGateDto qualityGateDto1 = insertQualityGate();
+ QualityGateDto qualityGateDto2 = insertQualityGate();
+ QualityGateDto qualityGateDto3 = insertQualityGate();
+
+ GroupDto group1 = dbTester.users().insertGroup();
+ GroupDto group2 = dbTester.users().insertGroup();
+ dbTester.qualityGates().addGroupPermission(qualityGateDto1, group1);
+ dbTester.qualityGates().addGroupPermission(qualityGateDto2, group2);
+ dbTester.qualityGates().addGroupPermission(qualityGateDto3, group1);
+
+ underTest.deleteByGroup(dbSession, group1);
+
+ assertThat(underTest.exists(dbSession, qualityGateDto1, group1)).isFalse();
+ assertThat(underTest.exists(dbSession, qualityGateDto2, group2)).isTrue();
+ assertThat(underTest.exists(dbSession, qualityGateDto3, group1)).isFalse();
+ }
+
@Test
public void deleteByQProfileAndGroup() {
QualityGateDto qualityGateDto = insertQualityGate();
removeFromPermissionTemplates(dbSession, group);
removeGroupMembers(dbSession, group);
dbClient.qProfileEditGroupsDao().deleteByGroup(dbSession, group);
+ dbClient.qualityGateGroupPermissionsDao().deleteByGroup(dbSession, group);
dbClient.groupDao().deleteByUuid(dbSession, group.getUuid(), group.getName());
dbSession.commit();
import org.sonar.db.component.ComponentTesting;
import org.sonar.db.permission.template.PermissionTemplateDto;
import org.sonar.db.permission.template.PermissionTemplateTesting;
+import org.sonar.db.qualitygate.QualityGateDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
assertThat(db.countRowsOfTable("qprofile_edit_groups")).isZero();
}
+ @Test
+ public void delete_qgate_permissions() {
+ addAdmin();
+ insertDefaultGroup();
+ GroupDto group = db.users().insertGroup();
+ QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
+ db.qualityGates().addGroupPermission(qualityGate, group);
+ loginAsAdmin();
+
+ newRequest()
+ .setParam("id", group.getUuid())
+ .execute();
+
+ assertThat(db.countRowsOfTable("qgate_group_permissions")).isZero();
+ }
+
@Test
public void fail_if_id_does_not_exist() {
addAdmin();