diff options
21 files changed, 372 insertions, 20 deletions
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index 839e2c6aae4..b99e0c4b47d 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -122,7 +122,7 @@ public class ComputeEngineContainerImplTest { ); assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF - + 6 // MigrationConfigurationModule + + 7 // MigrationConfigurationModule + 16 // level 2 ); assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java index e724ff44940..1d3754e6f39 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java @@ -27,6 +27,7 @@ import org.sonar.server.platform.db.migration.step.MigrationStepsProvider; import org.sonar.server.platform.db.migration.version.v00.DbVersion00; import org.sonar.server.platform.db.migration.version.v80.DbVersion80; import org.sonar.server.platform.db.migration.version.v81.DbVersion81; +import org.sonar.server.platform.db.migration.version.v82.DbVersion82; public class MigrationConfigurationModule extends Module { @Override @@ -36,6 +37,7 @@ public class MigrationConfigurationModule extends Module { DbVersion00.class, DbVersion80.class, DbVersion81.class, + DbVersion82.class, // migration steps MigrationStepRegistryImpl.class, diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java index f09d1c15fa7..997f9362c41 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java @@ -42,8 +42,6 @@ public class DbVersion81 implements DbVersion { RenameDaysBeforeDeletingInactiveSLBSetting.class) .add(3112, "Migrate short and long living branches types to common BRANCH type", MigrateSlbsAndLlbsToCommonType.class) .add(3113, "Migrate short and long living branches types to common BRANCH type in ce tasks table", - MigrateSlbsAndLlbsToCommonTypeInCeTasks.class) - .add(3114, "Drop 'In Review' Security Hotspots status ", DropSecurityHotSpotsInReviewStatus.class) - .add(3115, "Migrate Manual Vulnerabilities to Security Hotspots ", MigrateManualVulnerabilitiesToSecurityHotSpots.class); + MigrateSlbsAndLlbsToCommonTypeInCeTasks.class); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java new file mode 100644 index 00000000000..d46e7ca508a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v81; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class RemoveNewsboxDismissHotspotsProperty extends DataChange { + + public RemoveNewsboxDismissHotspotsProperty(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + context.prepareUpsert("delete from user_properties where kee='newsbox.dismiss.hotspots'") + .execute() + .commit(); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java new file mode 100644 index 00000000000..ccaa809ef80 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java @@ -0,0 +1,33 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v82; + +import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; +import org.sonar.server.platform.db.migration.version.DbVersion; + +public class DbVersion82 implements DbVersion { + @Override + public void addSteps(MigrationStepRegistry registry) { + registry + .add(3200, "Drop 'In Review' Security Hotspots status ", DropSecurityHotSpotsInReviewStatus.class) + .add(3201, "Migrate Manual Vulnerabilities to Security Hotspots ", MigrateManualVulnerabilitiesToSecurityHotSpots.class) + .add(3202, "Remove 'newsbox.dismiss.hotspots' user property", RemoveNewsboxDismissHotspotsProperty.class); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatus.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatus.java index 7b1248d2c19..44601a38c09 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatus.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatus.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v81; +package org.sonar.server.platform.db.migration.version.v82; import java.sql.SQLException; import org.sonar.api.utils.System2; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpots.java index 8c3e16a33f5..a170484888e 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpots.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpots.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v81; +package org.sonar.server.platform.db.migration.version.v82; import java.sql.SQLException; import org.sonar.api.utils.System2; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java new file mode 100644 index 00000000000..1acb60826a5 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v82; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class RemoveNewsboxDismissHotspotsProperty extends DataChange { + + public RemoveNewsboxDismissHotspotsProperty(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + context.prepareUpsert("delete from user_properties where kee='newsbox.dismiss.hotspots'") + .execute() + .commit(); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java index 615d0ebd933..17f0012f50f 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java @@ -37,7 +37,7 @@ public class MigrationConfigurationModuleTest { assertThat(container.getPicoContainer().getComponentAdapters()) .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER // DbVersion classes - + 3 + + 4 // Others + 4); } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java index 1bbfa86ae55..46c2f39dfd8 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java @@ -36,7 +36,7 @@ public class DbVersion81Test { @Test public void verify_migration_count() { - verifyMigrationCount(underTest, 16); + verifyMigrationCount(underTest, 14); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java new file mode 100644 index 00000000000..284e5c308c6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java @@ -0,0 +1,93 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v81; + +import java.sql.SQLException; +import java.time.Instant; +import java.util.Random; +import java.util.UUID; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.db.CoreDbTester; + +import static java.lang.String.format; +import static org.junit.Assert.assertEquals; + +public class RemoveNewsboxDismissHotspotsPropertyTest { + + private static final String USER_PROPERTIES_TABLE_NAME = "user_properties"; + private static final int TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES = 10; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveNewsboxDismissHotspotsPropertyTest.class, "schema.sql"); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private Random random = new Random(); + + private RemoveNewsboxDismissHotspotsProperty underTest = new RemoveNewsboxDismissHotspotsProperty(dbTester.database()); + + @Before + public void setup() { + insertUserProperty("some-user-uuid", "some-property", random.nextBoolean()); + + for (int i = 1; i <= TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES; i++) { + insertUserProperty(format("user-uuid-%s", i), "newsbox.dismiss.hotspots", random.nextBoolean()); + } + + int propertiesCount = dbTester.countRowsOfTable(USER_PROPERTIES_TABLE_NAME); + assertEquals(TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES + 1, propertiesCount); + } + + @Test + public void remove_newsbox_dismiss_hotspot_property() throws SQLException { + underTest.execute(); + + verifyResult(); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + underTest.execute(); + + verifyResult(); + } + + private void verifyResult() { + int hotspotDismissPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee = 'newsbox.dismiss.hotspots'"); + assertEquals(0, hotspotDismissPropertiesCount); + int otherPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee != 'newsbox.dismiss.hotspots'"); + assertEquals(1, otherPropertiesCount); + } + + private void insertUserProperty(String userUuid, String key, boolean value) { + dbTester.executeInsert(USER_PROPERTIES_TABLE_NAME, + "uuid", UUID.randomUUID().toString(), + "kee", key, + "user_uuid", userUuid, + "text_value", value, + "created_at", Instant.now().toEpochMilli(), + "updated_at", Instant.now().toEpochMilli()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java new file mode 100644 index 00000000000..0776c6275e6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v82; + +import org.junit.Test; +import org.sonar.server.platform.db.migration.version.DbVersion; + +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; + +public class DbVersion82Test { + + private DbVersion underTest = new DbVersion82(); + + @Test + public void migrationNumber_starts_at_3000() { + verifyMinimumMigrationNumber(underTest, 3200); + } + + @Test + public void verify_migration_count() { + verifyMigrationCount(underTest, 3); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatusTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java index 33272ea586a..9ede542c649 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatusTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v81; +package org.sonar.server.platform.db.migration.version.v82; import java.sql.SQLException; import java.util.List; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java index 975e3eaa3a1..50cba019e05 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.platform.db.migration.version.v81; +package org.sonar.server.platform.db.migration.version.v82; import java.sql.SQLException; import java.util.ArrayList; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java new file mode 100644 index 00000000000..c087c18c646 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java @@ -0,0 +1,93 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v82; + +import java.sql.SQLException; +import java.time.Instant; +import java.util.Random; +import java.util.UUID; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.db.CoreDbTester; + +import static java.lang.String.format; +import static org.junit.Assert.assertEquals; + +public class RemoveNewsboxDismissHotspotsPropertyTest { + + private static final String USER_PROPERTIES_TABLE_NAME = "user_properties"; + private static final int TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES = 10; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveNewsboxDismissHotspotsPropertyTest.class, "schema.sql"); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private Random random = new Random(); + + private RemoveNewsboxDismissHotspotsProperty underTest = new RemoveNewsboxDismissHotspotsProperty(dbTester.database()); + + @Before + public void setup() { + insertUserProperty("some-user-uuid", "some-property", random.nextBoolean()); + + for (int i = 1; i <= TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES; i++) { + insertUserProperty(format("user-uuid-%s", i), "newsbox.dismiss.hotspots", random.nextBoolean()); + } + + int propertiesCount = dbTester.countRowsOfTable(USER_PROPERTIES_TABLE_NAME); + assertEquals(TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES + 1, propertiesCount); + } + + @Test + public void remove_newsbox_dismiss_hotspot_property() throws SQLException { + underTest.execute(); + + verifyResult(); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + underTest.execute(); + + verifyResult(); + } + + private void verifyResult() { + int hotspotDismissPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee = 'newsbox.dismiss.hotspots'"); + assertEquals(0, hotspotDismissPropertiesCount); + int otherPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee != 'newsbox.dismiss.hotspots'"); + assertEquals(1, otherPropertiesCount); + } + + private void insertUserProperty(String userUuid, String key, boolean value) { + dbTester.executeInsert(USER_PROPERTIES_TABLE_NAME, + "uuid", UUID.randomUUID().toString(), + "kee", key, + "user_uuid", userUuid, + "text_value", value, + "created_at", Instant.now().toEpochMilli(), + "updated_at", Instant.now().toEpochMilli()); + } +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql new file mode 100644 index 00000000000..8ce5b03c093 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_PROPERTIES" ( + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(255) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "TEXT_VALUE" VARCHAR(4000) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_USER_PROPERTIES" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "USER_PROPERTIES_USER_UUID_KEE" ON "USER_PROPERTIES" ("USER_UUID", "KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatusTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest/schema.sql index d8f2d4316ab..d8f2d4316ab 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatusTest/schema.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest/schema.sql diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql index d8f2d4316ab..d8f2d4316ab 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql new file mode 100644 index 00000000000..8ce5b03c093 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_PROPERTIES" ( + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(255) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "TEXT_VALUE" VARCHAR(4000) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + + CONSTRAINT "PK_USER_PROPERTIES" PRIMARY KEY ("UUID") +); +CREATE UNIQUE INDEX "USER_PROPERTIES_USER_UUID_KEE" ON "USER_PROPERTIES" ("USER_UUID", "KEE"); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetSettingAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetSettingAction.java index 8acbcf797b1..4b208c7ca2d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetSettingAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetSettingAction.java @@ -57,7 +57,7 @@ public class SetSettingAction implements UsersWsAction { .setRequired(true) .setMaximumLength(100) .setDescription("Setting key") - .setPossibleValues("notifications.optOut", UserUpdater.NOTIFICATIONS_READ_DATE, "newsbox.dismiss.hotspots"); + .setPossibleValues("notifications.optOut", UserUpdater.NOTIFICATIONS_READ_DATE); action.createParam(PARAM_VALUE) .setRequired(true) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetSettingActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetSettingActionTest.java index 96030c5eaa2..2dd0af8b413 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetSettingActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetSettingActionTest.java @@ -91,17 +91,11 @@ public class SetSettingActionTest { .setParam("value", "true") .execute(); - ws.newRequest() - .setParam("key", "newsbox.dismiss.hotspots") - .setParam("value", "true") - .execute(); - assertThat(db.getDbClient().userPropertiesDao().selectByUser(db.getSession(), user)) .extracting(UserPropertyDto::getKey, UserPropertyDto::getValue) .containsExactlyInAnyOrder( tuple("notifications.readDate", "1234"), - tuple("notifications.optOut", "true"), - tuple("newsbox.dismiss.hotspots", "true")); + tuple("notifications.optOut", "true")); } @Test @@ -131,8 +125,7 @@ public class SetSettingActionTest { assertThat(definition.param("key").possibleValues()).containsExactlyInAnyOrder( "notifications.optOut", - "notifications.readDate", - "newsbox.dismiss.hotspots"); + "notifications.readDate"); } } |