]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13936 Remove use of organizations in Groups
authorMichal Duda <michal.duda@sonarsource.com>
Fri, 9 Oct 2020 12:25:55 +0000 (14:25 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 16 Oct 2020 20:07:40 +0000 (20:07 +0000)
45 files changed:
server/sonar-db-dao/src/main/resources/org/sonar/db/user/GroupMapper.xml
server/sonar-db-dao/src/schema/schema-sq.ddl
server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DbVersion86.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroups.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullable.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest/schema.sql [new file with mode: 0644]
server/sonar-server-common/src/testFixtures/java/org/sonar/server/organization/TestDefaultOrganizationProvider.java
server/sonar-webserver-auth/src/main/java/org/sonar/server/usergroups/DefaultGroupFinder.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/usergroups/DefaultGroupFinderTest.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsRef.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsSupport.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/user/ws/groups-example.json
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/usergroups/ws/search-example.json
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/BasePermissionWsTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/GroupWsRefTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/RemoveUserActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UsersActionTest.java
sonar-ws/src/main/protobuf/ws-user_groups.proto

index 2dbdc19172d5da29a311d78d3a7eaa960746e235..75b607bff32086b9b06cf96cb06998fba49c03c3 100644 (file)
   <insert id="insert" parameterType="Group" useGeneratedKeys="false">
     insert into groups (
     uuid,
-    organization_uuid,
     name,
     description,
     created_at,
     updated_at
     ) values (
     #{uuid,jdbcType=VARCHAR},
-    'asd',
     #{name,jdbcType=VARCHAR},
     #{description,jdbcType=VARCHAR},
     #{createdAt,jdbcType=TIMESTAMP},
index 25052cb6ecc0cdc84cf4dcc7699b3c0e23f098a1..eba030939d8e6abe5293b8e9b9a49815686411bb 100644 (file)
@@ -325,14 +325,14 @@ CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID");
 CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("GROUP_UUID", "COMPONENT_UUID", "ROLE");
 
 CREATE TABLE "GROUPS"(
-    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
-    "NAME" VARCHAR(500),
+    "NAME" VARCHAR(500) NOT NULL,
     "DESCRIPTION" VARCHAR(200),
     "CREATED_AT" TIMESTAMP,
     "UPDATED_AT" TIMESTAMP,
     "UUID" VARCHAR(40) NOT NULL
 );
 ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID");
+CREATE UNIQUE INDEX "UNIQ_GROUPS_NAME" ON "GROUPS"("NAME");
 
 CREATE TABLE "GROUPS_USERS"(
     "GROUP_UUID" VARCHAR(40) NOT NULL,
index 4d1443c728a730e3bec2c1e56e887851fe98c691..97f6c71dbfb6bf15475352d5ccbd64c4f827bb14 100644 (file)
@@ -137,7 +137,7 @@ public class AuthorizationDaoTest {
     db.users().insertMember(group2, user3);
 
     // group3 has the permission "perm1" but has no users
-    GroupDto group3 = db.users().insertGroup("g2");
+    GroupDto group3 = db.users().insertGroup("g3");
     db.users().insertPermissionOnGroup(group3, "perm1");
 
     db.users().insertPermissionOnUser(user4, "perm1");
index 7ee38344a1ede6ef72b600bfabb911179dd79417..a916bf7de82b6409bc6783186df97caaa9258ff4 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Set;
 import java.util.function.Consumer;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
+import org.sonar.api.security.DefaultGroups;
 import org.sonar.api.web.UserRole;
 import org.sonar.core.util.Uuids;
 import org.sonar.core.util.stream.MoreCollectors;
@@ -40,10 +41,10 @@ import org.sonar.db.permission.UserPermissionDto;
 import org.sonar.db.project.ProjectDto;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static java.lang.String.format;
 import static java.util.Arrays.stream;
 import static org.apache.commons.lang.math.RandomUtils.nextLong;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
+import static org.sonar.db.user.GroupTesting.newGroupDto;
 
 public class UserDbTester {
   private static final Set<String> PUBLIC_PERMISSIONS = ImmutableSet.of(UserRole.USER, UserRole.CODEVIEWER); // FIXME to check with Simon
@@ -141,12 +142,12 @@ public class UserDbTester {
   // GROUPS
 
   public GroupDto insertGroup(String name) {
-    GroupDto group = GroupTesting.newGroupDto().setName(name);
+    GroupDto group = newGroupDto().setName(name);
     return insertGroup(group);
   }
 
   public GroupDto insertGroup() {
-    GroupDto group = GroupTesting.newGroupDto();
+    GroupDto group = newGroupDto();
     return insertGroup(group);
   }
 
@@ -156,25 +157,12 @@ public class UserDbTester {
     return dto;
   }
 
-  public GroupDto insertDefaultGroup(GroupDto dto) {
-    db.getDbClient().organizationDao().getDefaultGroupUuid(db.getSession(), db.getDefaultOrganization().getUuid())
-      .ifPresent(groupUuid -> {
-        throw new IllegalArgumentException(format("Organization '%s' has already a default group", db.getDefaultOrganization().getUuid()));
-      });
-    db.getDbClient().groupDao().insert(db.getSession(), dto);
-    db.getDbClient().organizationDao().setDefaultGroupUuid(db.getSession(), db.getDefaultOrganization().getUuid(), dto);
+  public GroupDto insertDefaultGroup() {
+    GroupDto dto = db.getDbClient().groupDao().insert(db.getSession(), newGroupDto().setName(DefaultGroups.USERS).setDescription("Users"));
     db.commit();
     return dto;
   }
 
-  public GroupDto insertDefaultGroup(String name) {
-    return insertDefaultGroup(GroupTesting.newGroupDto().setName(name));
-  }
-
-  public GroupDto insertDefaultGroup() {
-    return insertDefaultGroup(GroupTesting.newGroupDto());
-  }
-
   @CheckForNull
   public GroupDto selectGroupByUuid(String groupUuid) {
     return db.getDbClient().groupDao().selectByUuid(db.getSession(), groupUuid);
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTable.java
new file mode 100644 (file)
index 0000000..3742dc6
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.def.VarcharColumnDef;
+import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class AddUniqueIndexOnNameColumnOfGroupsTable extends DdlChange {
+  private static final String TABLE_NAME = "groups";
+  private static final String INDEX_NAME = "uniq_groups_name";
+
+  public AddUniqueIndexOnNameColumnOfGroupsTable(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new CreateIndexBuilder()
+      .setUnique(true)
+      .setTable(TABLE_NAME)
+      .setName(INDEX_NAME)
+      .addColumn(new VarcharColumnDef.Builder()
+        .setColumnName("name")
+        .setIgnoreOracleUnit(true)
+        .setLimit(500)
+        .setIsNullable(false)
+        .build())
+      .build());
+  }
+}
index 29ccb9dcefe7e30b4d157a7703464a74f175a76c..d759359e7507339d5200bfcdd869c3e98d423fb4 100644 (file)
@@ -38,6 +38,9 @@ public class DbVersion86 implements DbVersion {
       .add(4108, "Drop 'organization_uuid' in 'user_roles'", DropOrganizationInUserRoles.class)
       .add(4109, "Drop 'organization_uuid' in 'group_roles'", DropOrganizationInGroupRoles.class)
       .add(4110, "Drop 'organization_uuid' in 'permission_templates'", DropOrganizationInPermissionTemplates.class)
+      .add(4111, "Drop 'organization_uuid' in 'groups'", DropOrganizationInGroups.class)
+      .add(4112, "Make 'name' column in 'groups' table not nullable", MakeNameColumnInGroupsTableNotNullable.class)
+      .add(4113, "Make 'name' column in 'groups' table unique", AddUniqueIndexOnNameColumnOfGroupsTable.class)
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroups.java
new file mode 100644 (file)
index 0000000..64e479b
--- /dev/null
@@ -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 DropOrganizationInGroups extends DdlChange {
+
+  private static final String TABLE_NAME = "groups";
+
+  public DropOrganizationInGroups(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/main/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullable.java
new file mode 100644 (file)
index 0000000..b2c30fc
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.def.VarcharColumnDef;
+import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class MakeNameColumnInGroupsTableNotNullable extends DdlChange {
+  private static final String TABLE = "groups";
+
+  private static final VarcharColumnDef columnDefinition = newVarcharColumnDefBuilder()
+    .setColumnName("name")
+    .setIsNullable(false)
+    .setIgnoreOracleUnit(true)
+    .setLimit(500)
+    .build();
+
+  public MakeNameColumnInGroupsTableNotNullable(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AlterColumnsBuilder(getDialect(), TABLE)
+      .updateColumn(columnDefinition)
+      .build());
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest.java
new file mode 100644 (file)
index 0000000..7e21798
--- /dev/null
@@ -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 AddUniqueIndexOnNameColumnOfGroupsTableTest {
+
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexOnNameColumnOfGroupsTableTest.class, "schema.sql");
+
+  private final MigrationStep underTest = new AddUniqueIndexOnNameColumnOfGroupsTable(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertUniqueIndex("groups", "uniq_groups_name", "name");
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest.java
new file mode 100644 (file)
index 0000000..8568ef0
--- /dev/null
@@ -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 DropOrganizationInGroupsTest {
+
+  @Rule
+  public CoreDbTester dbTester = CoreDbTester.createForSchema(DropOrganizationInGroupsTest.class, "schema.sql");
+
+  private final MigrationStep underTest = new DropOrganizationInGroups(dbTester.database());
+
+  @Test
+  public void column_has_been_dropped() throws SQLException {
+    underTest.execute();
+    dbTester.assertColumnDoesNotExist("groups", "organization_uuid");
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest.java
new file mode 100644 (file)
index 0000000..8113ff0
--- /dev/null
@@ -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.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;
+
+import static java.sql.Types.VARCHAR;
+
+public class MakeNameColumnInGroupsTableNotNullableTest {
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(MakeNameColumnInGroupsTableNotNullableTest.class, "schema.sql");
+
+  private final MigrationStep underTest = new MakeNameColumnInGroupsTableNotNullable(db.database());
+
+  @Test
+  public void uuid_column_is_not_null() throws SQLException {
+    underTest.execute();
+
+    db.assertColumnDefinition("groups", "name", VARCHAR, 500, false);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/AddUniqueIndexOnNameColumnOfGroupsTableTest/schema.sql
new file mode 100644 (file)
index 0000000..e573be0
--- /dev/null
@@ -0,0 +1,8 @@
+CREATE TABLE "GROUPS"(
+    "NAME" VARCHAR(500) NOT NULL,
+    "DESCRIPTION" VARCHAR(200),
+    "CREATED_AT" TIMESTAMP,
+    "UPDATED_AT" TIMESTAMP,
+    "UUID" VARCHAR(40) NOT NULL
+);
+ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInGroupsTest/schema.sql
new file mode 100644 (file)
index 0000000..3f76dd2
--- /dev/null
@@ -0,0 +1,9 @@
+CREATE TABLE "GROUPS"(
+    "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+    "NAME" VARCHAR(500),
+    "DESCRIPTION" VARCHAR(200),
+    "CREATED_AT" TIMESTAMP,
+    "UPDATED_AT" TIMESTAMP,
+    "UUID" VARCHAR(40) NOT NULL
+);
+ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v86/MakeNameColumnInGroupsTableNotNullableTest/schema.sql
new file mode 100644 (file)
index 0000000..2784c04
--- /dev/null
@@ -0,0 +1,8 @@
+CREATE TABLE "GROUPS"(
+    "NAME" VARCHAR(500),
+    "DESCRIPTION" VARCHAR(200),
+    "CREATED_AT" TIMESTAMP,
+    "UPDATED_AT" TIMESTAMP,
+    "UUID" VARCHAR(40) NOT NULL
+);
+ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID");
index 4c27c0e59cd3d02e9d76537781e10a4f4fb77f2e..280d0512dbd92e6752ba9d1c6d7e6a15f995e43d 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Date;
 import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
 
+//TODO fix this
 public class TestDefaultOrganizationProvider implements DefaultOrganizationProvider {
 
   private final DefaultOrganizationProvider delegate;
index 28d41b26f2927ca66c930a16f3d0f3f4056daadd..34b7eb45ef1422e2fe7f8e05dd517aab126bb376 100644 (file)
  */
 package org.sonar.server.usergroups;
 
+import org.sonar.api.security.DefaultGroups;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.user.GroupDto;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-
-import static java.lang.String.format;
-import static java.util.Objects.requireNonNull;
 
 public class DefaultGroupFinder {
 
   private final DbClient dbClient;
-  private final DefaultOrganizationProvider defaultOrganizationProvider;
 
-  public DefaultGroupFinder(DbClient dbClient, DefaultOrganizationProvider defaultOrganizationProvider) {
+  public DefaultGroupFinder(DbClient dbClient) {
     this.dbClient = dbClient;
-    this.defaultOrganizationProvider = defaultOrganizationProvider;
   }
 
   public GroupDto findDefaultGroup(DbSession dbSession) {
-    String defaultGroupUuid = dbClient.organizationDao().getDefaultGroupUuid(dbSession, defaultOrganizationProvider.get().getUuid())
-      .orElseThrow(() -> new IllegalStateException("Default group cannot be found "));
-    return requireNonNull(dbClient.groupDao().selectByUuid(dbSession, defaultGroupUuid), format("Group '%s' cannot be found", defaultGroupUuid));
+    return dbClient.groupDao().selectByName(dbSession, DefaultGroups.USERS)
+      .orElseThrow(() -> new IllegalStateException("Default group cannot be found"));
   }
 
 }
index f36a976467acd2ee42eaa42baa9545ececd5477a..c97df1924a51bd2d1896835e5a1bd25ac619c44f 100644 (file)
@@ -98,12 +98,13 @@ public class HttpHeadersAuthenticationTest {
   private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
 
   private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
-  private UserRegistrarImpl userIdentityAuthenticator = new UserRegistrarImpl(
+
+  private final DefaultGroupFinder defaultGroupFinder = new DefaultGroupFinder(db.getDbClient());
+  private final UserRegistrarImpl userIdentityAuthenticator = new UserRegistrarImpl(
     db.getDbClient(),
-    new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), userIndexer, defaultOrganizationProvider, new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider),
-      settings.asConfig(),
+    new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), userIndexer, defaultOrganizationProvider, defaultGroupFinder, settings.asConfig(),
       localAuthentication),
-    new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider));
+    defaultGroupFinder);
 
   private HttpServletResponse response = mock(HttpServletResponse.class);
   private JwtHttpHandler jwtHttpHandler = mock(JwtHttpHandler.class);
@@ -116,7 +117,7 @@ public class HttpHeadersAuthenticationTest {
     when(system2.now()).thenReturn(NOW);
     group1 = db.users().insertGroup(GROUP1);
     group2 = db.users().insertGroup(GROUP2);
-    sonarUsers = db.users().insertDefaultGroup("sonar-users");
+    sonarUsers = db.users().insertDefaultGroup();
   }
 
   @Test
index 36dcca0e3d8b20920887beccae065005ae679ba5..f73873bc8144d491f979d52b0e75afe7cc9c6007 100644 (file)
@@ -80,7 +80,7 @@ public class UserRegistrarImplTest {
   private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
   private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
   private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
-  private DefaultGroupFinder groupFinder = new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider);
+  private final DefaultGroupFinder groupFinder = new DefaultGroupFinder(db.getDbClient());
   private UserUpdater userUpdater = new UserUpdater(
     mock(NewUserNotifier.class),
     db.getDbClient(),
@@ -698,7 +698,7 @@ public class UserRegistrarImplTest {
   }
 
   private GroupDto insertDefaultGroup() {
-    return db.users().insertDefaultGroup("sonar-users");
+    return db.users().insertDefaultGroup();
   }
 
 }
index bef3d74dad07b8efba7945c0fb385d048f86a297..897f737c37f28d3699823556208e31b0d18e1c5f 100644 (file)
@@ -81,7 +81,7 @@ public class UserUpdaterCreateTest {
   private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
 
   private UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer, defaultOrganizationProvider,
-    new DefaultGroupFinder(dbClient, defaultOrganizationProvider), settings.asConfig(), localAuthentication);
+    new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication);
 
   @Test
   public void create_user() {
@@ -454,7 +454,7 @@ public class UserUpdaterCreateTest {
       .setName("Marius")
       .setEmail("marius@mail.com")
       .setPassword("password")
-      .setScmAccounts(asList("jo"))
+      .setScmAccounts(singletonList("jo"))
       .build(), u -> {
       });
   }
@@ -487,7 +487,7 @@ public class UserUpdaterCreateTest {
       .setName("Marius2")
       .setEmail("marius2@mail.com")
       .setPassword("password2")
-      .setScmAccounts(asList(DEFAULT_LOGIN))
+      .setScmAccounts(singletonList(DEFAULT_LOGIN))
       .build(), u -> {
       });
   }
@@ -502,7 +502,7 @@ public class UserUpdaterCreateTest {
       .setName("Marius2")
       .setEmail("marius2@mail.com")
       .setPassword("password2")
-      .setScmAccounts(asList("marius2@mail.com"))
+      .setScmAccounts(singletonList("marius2@mail.com"))
       .build(), u -> {
       });
   }
@@ -559,7 +559,7 @@ public class UserUpdaterCreateTest {
   }
 
   @Test
-  public void associate_default_group_when_creating_user_and_organizations_are_disabled() {
+  public void associate_default_group_when_creating_user() {
     GroupDto defaultGroup = createDefaultGroup();
 
     underTest.createAndCommit(db.getSession(), NewUser.builder()
@@ -570,7 +570,7 @@ public class UserUpdaterCreateTest {
       .build(), u -> {
       });
 
-    Multimap<String, String> groups = dbClient.groupMembershipDao().selectGroupsByLogins(session, asList("user"));
+    Multimap<String, String> groups = dbClient.groupMembershipDao().selectGroupsByLogins(session, singletonList("user"));
     assertThat(groups.get("user")).containsOnly(defaultGroup.getName());
   }
 
index 8d37987185b502ccc3d03fcd801f7db50dd31780..f64f25069a86f92b565f6e0bef1bb7e46934d054 100644 (file)
@@ -48,7 +48,7 @@ import static org.sonar.process.ProcessProperties.Property.ONBOARDING_TUTORIAL_S
 
 public class UserUpdaterReactivateTest {
 
-  private System2 system2 = new AlwaysIncreasingSystem2();
+  private final System2 system2 = new AlwaysIncreasingSystem2();
 
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
@@ -57,15 +57,15 @@ public class UserUpdaterReactivateTest {
   @Rule
   public DbTester db = DbTester.create(system2);
 
-  private DbClient dbClient = db.getDbClient();
-  private NewUserNotifier newUserNotifier = mock(NewUserNotifier.class);
-  private DbSession session = db.getSession();
-  private UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
-  private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
-  private MapSettings settings = new MapSettings();
-  private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
-  private UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer, defaultOrganizationProvider,
-    new DefaultGroupFinder(dbClient, defaultOrganizationProvider),
+  private final DbClient dbClient = db.getDbClient();
+  private final NewUserNotifier newUserNotifier = mock(NewUserNotifier.class);
+  private final DbSession session = db.getSession();
+  private final UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
+  private final DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
+  private final MapSettings settings = new MapSettings();
+  private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+  private final UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer, defaultOrganizationProvider,
+    new DefaultGroupFinder(dbClient),
     settings.asConfig(), localAuthentication);
 
   @Test
index db2d558a8fcc6336de3176006bf74d61bef9e030..f2d9e17033bc6f54d561e8bb4d80164ad0fb8315 100644 (file)
@@ -77,7 +77,7 @@ public class UserUpdaterUpdateTest {
   private MapSettings settings = new MapSettings();
   private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
   private UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer, defaultOrganizationProvider,
-    new DefaultGroupFinder(dbClient, defaultOrganizationProvider), settings.asConfig(), localAuthentication);
+    new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication);
 
   @Test
   public void update_user() {
index fcc6ac73c8a140d0a7769264cb8ae523d7242bfc..64dd72aea43de26fea229ef5b706c49edb281c6f 100644 (file)
@@ -21,52 +21,48 @@ package org.sonar.server.usergroups;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.user.GroupDto;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
 
-import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 public class DefaultGroupFinderTest {
 
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
   @Rule
   public DbTester db = DbTester.create();
 
-  private DefaultGroupFinder underTest = new DefaultGroupFinder(db.getDbClient(), TestDefaultOrganizationProvider.from(db));
+  private final DefaultGroupFinder underTest = new DefaultGroupFinder(db.getDbClient());
 
   @Test
   public void find_default_group() {
-    GroupDto defaultGroup = db.users().insertDefaultGroup("default");
+    GroupDto defaultGroup = db.users().insertDefaultGroup();
 
     GroupDto result = underTest.findDefaultGroup(db.getSession());
 
     assertThat(result.getUuid()).isEqualTo(defaultGroup.getUuid());
-    assertThat(result.getName()).isEqualTo("default");
+    assertThat(result.getName()).isEqualTo("sonar-users");
   }
 
   @Test
   public void fail_with_ISE_when_no_default_group() {
     db.users().insertGroup();
+    DbSession session = db.getSession();
 
-    expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage(format("Default group cannot be found"));
-
-    underTest.findDefaultGroup(db.getSession());
+    assertThatThrownBy(() -> underTest.findDefaultGroup(session))
+      .isInstanceOf(IllegalStateException.class)
+      .hasMessage("Default group cannot be found");
   }
 
   @Test
-  public void fail_with_NPE_when_default_group_does_not_exist() {
-    GroupDto defaultGroup = db.users().insertDefaultGroup("default");
+  public void fail_with_ISE_when_default_group_does_not_exist() {
+    GroupDto defaultGroup = db.users().insertDefaultGroup();
     db.getDbClient().groupDao().deleteByUuid(db.getSession(), defaultGroup.getUuid());
+    DbSession session = db.getSession();
 
-    expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage(format("Group '%s' cannot be found", defaultGroup.getUuid()));
-
-    underTest.findDefaultGroup(db.getSession());
+    assertThatThrownBy(() -> underTest.findDefaultGroup(session))
+      .isInstanceOf(IllegalStateException.class)
+      .hasMessage("Default group cannot be found");
   }
 }
index 735cb6e46a46e986d76f31cbf89923adfd586b19..92839b631540abcd67dd83881f1e80e7646308d4 100644 (file)
@@ -73,7 +73,7 @@ public class PermissionWsSupport {
   public GroupUuidOrAnyone findGroup(DbSession dbSession, Request request) {
     String groupUuid = request.param(PARAM_GROUP_ID);
     String groupName = request.param(PARAM_GROUP_NAME);
-    GroupWsRef groupRef = GroupWsRef.create(groupUuid, null, groupName);
+    GroupWsRef groupRef = GroupWsRef.create(groupUuid, groupName);
     return groupWsSupport.findGroupOrAnyone(dbSession, groupRef);
   }
 
index 9010af8a6173794f5573c57d091f959f6a3c83e1..7e1500fa7664f7b1724639b798b72f21836f9289 100644 (file)
@@ -38,7 +38,6 @@ import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.server.usergroups.ws.GroupWsSupport.DESCRIPTION_MAX_LENGTH;
 import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_GROUP_DESCRIPTION;
 import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_GROUP_NAME;
-import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_ORGANIZATION_KEY;
 import static org.sonar.server.usergroups.ws.GroupWsSupport.toProtobuf;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
@@ -68,12 +67,6 @@ public class CreateAction implements UserGroupsWsAction {
       .setChangelog(
         new Change("8.4", "Field 'id' format in the response changes from integer to string."));
 
-    action.createParam(PARAM_ORGANIZATION_KEY)
-      .setDescription("Key of organization. If unset then default organization is used.")
-      .setExampleValue("my-org")
-      .setSince("6.2")
-      .setInternal(true);
-
     action.createParam(PARAM_GROUP_NAME)
       .setRequired(true)
       .setMaximumLength(GROUP_NAME_MAX_LENGTH)
@@ -111,8 +104,7 @@ public class CreateAction implements UserGroupsWsAction {
   private void writeResponse(Request request, Response response, GroupDto group) {
     UserGroups.CreateWsResponse.Builder respBuilder = UserGroups.CreateWsResponse.newBuilder();
     // 'default' is always false as it's not possible to create a default group
-    // TODO
-    respBuilder.setGroup(toProtobuf("org", group, 0, false));
+    respBuilder.setGroup(toProtobuf(group, 0, false));
     writeProtobuf(respBuilder.build(), request, response);
   }
 }
index a2f38972852e5547e087512154b003761c060661..45087fb5cc79d4f321f8168898328d4ffa61bb74 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.usergroups.ws;
 
 import java.util.Objects;
-import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 import org.sonar.api.security.DefaultGroups;
@@ -36,7 +35,7 @@ import static org.sonar.server.exceptions.BadRequestException.checkRequest;
  * of these two options:
  * <ul>
  *   <li>group uuid, for instance 1234</li>
- *   <li>group name and optional organization key</li>
+ *   <li>group name</li>
  * </ul>
  *
  * The reference is then converted to a {@link GroupUuid} or {@link GroupUuidOrAnyone}.
@@ -45,19 +44,16 @@ import static org.sonar.server.exceptions.BadRequestException.checkRequest;
 public class GroupWsRef {
 
   private final String uuid;
-  private final String organizationKey;
   private final String name;
 
-  private GroupWsRef(String uuid, @Nullable String organizationKey, @Nullable String name) {
+  private GroupWsRef(@Nullable String uuid, @Nullable String name) {
     this.uuid = uuid;
-    this.organizationKey = organizationKey;
     this.name = name;
   }
 
   /**
    * @return {@code true} if uuid is defined and {@link #getUuid()} can be called. If {@code false}, then
-   *   the couple {organizationKey, name} is defined and the methods {@link #getOrganizationKey()}/{@link #getName()}
-   *   can be called.
+   *   the name is defined and the method {@link #getName()} can be called.
    */
   public boolean hasUuid() {
     return uuid != null;
@@ -65,23 +61,13 @@ public class GroupWsRef {
 
   /**
    * @return the group uuid
-   * @throws IllegalStateException if {@link #getUuid()} is {@code false}
+   * @throws IllegalStateException if {@link #hasUuid()} is {@code false}
    */
   public String getUuid() {
     checkState(hasUuid(), "Id is not present. Please see hasUuid().");
     return uuid;
   }
 
-  /**
-   * @return the organization key
-   * @throws IllegalStateException if {@link #getUuid()} is {@code true}
-   */
-  @CheckForNull
-  public String getOrganizationKey() {
-    checkState(!hasUuid(), "Organization is not present. Please see hasId().");
-    return organizationKey;
-  }
-
   /**
    * @return the non-null group name. Can be anyone.
    * @throws IllegalStateException if {@link #getUuid()} is {@code true}
@@ -96,28 +82,27 @@ public class GroupWsRef {
    * as they can't be referenced by an uuid.
    */
   static GroupWsRef fromUuid(String uuid) {
-    return new GroupWsRef(uuid, null, null);
+    return new GroupWsRef(uuid, null);
   }
 
   /**
-   * Creates a reference to a group by its organization and name. Virtual groups "Anyone" are
+   * Creates a reference to a group by its name. Virtual groups "Anyone" are
    * supported.
    *
-   * @param organizationKey key of organization. If {@code null}, then default organization will be used.
    * @param name non-null name. Can refer to anyone group (case-insensitive {@code "anyone"}).
    */
-  static GroupWsRef fromName(@Nullable String organizationKey, String name) {
-    return new GroupWsRef(null, organizationKey, requireNonNull(name));
+  static GroupWsRef fromName(String name) {
+    return new GroupWsRef(null, requireNonNull(name));
   }
 
-  public static GroupWsRef create(@Nullable String uuid, @Nullable String organizationKey, @Nullable String name) {
+  public static GroupWsRef create(@Nullable String uuid, @Nullable String name) {
     if (uuid != null) {
-      checkRequest(organizationKey == null && name == null, "Either group id or couple organization/group name must be set");
+      checkRequest(name == null, "Either group id or group name must be set");
       return fromUuid(uuid);
     }
 
     checkRequest(name != null, "Group name or group id must be provided");
-    return fromName(organizationKey, name);
+    return fromName(name);
   }
 
   public boolean isAnyone() {
@@ -133,21 +118,16 @@ public class GroupWsRef {
       return false;
     }
     GroupWsRef that = (GroupWsRef) o;
-    return Objects.equals(uuid, that.uuid) && Objects.equals(organizationKey, that.organizationKey) && Objects.equals(name, that.name);
+    return Objects.equals(uuid, that.uuid) && Objects.equals(name, that.name);
   }
 
   @Override
   public int hashCode() {
-    return Objects.hash(uuid, organizationKey, name);
+    return Objects.hash(uuid, name);
   }
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("GroupWsRef{");
-    sb.append("uuid=").append(uuid);
-    sb.append(", organizationKey='").append(organizationKey).append('\'');
-    sb.append(", name='").append(name).append('\'');
-    sb.append('}');
-    return sb.toString();
+    return "GroupWsRef{uuid=" + uuid + ", name='" + name + "'}";
   }
 }
index d4d4c38833b9369d6349f4490f8730a600a4cb3a..354f49a7aa6d922885d32ce1f7071e8228c6fa7a 100644 (file)
@@ -44,7 +44,6 @@ import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOption
 public class GroupWsSupport {
 
   static final String PARAM_GROUP_ID = "id";
-  static final String PARAM_ORGANIZATION_KEY = "organization";
   static final String PARAM_GROUP_NAME = "name";
   static final String PARAM_GROUP_DESCRIPTION = "description";
   static final String PARAM_LOGIN = "login";
@@ -63,8 +62,7 @@ public class GroupWsSupport {
   }
 
   /**
-   * Find a group by its id (parameter {@link #PARAM_GROUP_ID}) or couple organization key/group name
-   * (parameters {@link #PARAM_ORGANIZATION_KEY} and {@link #PARAM_GROUP_NAME}). The virtual
+   * Find a group by its id (parameter {@link #PARAM_GROUP_ID}) or group name (parameter {@link #PARAM_GROUP_NAME}). The virtual
    * group "Anyone" is not supported.
    *
    * @throws NotFoundException if parameters are missing/incorrect, if the requested group does not exist
@@ -76,9 +74,8 @@ public class GroupWsSupport {
 
   public GroupDto findGroupDto(DbSession dbSession, Request request) {
     String uuid = request.param(PARAM_GROUP_ID);
-    String organizationKey = request.param(PARAM_ORGANIZATION_KEY);
     String name = request.param(PARAM_GROUP_NAME);
-    return findGroupDto(dbSession, GroupWsRef.create(uuid, organizationKey, name));
+    return findGroupDto(dbSession, GroupWsRef.create(uuid, name));
   }
 
   public GroupDto findGroupDto(DbSession dbSession, GroupWsRef ref) {
@@ -121,10 +118,9 @@ public class GroupWsSupport {
     checkArgument(!defaultGroup.getUuid().equals(groupDto.getUuid()), "Default group '%s' cannot be used to perform this action", groupDto.getName());
   }
 
-  static UserGroups.Group.Builder toProtobuf(String org, GroupDto group, int membersCount, boolean isDefault) {
+  static UserGroups.Group.Builder toProtobuf(GroupDto group, int membersCount, boolean isDefault) {
     UserGroups.Group.Builder wsGroup = UserGroups.Group.newBuilder()
       .setId(group.getUuid())
-      .setOrganization(org)
       .setName(group.getName())
       .setMembersCount(membersCount)
       .setDefault(isDefault);
@@ -145,11 +141,6 @@ public class GroupWsSupport {
   }
 
   private static void defineGroupNameWsParameter(WebService.NewAction action) {
-    action.createParam(PARAM_ORGANIZATION_KEY)
-      .setDescription("Key of organization")
-      .setExampleValue("my-org")
-      .setInternal(true)
-      .setSince("6.2");
     action.createParam(PARAM_GROUP_NAME)
       .setDescription("Group name")
       .setExampleValue("sonar-administrators");
index 8c909605d263f4591c13b7d02b20167cac72887e..45aed86a62059c7f76989b2be6dc399bef40999c 100644 (file)
@@ -27,7 +27,6 @@ import java.util.Set;
 import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
 import org.sonar.api.server.ws.WebService.NewController;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.Paging;
@@ -44,7 +43,6 @@ import static org.apache.commons.lang.StringUtils.defaultIfBlank;
 import static org.sonar.api.utils.Paging.forPageIndex;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.server.es.SearchOptions.MAX_PAGE_SIZE;
-import static org.sonar.server.usergroups.ws.GroupWsSupport.PARAM_ORGANIZATION_KEY;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 import static org.sonarqube.ws.UserGroups.Group;
 import static org.sonarqube.ws.UserGroups.SearchWsResponse;
@@ -68,7 +66,7 @@ public class SearchAction implements UserGroupsWsAction {
 
   @Override
   public void define(NewController context) {
-    WebService.NewAction action = context.createAction("search")
+    context.createAction("search")
       .setDescription("Search for user groups.<br>" +
         "Requires the following permission: 'Administer System'.")
       .setHandler(this)
@@ -81,12 +79,6 @@ public class SearchAction implements UserGroupsWsAction {
         new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
         new Change("6.4", "Paging response fields moved to a Paging object"),
         new Change("6.4", "'default' response field has been added"));
-
-    action.createParam(PARAM_ORGANIZATION_KEY)
-      .setDescription("Key of organization. If not set then groups are searched in default organization.")
-      .setExampleValue("my-org")
-      .setSince("6.2")
-      .setInternal(true);
   }
 
   @Override
index 8e68133b08623a859deed8189bcbd0576075edcb..03f2f5b7c067f4d17a80686a82d49381dd0d68a3 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.user.GroupDto;
 import org.sonar.db.user.UserMembershipQuery;
-import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.UserGroups;
 
@@ -51,13 +50,11 @@ public class UpdateAction implements UserGroupsWsAction {
   private final DbClient dbClient;
   private final UserSession userSession;
   private final GroupWsSupport support;
-  private final DefaultOrganizationProvider defaultOrganizationProvider;
 
-  public UpdateAction(DbClient dbClient, UserSession userSession, GroupWsSupport support, DefaultOrganizationProvider defaultOrganizationProvider) {
+  public UpdateAction(DbClient dbClient, UserSession userSession, GroupWsSupport support) {
     this.dbClient = dbClient;
     this.userSession = userSession;
     this.support = support;
-    this.defaultOrganizationProvider = defaultOrganizationProvider;
   }
 
   @Override
@@ -152,7 +149,7 @@ public class UpdateAction implements UserGroupsWsAction {
 
     UserGroups.UpdateWsResponse.Builder respBuilder = UserGroups.UpdateWsResponse.newBuilder();
     // 'default' is always false as it's not possible to update a default group
-    respBuilder.setGroup(toProtobuf(defaultOrganizationProvider.get().getKey(), group, membersCount, false));
+    respBuilder.setGroup(toProtobuf(group, membersCount, false));
     writeProtobuf(respBuilder.build(), request, response);
   }
 
index fcf4d68e287767b9a3e6a6faa5191271c17f40b1..de381b2b323aee66c1381c53c2ac865ec2d28f36 100644 (file)
@@ -15,7 +15,7 @@
     {
       "id": 2,
       "name": "sonar-users",
-      "description": "Sonar Users",
+      "description": "Users",
       "selected": true,
       "default": true
     }
index f165d2a76ee6cb920a32a9e792a44f87f3ea7266..6cf71371022047e28029993fae30f48116e92509 100644 (file)
@@ -7,7 +7,7 @@
   "groups": [
     {
       "id": "AU-Tpxb--iU5OvuD2FLy",
-      "name": "users",
+      "name": "sonar-users",
       "description": "Users",
       "membersCount": 17,
       "default": true
index 588fab45048b673ead0d9086604c56e2f338082f..82d22c0dbb84e30f9df1dddf72a0208bfda108c1 100644 (file)
@@ -70,7 +70,7 @@ public abstract class BasePermissionWsTest<A extends PermissionsWsAction> {
   protected abstract A buildWsAction();
 
   protected GroupWsSupport newGroupWsSupport() {
-    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider));
+    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient()));
   }
 
   protected PermissionWsSupport newPermissionWsSupport() {
index 493173dc94d6bf187e56d02b20bcd67fbffc6907..f92d0a53aeb8979b18ba186ad0e13ca7803969cb 100644 (file)
@@ -80,7 +80,7 @@ public class DeleteTemplateActionTest {
   @Before
   public void setUp() {
     DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
-    GroupWsSupport groupWsSupport = new GroupWsSupport(dbClient, new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider));
+    GroupWsSupport groupWsSupport = new GroupWsSupport(dbClient, new DefaultGroupFinder(db.getDbClient()));
     this.underTestWithoutViews = new WsActionTester(new DeleteTemplateAction(dbClient, userSession,
       new PermissionWsSupport(dbClient, new ComponentFinder(dbClient, resourceTypes), groupWsSupport), defaultTemplatesResolver, defaultOrganizationProvider));
     this.underTestWithViews = new WsActionTester(new DeleteTemplateAction(dbClient, userSession,
index d6defca65ab52ef2f29d3741955368db5be90d64..9c4b1ef0cea133a408f80f44ee8c15ac78c8b6a4 100644 (file)
@@ -50,8 +50,6 @@ import static org.sonar.db.user.UserTesting.newLocalUser;
 
 public class ChangePasswordActionTest {
 
-  private System2 system2 = new AlwaysIncreasingSystem2();
-
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
   @Rule
@@ -67,7 +65,7 @@ public class ChangePasswordActionTest {
 
   private UserUpdater userUpdater = new UserUpdater(
     mock(NewUserNotifier.class), db.getDbClient(), new UserIndexer(db.getDbClient(), es.client()), testDefaultOrganizationProvider,
-    new DefaultGroupFinder(db.getDbClient(), testDefaultOrganizationProvider),
+    new DefaultGroupFinder(db.getDbClient()),
     new MapSettings().asConfig(),
     localAuthentication);
 
@@ -75,7 +73,7 @@ public class ChangePasswordActionTest {
 
   @Before
   public void setUp() {
-    db.users().insertDefaultGroup("sonar-users");
+    db.users().insertDefaultGroup();
   }
 
   @Test
index 31ab548314bbbf21419e891bdf4fd5efa989e9a4..3d5a67462aaf29d22f7999f9e2d339ad8c56a5b5 100644 (file)
@@ -65,7 +65,6 @@ import static org.sonar.server.user.index.UserIndexDefinition.FIELD_SCM_ACCOUNTS
 
 public class CreateActionTest {
 
-  private static final String DEFAULT_GROUP_NAME = "sonar-users";
   private MapSettings settings = new MapSettings();
   private System2 system2 = new AlwaysIncreasingSystem2();
 
@@ -85,12 +84,12 @@ public class CreateActionTest {
   private WsActionTester tester = new WsActionTester(new CreateAction(
     db.getDbClient(),
     new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), userIndexer, defaultOrganizationProvider,
-      new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider), settings.asConfig(), localAuthentication),
+      new DefaultGroupFinder(db.getDbClient()), settings.asConfig(), localAuthentication),
     userSessionRule));
 
   @Before
   public void setUp() {
-    defaultGroup = db.users().insertDefaultGroup(DEFAULT_GROUP_NAME);
+    defaultGroup = db.users().insertDefaultGroup();
   }
 
   @Test
index b28a25c45b251621f30fe6b16e801ffd672f7a18..2e57bb8697d525a0817ecd290e10acede685b7c4 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.db.user.GroupDto;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.DefaultGroupFinder;
 import org.sonar.server.ws.TestRequest;
@@ -62,12 +61,12 @@ public class GroupsActionTest {
   public UserSessionRule userSession = UserSessionRule.standalone().logIn().setRoot();
 
   private WsActionTester ws = new WsActionTester(new GroupsAction(db.getDbClient(), userSession,
-    new DefaultGroupFinder(db.getDbClient(), TestDefaultOrganizationProvider.from(db))));
+    new DefaultGroupFinder(db.getDbClient())));
 
   @Test
   public void empty_groups() {
     insertUser();
-    insertDefaultGroup("sonar-users", "Sonar Users");
+    insertDefaultGroup();
 
     GroupsWsResponse response = call(ws.newRequest().setParam("login", USER_LOGIN));
 
@@ -77,7 +76,7 @@ public class GroupsActionTest {
   @Test
   public void return_selected_groups_selected_param_is_set_to_all() {
     UserDto user = insertUser();
-    GroupDto usersGroup = insertDefaultGroup("sonar-users", "Sonar Users");
+    GroupDto usersGroup = insertDefaultGroup();
     GroupDto adminGroup = insertGroup("sonar-admins", "Sonar Admins");
     addUserToGroup(user, usersGroup);
 
@@ -93,7 +92,7 @@ public class GroupsActionTest {
   @Test
   public void return_selected_groups_selected_param_is_set_to_selected() {
     UserDto user = insertUser();
-    GroupDto usersGroup = insertDefaultGroup("sonar-users", "Sonar Users");
+    GroupDto usersGroup = insertDefaultGroup();
     insertGroup("sonar-admins", "Sonar Admins");
     addUserToGroup(user, usersGroup);
 
@@ -107,7 +106,7 @@ public class GroupsActionTest {
   @Test
   public void return_selected_groups_selected_param_is_not_set() {
     UserDto user = insertUser();
-    GroupDto usersGroup = insertDefaultGroup("sonar-users", "Sonar Users");
+    GroupDto usersGroup = insertDefaultGroup();
     insertGroup("sonar-admins", "Sonar Admins");
     addUserToGroup(user, usersGroup);
 
@@ -121,7 +120,7 @@ public class GroupsActionTest {
   @Test
   public void return_not_selected_groups_selected_param_is_set_to_deselected() {
     UserDto user = insertUser();
-    GroupDto usersGroup = insertDefaultGroup("sonar-users", "Sonar Users");
+    GroupDto usersGroup = insertDefaultGroup();
     GroupDto adminGroup = insertGroup("sonar-admins", "Sonar Admins");
     addUserToGroup(user, usersGroup);
 
@@ -132,21 +131,10 @@ public class GroupsActionTest {
       .containsOnly(tuple(adminGroup.getUuid(), adminGroup.getName(), adminGroup.getDescription(), false));
   }
 
-  @Test
-  public void return_group_not_having_description() {
-    UserDto user = insertUser();
-    GroupDto group = insertDefaultGroup("sonar-users", null);
-    addUserToGroup(user, group);
-
-    GroupsWsResponse response = call(ws.newRequest().setParam("login", "john").setParam(Param.SELECTED, ALL.value()));
-
-    assertThat(response.getGroupsList()).extracting(GroupsWsResponse.Group::hasDescription).containsOnly(false);
-  }
-
   @Test
   public void search_with_pagination() {
     UserDto user = insertUser();
-    insertDefaultGroup("sonar-users", "Sonar Users");
+    insertDefaultGroup();
     for (int i = 1; i <= 9; i++) {
       GroupDto groupDto = insertGroup("group-" + i, "group-" + i);
       addUserToGroup(user, groupDto);
@@ -166,7 +154,7 @@ public class GroupsActionTest {
   @Test
   public void search_by_text_query() {
     UserDto user = insertUser();
-    GroupDto usersGroup = insertDefaultGroup("sonar-users", "Sonar Users");
+    GroupDto usersGroup = insertDefaultGroup();
     GroupDto adminGroup = insertGroup("sonar-admins", "Sonar Admins");
     addUserToGroup(user, usersGroup);
 
@@ -179,7 +167,7 @@ public class GroupsActionTest {
   @Test
   public void return_default_group_information() {
     UserDto user = insertUser();
-    GroupDto usersGroup = insertDefaultGroup("sonar-users", "Sonar Users");
+    GroupDto usersGroup = insertDefaultGroup();
     GroupDto adminGroup = insertGroup("sonar-admins", "Sonar Admins");
     addUserToGroup(user, usersGroup);
 
@@ -195,7 +183,7 @@ public class GroupsActionTest {
   @Test
   public void return_groups() {
     UserDto user = insertUser();
-    GroupDto group = db.users().insertDefaultGroup(newGroupDto().setName("group1"));
+    GroupDto group = db.users().insertDefaultGroup();
     addUserToGroup(user, group);
 
     GroupsWsResponse response = call(ws.newRequest()
@@ -222,7 +210,7 @@ public class GroupsActionTest {
 
   @Test
   public void fail_on_unknown_user() {
-    insertDefaultGroup("sonar-users", "Sonar Users");
+    insertDefaultGroup();
 
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Unknown user: john");
@@ -233,7 +221,7 @@ public class GroupsActionTest {
   @Test
   public void fail_on_disabled_user() {
     UserDto userDto = db.users().insertUser(user -> user.setLogin("disabled").setActive(false));
-    insertDefaultGroup("sonar-users", "Sonar Users");
+    insertDefaultGroup();
 
     expectedException.expect(NotFoundException.class);
     expectedException.expectMessage("Unknown user: disabled");
@@ -244,7 +232,7 @@ public class GroupsActionTest {
   @Test
   public void fail_when_page_size_is_greater_than_500() {
     UserDto user = insertUser();
-    insertDefaultGroup("sonar-users", "Sonar Users");
+    insertDefaultGroup();
 
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("The 'ps' parameter must be less than 500");
@@ -275,7 +263,7 @@ public class GroupsActionTest {
   @Test
   public void test_json_example() {
     UserDto user = insertUser();
-    GroupDto usersGroup = insertDefaultGroup("sonar-users", "Sonar Users");
+    GroupDto usersGroup = insertDefaultGroup();
     insertGroup("sonar-admins", "Sonar Admins");
     addUserToGroup(user, usersGroup);
 
@@ -308,8 +296,8 @@ public class GroupsActionTest {
     return db.users().insertGroup(newGroupDto().setName(name).setDescription(description));
   }
 
-  private GroupDto insertDefaultGroup(String name, String description) {
-    return db.users().insertDefaultGroup(newGroupDto().setName(name).setDescription(description));
+  private GroupDto insertDefaultGroup() {
+    return db.users().insertDefaultGroup();
   }
 
   private void addUserToGroup(UserDto user, GroupDto usersGroup) {
index 541a6743ec02dfd944e89abc4ab128603047842c..7578d98ce920067dc08772155672ea0ee9822927 100644 (file)
@@ -72,12 +72,12 @@ public class UpdateActionTest {
 
   private WsActionTester ws = new WsActionTester(new UpdateAction(
     new UserUpdater(mock(NewUserNotifier.class), dbClient, userIndexer, defaultOrganizationProvider,
-      new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider), settings.asConfig(), localAuthentication),
+      new DefaultGroupFinder(db.getDbClient()), settings.asConfig(), localAuthentication),
     userSession, new UserJsonWriter(userSession), dbClient));
 
   @Before
   public void setUp() {
-    db.users().insertDefaultGroup("sonar-users");
+    db.users().insertDefaultGroup();
   }
 
   @Test
index 532495e2373878545ecad1ae4ad0e940d5b5a3d4..8d3537441a567c98c803daedc50db4d003782bd3 100644 (file)
@@ -30,7 +30,6 @@ import org.sonar.db.user.GroupDto;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.DefaultGroupFinder;
 import org.sonar.server.ws.TestRequest;
@@ -53,16 +52,15 @@ public class AddUserActionTest {
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
 
-  private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
-  private WsActionTester ws = new WsActionTester(new AddUserAction(db.getDbClient(), userSession, newGroupWsSupport()));
+  private final WsActionTester ws = new WsActionTester(new AddUserAction(db.getDbClient(), userSession, newGroupWsSupport()));
 
   @Test
   public void verify_definition() {
     Action wsDef = ws.getDef();
 
-    assertThat(wsDef.isInternal()).isEqualTo(false);
+    assertThat(wsDef.isInternal()).isFalse();
     assertThat(wsDef.since()).isEqualTo("5.2");
-    assertThat(wsDef.isPost()).isEqualTo(true);
+    assertThat(wsDef.isPost()).isTrue();
     assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
       tuple("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
   }
@@ -205,11 +203,11 @@ public class AddUserActionTest {
   @Test
   public void fail_to_add_user_to_default_group() {
     UserDto user = db.users().insertUser();
-    GroupDto defaultGroup = db.users().insertDefaultGroup("default");
+    GroupDto defaultGroup = db.users().insertDefaultGroup();
     loginAsAdmin();
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
+    expectedException.expectMessage("Default group 'sonar-users' cannot be used to perform this action");
 
     newRequest()
       .setParam("id", defaultGroup.getUuid())
@@ -252,7 +250,7 @@ public class AddUserActionTest {
   }
 
   private GroupWsSupport newGroupWsSupport() {
-    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider));
+    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient()));
   }
 
 }
index 4b3237ab7a5fb210a0ab74034d02e81745277249..4f04c9c7b73bf153abe893ddfdc4427dbf76b3f2 100644 (file)
@@ -31,8 +31,6 @@ import org.sonar.db.DbTester;
 import org.sonar.db.user.GroupDto;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.ServerException;
-import org.sonar.server.organization.DefaultOrganization;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.DefaultGroupFinder;
 import org.sonar.server.ws.WsActionTester;
@@ -49,9 +47,8 @@ public class CreateActionTest {
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
 
-  private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
-  private CreateAction underTest = new CreateAction(db.getDbClient(), userSession, newGroupWsSupport(), new SequenceUuidFactory());
-  private WsActionTester tester = new WsActionTester(underTest);
+  private final CreateAction underTest = new CreateAction(db.getDbClient(), userSession, newGroupWsSupport(), new SequenceUuidFactory());
+  private final WsActionTester tester = new WsActionTester(underTest);
 
   @Test
   public void define_create_action() {
@@ -60,7 +57,7 @@ public class CreateActionTest {
     assertThat(action.key()).isEqualTo("create");
     assertThat(action.isPost()).isTrue();
     assertThat(action.responseExampleAsString()).isNotEmpty();
-    assertThat(action.params()).hasSize(3);
+    assertThat(action.params()).hasSize(2);
     assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
       tuple("8.4", "Field 'id' format in the response changes from integer to string."));
   }
@@ -165,10 +162,6 @@ public class CreateActionTest {
   }
 
   private GroupWsSupport newGroupWsSupport() {
-    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider));
-  }
-
-  private DefaultOrganization getDefaultOrganization() {
-    return defaultOrganizationProvider.get();
+    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient()));
   }
 }
index 360ebffa3aba1c6076039765e6e8263b8daa0b04..4babb8540283c64b49e1e319a45c7001617ede75 100644 (file)
@@ -36,7 +36,6 @@ import org.sonar.db.qualityprofile.QProfileDto;
 import org.sonar.db.user.GroupDto;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.DefaultGroupFinder;
 import org.sonar.server.ws.TestRequest;
@@ -59,17 +58,16 @@ public class DeleteActionTest {
   @Rule
   public DbTester db = DbTester.create(new AlwaysIncreasingSystem2());
 
-  private ComponentDbTester componentTester = new ComponentDbTester(db);
-  private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
-  private WsActionTester ws = new WsActionTester(new DeleteAction(db.getDbClient(), userSession, newGroupWsSupport()));
+  private final ComponentDbTester componentTester = new ComponentDbTester(db);
+  private final WsActionTester ws = new WsActionTester(new DeleteAction(db.getDbClient(), userSession, newGroupWsSupport()));
 
   @Test
   public void verify_definition() {
     Action wsDef = ws.getDef();
 
-    assertThat(wsDef.isInternal()).isEqualTo(false);
+    assertThat(wsDef.isInternal()).isFalse();
     assertThat(wsDef.since()).isEqualTo("5.2");
-    assertThat(wsDef.isPost()).isEqualTo(true);
+    assertThat(wsDef.isPost()).isTrue();
     assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
       tuple("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
   }
@@ -129,7 +127,7 @@ public class DeleteActionTest {
       .setParam("id", group.getUuid())
       .execute();
 
-    assertThat(db.countRowsOfTable("groups_users")).isEqualTo(0);
+    assertThat(db.countRowsOfTable("groups_users")).isZero();
   }
 
   @Test
@@ -145,7 +143,7 @@ public class DeleteActionTest {
       .setParam("id", group.getUuid())
       .execute();
 
-    assertThat(db.countRowsOfTable("group_roles")).isEqualTo(0);
+    assertThat(db.countRowsOfTable("group_roles")).isZero();
   }
 
   @Test
@@ -164,7 +162,7 @@ public class DeleteActionTest {
       .setParam("id", group.getUuid())
       .execute();
 
-    assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(0);
+    assertThat(db.countRowsOfTable("perm_templates_groups")).isZero();
   }
 
   @Test
@@ -200,10 +198,10 @@ public class DeleteActionTest {
   @Test
   public void fail_to_delete_default_group() {
     loginAsAdmin();
-    GroupDto defaultGroup = db.users().insertDefaultGroup("default");
+    GroupDto defaultGroup = db.users().insertDefaultGroup();
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
+    expectedException.expectMessage("Default group 'sonar-users' cannot be used to perform this action");
 
     newRequest()
       .setParam("id", defaultGroup.getUuid())
@@ -246,7 +244,7 @@ public class DeleteActionTest {
     db.users().insertDefaultGroup();
     GroupDto adminGroup1 = db.users().insertGroup("admins");
     db.users().insertPermissionOnGroup(adminGroup1, SYSTEM_ADMIN);
-    GroupDto adminGroup2 = db.users().insertGroup("admins");
+    GroupDto adminGroup2 = db.users().insertGroup("admins2");
     db.users().insertPermissionOnGroup(adminGroup2, SYSTEM_ADMIN);
     UserDto bigBoss = db.users().insertUser();
     db.users().insertMember(adminGroup2, bigBoss);
@@ -262,12 +260,12 @@ public class DeleteActionTest {
       .setParam(PARAM_GROUP_ID, adminGroup1.getUuid())
       .execute();
   }
-  
+
   private void addAdmin() {
     UserDto admin = db.users().insertUser();
     db.users().insertPermissionOnUser(admin, SYSTEM_ADMIN);
   }
-  
+
   private void loginAsAdmin() {
     userSession.logIn().addPermission(ADMINISTER);
   }
@@ -281,7 +279,7 @@ public class DeleteActionTest {
   }
 
   private GroupWsSupport newGroupWsSupport() {
-    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider));
+    return new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient()));
   }
 
 }
index 86c9d2ad9045695e7d8b18865a9b1ce1f9d682df..b24f265a96adfa945380729e038b39dcbbb60151 100644 (file)
@@ -41,9 +41,8 @@ public class GroupWsRefTest {
 
   @Test
   public void test_ref_by_name() {
-    GroupWsRef ref = fromName("ORG1", "the-group");
+    GroupWsRef ref = fromName("the-group");
     assertThat(ref.hasUuid()).isFalse();
-    assertThat(ref.getOrganizationKey()).isEqualTo("ORG1");
     assertThat(ref.getName()).isEqualTo("the-group");
     assertThat(ref.isAnyone()).isFalse();
   }
@@ -52,37 +51,37 @@ public class GroupWsRefTest {
   public void test_equals_and_hashCode() {
     GroupWsRef refId1 = GroupWsRef.fromUuid("10");
     GroupWsRef refId2 = GroupWsRef.fromUuid("11");
-    assertThat(refId1.equals(refId1)).isTrue();
-    assertThat(refId1.equals(GroupWsRef.fromUuid("10"))).isTrue();
-    assertThat(refId1.hashCode()).isEqualTo(GroupWsRef.fromUuid("10").hashCode());
-    assertThat(refId1.equals(refId2)).isFalse();
+    assertThat(refId1)
+      .isEqualTo(refId1)
+      .isEqualTo(GroupWsRef.fromUuid("10"))
+      .hasSameHashCodeAs(GroupWsRef.fromUuid("10"))
+      .isNotEqualTo(refId2);
 
-    GroupWsRef refName1 = fromName("ORG1", "the-group");
-    GroupWsRef refName2 = fromName("ORG1", "the-group2");
-    GroupWsRef refName3 = fromName("ORG2", "the-group2");
-    assertThat(refName1.equals(refName1)).isTrue();
-    assertThat(refName1.equals(fromName("ORG1", "the-group"))).isTrue();
-    assertThat(refName1.hashCode()).isEqualTo(fromName("ORG1", "the-group").hashCode());
-    assertThat(refName1.equals(refName2)).isFalse();
-    assertThat(refName2.equals(refName3)).isFalse();
+    GroupWsRef refName1 = fromName("the-group");
+    GroupWsRef refName2 = fromName("the-group2");
+    GroupWsRef refName3 = fromName("the-group2");
+    assertThat(refName1)
+      .isEqualTo(refName1)
+      .isEqualTo(fromName("the-group"))
+      .hasSameHashCodeAs(fromName("the-group"))
+      .isNotEqualTo(refName2);
+    assertThat(refName2).isEqualTo(refName3);
   }
 
   @Test
   public void test_toString() {
     GroupWsRef refId = GroupWsRef.fromUuid("10");
-    assertThat(refId.toString()).isEqualTo("GroupWsRef{uuid=10, organizationKey='null', name='null'}");
+    assertThat(refId).hasToString("GroupWsRef{uuid=10, name='null'}");
   }
 
   @Test
   public void reference_anyone_by_its_name() {
-    GroupWsRef ref = GroupWsRef.fromName("my-org", "Anyone");
-    assertThat(ref.getOrganizationKey()).isEqualTo("my-org");
+    GroupWsRef ref = GroupWsRef.fromName("Anyone");
     assertThat(ref.getName()).isEqualTo("Anyone");
     assertThat(ref.isAnyone()).isTrue();
 
     // case-insensitive
-    ref = GroupWsRef.fromName("my-org", "anyone");
-    assertThat(ref.getOrganizationKey()).isEqualTo("my-org");
+    ref = GroupWsRef.fromName("anyone");
     assertThat(ref.getName()).isEqualTo("anyone");
     assertThat(ref.isAnyone()).isTrue();
   }
index bf2efd3c1295c2a93f55d07366a4666ae783b7c3..7a74834f76d72cdc8fa7b8dc626b678df6e04ab8 100644 (file)
@@ -32,7 +32,6 @@ import org.sonar.db.user.UserDto;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.DefaultGroupFinder;
 import org.sonar.server.ws.TestRequest;
@@ -55,16 +54,16 @@ public class RemoveUserActionTest {
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
 
-  private WsActionTester ws = new WsActionTester(
-    new RemoveUserAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient(), TestDefaultOrganizationProvider.from(db)))));
+  private final WsActionTester ws = new WsActionTester(
+    new RemoveUserAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient()))));
 
   @Test
   public void verify_definition() {
     Action wsDef = ws.getDef();
 
-    assertThat(wsDef.isInternal()).isEqualTo(false);
+    assertThat(wsDef.isInternal()).isFalse();
     assertThat(wsDef.since()).isEqualTo("5.2");
-    assertThat(wsDef.isPost()).isEqualTo(true);
+    assertThat(wsDef.isPost()).isTrue();
     assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
       tuple("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
   }
@@ -225,12 +224,12 @@ public class RemoveUserActionTest {
   @Test
   public void fail_to_remove_user_from_default_group() {
     UserDto user = db.users().insertUser();
-    GroupDto defaultGroup = db.users().insertDefaultGroup("default");
+    GroupDto defaultGroup = db.users().insertDefaultGroup();
     db.users().insertMember(defaultGroup, user);
     loginAsAdmin();
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
+    expectedException.expectMessage("Default group 'sonar-users' cannot be used to perform this action");
 
     newRequest()
       .setParam("id", defaultGroup.getUuid())
index 79ee101b5d2f3fadcd095d3de3c3fa4d967de382..74754a72cc3d532a850c6f01414528a4eea86879 100644 (file)
@@ -62,8 +62,8 @@ public class SearchActionTest {
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
 
-  private WsActionTester ws = new WsActionTester(new SearchAction(db.getDbClient(), userSession,
-    new DefaultGroupFinder(db.getDbClient(), TestDefaultOrganizationProvider.from(db))));
+  private final WsActionTester ws = new WsActionTester(new SearchAction(db.getDbClient(), userSession,
+    new DefaultGroupFinder(db.getDbClient())));
 
   @Test
   public void define_search_action() {
@@ -71,7 +71,7 @@ public class SearchActionTest {
     assertThat(action).isNotNull();
     assertThat(action.key()).isEqualTo("search");
     assertThat(action.responseExampleAsString()).isNotEmpty();
-    assertThat(action.params()).hasSize(5);
+    assertThat(action.params()).hasSize(4);
     assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
       tuple("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
       tuple("6.4", "Paging response fields moved to a Paging object"),
@@ -80,11 +80,11 @@ public class SearchActionTest {
 
   @Test
   public void search_without_parameters() {
-    insertDefaultGroup(db.getDefaultOrganization(), "users", 0);
-    insertGroup(db.getDefaultOrganization(), "admins", 0);
-    insertGroup(db.getDefaultOrganization(), "customer1", 0);
-    insertGroup(db.getDefaultOrganization(), "customer2", 0);
-    insertGroup(db.getDefaultOrganization(), "customer3", 0);
+    insertDefaultGroup(0);
+    insertGroup("admins", 0);
+    insertGroup("customer1", 0);
+    insertGroup("customer2", 0);
+    insertGroup("customer3", 0);
     loginAsAdmin();
 
     SearchWsResponse response = call(ws.newRequest());
@@ -94,16 +94,16 @@ public class SearchActionTest {
       tuple("customer1", "Customer1", 0),
       tuple("customer2", "Customer2", 0),
       tuple("customer3", "Customer3", 0),
-      tuple("users", "Users", 0));
+      tuple("sonar-users", "Users", 0));
   }
 
   @Test
   public void search_with_members() {
-    insertDefaultGroup(db.getDefaultOrganization(), "users", 5);
-    insertGroup(db.getDefaultOrganization(), "admins", 1);
-    insertGroup(db.getDefaultOrganization(), "customer1", 0);
-    insertGroup(db.getDefaultOrganization(), "customer2", 4);
-    insertGroup(db.getDefaultOrganization(), "customer3", 0);
+    insertDefaultGroup(5);
+    insertGroup("admins", 1);
+    insertGroup("customer1", 0);
+    insertGroup("customer2", 4);
+    insertGroup("customer3", 0);
     loginAsAdmin();
 
     SearchWsResponse response = call(ws.newRequest());
@@ -113,16 +113,16 @@ public class SearchActionTest {
       tuple("customer1", "Customer1", 0),
       tuple("customer2", "Customer2", 4),
       tuple("customer3", "Customer3", 0),
-      tuple("users", "Users", 5));
+      tuple("sonar-users", "Users", 5));
   }
 
   @Test
   public void search_with_query() {
-    insertDefaultGroup(db.getDefaultOrganization(), "users", 0);
-    insertGroup(db.getDefaultOrganization(), "admins", 0);
-    insertGroup(db.getDefaultOrganization(), "customer%_%/1", 0);
-    insertGroup(db.getDefaultOrganization(), "customer%_%/2", 0);
-    insertGroup(db.getDefaultOrganization(), "customer%_%/3", 0);
+    insertDefaultGroup(0);
+    insertGroup("admins", 0);
+    insertGroup("customer%_%/1", 0);
+    insertGroup("customer%_%/2", 0);
+    insertGroup("customer%_%/3", 0);
     loginAsAdmin();
 
     SearchWsResponse response = call(ws.newRequest().setParam(TEXT_QUERY, "tomer%_%/"));
@@ -135,11 +135,11 @@ public class SearchActionTest {
 
   @Test
   public void search_with_paging() {
-    insertDefaultGroup(db.getDefaultOrganization(), "users", 0);
-    insertGroup(db.getDefaultOrganization(), "admins", 0);
-    insertGroup(db.getDefaultOrganization(), "customer1", 0);
-    insertGroup(db.getDefaultOrganization(), "customer2", 0);
-    insertGroup(db.getDefaultOrganization(), "customer3", 0);
+    insertDefaultGroup(0);
+    insertGroup("admins", 0);
+    insertGroup("customer1", 0);
+    insertGroup("customer2", 0);
+    insertGroup("customer3", 0);
     loginAsAdmin();
 
     SearchWsResponse response = call(ws.newRequest().setParam(PAGE_SIZE, "3"));
@@ -153,7 +153,7 @@ public class SearchActionTest {
     assertThat(response.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsOnly(2, 3, 5);
     assertThat(response.getGroupsList()).extracting(Group::getName, Group::getDescription, Group::getMembersCount).containsOnly(
       tuple("customer3", "Customer3", 0),
-      tuple("users", "Users", 0));
+      tuple("sonar-users", "Users", 0));
 
     response = call(ws.newRequest().setParam(PAGE_SIZE, "3").setParam(PAGE, "3"));
     assertThat(response.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsOnly(3, 3, 5);
@@ -162,7 +162,7 @@ public class SearchActionTest {
 
   @Test
   public void search_with_fields() {
-    insertDefaultGroup(db.getDefaultOrganization(), "sonar-users", 0);
+    insertDefaultGroup(0);
     loginAsAdmin();
 
     assertThat(call(ws.newRequest()).getGroupsList()).extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount)
@@ -179,23 +179,12 @@ public class SearchActionTest {
 
   @Test
   public void return_default_group() {
-    db.users().insertDefaultGroup("default");
+    db.users().insertDefaultGroup();
     loginAsAdmin();
 
     SearchWsResponse response = call(ws.newRequest());
 
-    assertThat(response.getGroupsList()).extracting(Group::getName, Group::getDefault).containsOnly(tuple("default", true));
-  }
-
-  @Test
-  public void fail_when_no_default_group() {
-    db.users().insertGroup("users");
-    loginAsAdmin();
-
-    expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage("Default group cannot be found");
-
-    call(ws.newRequest());
+    assertThat(response.getGroupsList()).extracting(Group::getName, Group::getDefault).containsOnly(tuple("sonar-users", true));
   }
 
   @Test
@@ -208,8 +197,8 @@ public class SearchActionTest {
 
   @Test
   public void test_json_example() {
-    insertDefaultGroup(db.getDefaultOrganization(), "users", 17);
-    insertGroup(db.getDefaultOrganization(), "administrators", 2);
+    insertDefaultGroup(17);
+    insertGroup("administrators", 2);
     loginAsAdmin();
 
     String response = ws.newRequest().setMediaType(MediaTypes.JSON).execute().getInput();
@@ -226,7 +215,7 @@ public class SearchActionTest {
     assertThat(action.isInternal()).isFalse();
     assertThat(action.responseExampleAsString()).isNotEmpty();
 
-    assertThat(action.params()).extracting(WebService.Param::key).containsOnly("p", "q", "ps", "f", "organization");
+    assertThat(action.params()).extracting(WebService.Param::key).containsOnly("p", "q", "ps", "f");
 
     assertThat(action.param("f").possibleValues()).containsOnly("name", "description", "membersCount");
   }
@@ -235,13 +224,12 @@ public class SearchActionTest {
     return request.executeProtobuf(SearchWsResponse.class);
   }
 
-  private void insertDefaultGroup(OrganizationDto org, String name, int numberOfMembers) {
-    GroupDto group = newGroupDto().setName(name).setDescription(capitalize(name));
-    db.users().insertDefaultGroup(group);
+  private void insertDefaultGroup(int numberOfMembers) {
+    GroupDto group = db.users().insertDefaultGroup();
     addMembers(group, numberOfMembers);
   }
 
-  private void insertGroup(OrganizationDto org, String name, int numberOfMembers) {
+  private void insertGroup(String name, int numberOfMembers) {
     GroupDto group = newGroupDto().setName(name).setDescription(capitalize(name));
     db.users().insertGroup(group);
     addMembers(group, numberOfMembers);
index 26d43ea4583ce3d4dbd33c17dc0793fb76201041..bf2b901f4066edfde0789bab7660a0ceb75c56fc 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.db.user.UserDto;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.exceptions.ServerException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.DefaultGroupFinder;
 import org.sonar.server.ws.TestRequest;
@@ -50,10 +49,8 @@ public class UpdateActionTest {
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
 
-  private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
-  private WsActionTester ws = new WsActionTester(
-    new UpdateAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider)),
-      defaultOrganizationProvider));
+  private final WsActionTester ws = new WsActionTester(
+    new UpdateAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient()))));
 
   @Test
   public void verify_definition() {
@@ -282,11 +279,11 @@ public class UpdateActionTest {
 
   @Test
   public void fail_to_update_default_group_name() {
-    GroupDto group = db.users().insertDefaultGroup("default");
+    GroupDto group = db.users().insertDefaultGroup();
     loginAsAdmin();
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
+    expectedException.expectMessage("Default group 'sonar-users' cannot be used to perform this action");
 
     newRequest()
       .setParam("id", group.getUuid())
@@ -296,11 +293,11 @@ public class UpdateActionTest {
 
   @Test
   public void fail_to_update_default_group_description() {
-    GroupDto group = db.users().insertDefaultGroup("default");
+    GroupDto group = db.users().insertDefaultGroup();
     loginAsAdmin();
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
+    expectedException.expectMessage("Default group 'sonar-users' cannot be used to perform this action");
 
     newRequest()
       .setParam("id", group.getUuid())
index 9ad8de4d6d5398282f06ec049af9d1269775e51a..1a9be214911f331dfad9a1c41d1e8de9ec530a06 100644 (file)
@@ -54,17 +54,16 @@ public class UsersActionTest {
   public DbTester db = DbTester.create(System2.INSTANCE);
   @Rule
   public UserSessionRule userSession = UserSessionRule.standalone();
-  private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
-  private WsActionTester ws = new WsActionTester(
-    new UsersAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient(), defaultOrganizationProvider))));
+  private final WsActionTester ws = new WsActionTester(
+    new UsersAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), new DefaultGroupFinder(db.getDbClient()))));
 
   @Test
   public void verify_definition() {
     Action wsDef = ws.getDef();
 
-    assertThat(wsDef.isInternal()).isEqualTo(false);
+    assertThat(wsDef.isInternal()).isFalse();
     assertThat(wsDef.since()).isEqualTo("5.2");
-    assertThat(wsDef.isPost()).isEqualTo(false);
+    assertThat(wsDef.isPost()).isFalse();
     assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
       tuple("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."));
   }
@@ -215,20 +214,20 @@ public class UsersActionTest {
       .setParam("id", group.getUuid())
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"users\": [\n" +
-      "    {\"login\": \"ada\", \"name\": \"Ada Lovelace\", \"selected\": true}\n" +
-      "  ]\n" +
-      "}");
+        "  \"users\": [\n" +
+        "    {\"login\": \"ada\", \"name\": \"Ada Lovelace\", \"selected\": true}\n" +
+        "  ]\n" +
+        "}");
 
     assertJson(newUsersRequest()
       .setParam("id", group.getUuid())
       .setParam(Param.SELECTED, SelectionMode.SELECTED.value())
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"users\": [\n" +
-      "    {\"login\": \"ada\", \"name\": \"Ada Lovelace\", \"selected\": true}\n" +
-      "  ]\n" +
-      "}");
+        "  \"users\": [\n" +
+        "    {\"login\": \"ada\", \"name\": \"Ada Lovelace\", \"selected\": true}\n" +
+        "  ]\n" +
+        "}");
   }
 
   @Test
@@ -270,13 +269,13 @@ public class UsersActionTest {
       .setParam(Param.SELECTED, SelectionMode.ALL.value())
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"p\": 1,\n" +
-      "  \"ps\": 1,\n" +
-      "  \"total\": 2,\n" +
-      "  \"users\": [\n" +
-      "    {\"login\": \"ada\", \"name\": \"Ada Lovelace\", \"selected\": true}\n" +
-      "  ]\n" +
-      "}");
+        "  \"p\": 1,\n" +
+        "  \"ps\": 1,\n" +
+        "  \"total\": 2,\n" +
+        "  \"users\": [\n" +
+        "    {\"login\": \"ada\", \"name\": \"Ada Lovelace\", \"selected\": true}\n" +
+        "  ]\n" +
+        "}");
 
     assertJson(newUsersRequest()
       .setParam("id", group.getUuid())
@@ -285,13 +284,13 @@ public class UsersActionTest {
       .setParam(Param.SELECTED, SelectionMode.ALL.value())
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"p\": 2,\n" +
-      "  \"ps\": 1,\n" +
-      "  \"total\": 2,\n" +
-      "  \"users\": [\n" +
-      "    {\"login\": \"grace\", \"name\": \"Grace Hopper\", \"selected\": false}\n" +
-      "  ]\n" +
-      "}");
+        "  \"p\": 2,\n" +
+        "  \"ps\": 1,\n" +
+        "  \"total\": 2,\n" +
+        "  \"users\": [\n" +
+        "    {\"login\": \"grace\", \"name\": \"Grace Hopper\", \"selected\": false}\n" +
+        "  ]\n" +
+        "}");
   }
 
   @Test
@@ -310,50 +309,50 @@ public class UsersActionTest {
       .setParam(Param.SELECTED, SelectionMode.ALL.value())
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"users\": [\n" +
-      "    {\"login\": \"ada.login\", \"name\": \"Ada Lovelace\", \"selected\": true},\n" +
-      "    {\"login\": \"grace\", \"name\": \"Grace Hopper\", \"selected\": false}\n" +
-      "  ]\n" +
-      "}\n");
+        "  \"users\": [\n" +
+        "    {\"login\": \"ada.login\", \"name\": \"Ada Lovelace\", \"selected\": true},\n" +
+        "    {\"login\": \"grace\", \"name\": \"Grace Hopper\", \"selected\": false}\n" +
+        "  ]\n" +
+        "}\n");
 
     assertJson(newUsersRequest().setParam("id", group.getUuid())
       .setParam("q", ".logi")
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"users\": [\n" +
-      "    {\n" +
-      "      \"login\": \"ada.login\",\n" +
-      "      \"name\": \"Ada Lovelace\",\n" +
-      "      \"selected\": true\n" +
-      "    }\n" +
-      "  ]\n" +
-      "}\n");
+        "  \"users\": [\n" +
+        "    {\n" +
+        "      \"login\": \"ada.login\",\n" +
+        "      \"name\": \"Ada Lovelace\",\n" +
+        "      \"selected\": true\n" +
+        "    }\n" +
+        "  ]\n" +
+        "}\n");
 
     assertJson(newUsersRequest().setParam("id", group.getUuid())
       .setParam("q", "OvE")
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"users\": [\n" +
-      "    {\n" +
-      "      \"login\": \"ada.login\",\n" +
-      "      \"name\": \"Ada Lovelace\",\n" +
-      "      \"selected\": true\n" +
-      "    }\n" +
-      "  ]\n" +
-      "}\n");
+        "  \"users\": [\n" +
+        "    {\n" +
+        "      \"login\": \"ada.login\",\n" +
+        "      \"name\": \"Ada Lovelace\",\n" +
+        "      \"selected\": true\n" +
+        "    }\n" +
+        "  ]\n" +
+        "}\n");
 
     assertJson(newUsersRequest().setParam("id", group.getUuid())
       .setParam("q", "mail")
       .execute()
       .getInput()).isSimilarTo("{\n" +
-      "  \"users\": [\n" +
-      "    {\n" +
-      "      \"login\": \"ada.login\",\n" +
-      "      \"name\": \"Ada Lovelace\",\n" +
-      "      \"selected\": true\n" +
-      "    }\n" +
-      "  ]\n" +
-      "}\n");
+        "  \"users\": [\n" +
+        "    {\n" +
+        "      \"login\": \"ada.login\",\n" +
+        "      \"name\": \"Ada Lovelace\",\n" +
+        "      \"selected\": true\n" +
+        "    }\n" +
+        "  ]\n" +
+        "}\n");
   }
 
   @Test
index 787f23845c8b1b2a256e4b324acb3ba54d1cda5c..bb5e07a7921ddeb88821c5a0f7befc171f2a42a9 100644 (file)
@@ -43,8 +43,8 @@ message SearchWsResponse {
 }
 
 message Group {
+  reserved 2;
   optional string id = 1;
-  optional string organization = 2;
   optional string name = 3;
   optional string description = 4;
   optional int32 membersCount = 5;