diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2020-10-12 10:28:26 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-10-16 20:07:40 +0000 |
commit | 073c87437febccfa5217eb42a86a31e646275b57 (patch) | |
tree | 9f4095d6abe5c3285f0012798610aa7d162818c9 /server | |
parent | 7de02f77f4ccc5761081f50eb2d7aa42a45f5642 (diff) | |
download | sonarqube-073c87437febccfa5217eb42a86a31e646275b57.tar.gz sonarqube-073c87437febccfa5217eb42a86a31e646275b57.zip |
SONAR-13936 Remove organization parameter from Users
* SONAR-13936 Remove organization parameter from api/users/groups
* SONAR-13936 Remove organization_uuid column from users table
Diffstat (limited to 'server')
8 files changed, 113 insertions, 33 deletions
diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl index 6f54915f01d..c0ed77595ea 100644 --- a/server/sonar-db-dao/src/schema/schema-sq.ddl +++ b/server/sonar-db-dao/src/schema/schema-sq.ddl @@ -941,7 +941,6 @@ CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); CREATE TABLE "USERS"( "UUID" VARCHAR(255) NOT NULL, "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), "NAME" VARCHAR(200), "EMAIL" VARCHAR(100), "CRYPTED_PASSWORD" VARCHAR(100), diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java index c8fe23774bb..660e864dfb7 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java @@ -33,6 +33,8 @@ public class DbVersion86 implements DbVersion { .add(4103, "Drop organization_uuid from 'default_qprofiles' table", DropOrganizationFromDefaultQProfiles.class) .add(4104, "Add primary key to the table 'default_qprofiles", AddPrimaryKeyToDefaultQProfiles.class) .add(4105, "Drop 'organization_uuid' in 'rules_metadata'", DropOrganizationInRulesMetadata.class) - .add(4106, "Update 'change_data' column of 'qprofile_changes' table to use ruleUuid", UpdateChangeDataOfQProfileChanges.class); + .add(4106, "Update 'change_data' column of 'qprofile_changes' table to use ruleUuid", UpdateChangeDataOfQProfileChanges.class) + .add(4107, "Drop 'organization_uuid' in 'users'", DropOrganizationInUsers.class) + ; } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsers.java new file mode 100644 index 00000000000..9128567da72 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsers.java @@ -0,0 +1,39 @@ +/* + * 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.v86; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropOrganizationInUsers extends DdlChange { + + private static final String TABLE_NAME = "users"; + + public DropOrganizationInUsers(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "organization_uuid").build()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest.java new file mode 100644 index 00000000000..7f6e699a95a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest.java @@ -0,0 +1,41 @@ +/* + * 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.v86; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropOrganizationInUsersTest { + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInUsersTest.class, "schema.sql"); + + private MigrationStep underTest = new DropOrganizationInUsers(dbTester.database()); + + @Test + public void column_has_been_dropped() throws SQLException { + underTest.execute(); + dbTester.assertColumnDoesNotExist("users", "organization_uuid"); + } + +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest/schema.sql new file mode 100644 index 00000000000..b748aff7b53 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInUsersTest/schema.sql @@ -0,0 +1,28 @@ +CREATE TABLE "USERS"( + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java index 80a9c7cb7d9..dbcbbb058ad 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java @@ -52,7 +52,6 @@ import static org.sonar.api.utils.Paging.forPageIndex; import static org.sonar.server.exceptions.NotFoundException.checkFound; import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOGIN; -import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_ORGANIZATION; public class GroupsAction implements UsersWsAction { @@ -62,7 +61,7 @@ public class GroupsAction implements UsersWsAction { private final UserSession userSession; private final DefaultGroupFinder defaultGroupFinder; - public GroupsAction(DbClient dbClient, UserSession userSession, DefaultGroupFinder defaultGroupFinder) { + public GroupsAction(DbClient dbClient, UserSession userSession, DefaultGroupFinder defaultGroupFinder) { this.dbClient = dbClient; this.userSession = userSession; this.defaultGroupFinder = defaultGroupFinder; @@ -86,12 +85,6 @@ public class GroupsAction implements UsersWsAction { .setDescription("A user login") .setExampleValue("admin") .setRequired(true); - - action.createParam(PARAM_ORGANIZATION) - .setDescription("Organization key") - .setExampleValue("my-org") - .setInternal(true) - .setSince("6.4"); } @Override @@ -125,7 +118,6 @@ public class GroupsAction implements UsersWsAction { checkArgument(pageSize <= MAX_PAGE_SIZE, "The '%s' parameter must be less than %s", PAGE_SIZE, MAX_PAGE_SIZE); return GroupsRequest.builder() .setLogin(request.mandatoryParam(PARAM_LOGIN)) - .setOrganization(request.param(PARAM_ORGANIZATION)) .setSelected(request.mandatoryParam(SELECTED)) .setQuery(request.param(TEXT_QUERY)) .setPage(request.mandatoryParamAsInt(PAGE)) @@ -168,7 +160,6 @@ public class GroupsAction implements UsersWsAction { private static class GroupsRequest { private final String login; - private final String organization; private final String query; private final String selected; private final Integer page; @@ -176,7 +167,6 @@ public class GroupsAction implements UsersWsAction { private GroupsRequest(Builder builder) { this.login = builder.login; - this.organization = builder.organization; this.query = builder.query; this.selected = builder.selected; this.page = builder.page; @@ -188,11 +178,6 @@ public class GroupsAction implements UsersWsAction { } @CheckForNull - public String getOrganization() { - return organization; - } - - @CheckForNull public String getQuery() { return query; } @@ -219,7 +204,6 @@ public class GroupsAction implements UsersWsAction { private static class Builder { private String login; - private String organization; private String query; private String selected; private Integer page; @@ -234,11 +218,6 @@ public class GroupsAction implements UsersWsAction { return this; } - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - public Builder setQuery(@Nullable String query) { this.query = query; return this; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetHomepageAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetHomepageAction.java index 053f1d520d1..d3b7903c044 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetHomepageAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetHomepageAction.java @@ -45,7 +45,6 @@ public class SetHomepageAction implements UsersWsAction { private static final String ACTION = "set_homepage"; public static final String PARAM_TYPE = "type"; - public static final String PARAM_ORGANIZATION = "organization"; public static final String PARAM_COMPONENT = "component"; public static final String PARAM_BRANCH = "branch"; private static final String PARAMETER_REQUIRED = "Type %s requires a parameter '%s'"; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java index a4edd459512..b28a25c45b2 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java @@ -298,17 +298,10 @@ public class GroupsActionTest { assertThat(action.isInternal()).isFalse(); assertThat(action.responseExampleAsString()).isNotEmpty(); - assertThat(action.params()).extracting(Param::key).containsOnly("p", "q", "ps", "login", "selected", "organization"); + assertThat(action.params()).extracting(Param::key).containsOnly("p", "q", "ps", "login", "selected"); WebService.Param qualifiers = action.param("login"); assertThat(qualifiers.isRequired()).isTrue(); - - WebService.Param organization = action.param("organization"); - assertThat(organization.isRequired()).isFalse(); - assertThat(organization.description()).isEqualTo("Organization key"); - assertThat(organization.isInternal()).isTrue(); - assertThat(organization.exampleValue()).isEqualTo("my-org"); - assertThat(organization.since()).isEqualTo("6.4"); } private GroupDto insertGroup(String name, String description) { |