]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15142 Set a permission template default for Projects / Applications / Portfolio...
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 16 Aug 2021 20:44:41 +0000 (15:44 -0500)
committersonartech <sonartech@sonarsource.com>
Thu, 19 Aug 2021 20:08:15 +0000 (20:08 +0000)
13 files changed:
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/GroupPermissionNewValue.java
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/UserNewValue.java
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/UserPermissionNewValue.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoWithPersisterTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoWithPersisterTest.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/UserPermissionChange.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/AddUserAction.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/permission/ws/RemoveUserAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java

index ca0fec0c2dd63ca09d89196e24c706c4e9e1dd3e..bad701178826d3c9cd06c016f635f3d95b7785ae 100644 (file)
@@ -61,7 +61,7 @@ public class GroupPermissionNewValue extends PermissionNewValue {
   public String toString() {
     StringBuilder sb = new StringBuilder("{");
     addField(sb, "\"permissionUuid\": ", this.permissionUuid, true);
-    addField(sb, "\"role\": ", this.role, true);
+    addField(sb, "\"permission\": ", this.permission, true);
     addField(sb, "\"groupUuid\": ", this.groupUuid, true);
     addField(sb, "\"groupName\": ", this.groupName, true);
     addField(sb, "\"componentUuid\": ", this.componentUuid, true);
index ff8f4dd95ebe7841bf49247dd7edaa09c6968b01..62bd6e87bb16864bfd7b32e0ecfb394896b04380 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.db.user.UserDto;
 
 public class UserNewValue extends NewValue {
   private String userUuid;
-  private String login;
+  private String userLogin;
 
   @Nullable
   private String name;
@@ -63,12 +63,12 @@ public class UserNewValue extends NewValue {
 
   public UserNewValue(String userUuid, String userLogin) {
     this.userUuid = userUuid;
-    this.login = userLogin;
+    this.userLogin = userLogin;
   }
 
   public UserNewValue(UserDto userDto) {
     this.userUuid = userDto.getUuid();
-    this.login = userDto.getLogin();
+    this.userLogin = userDto.getLogin();
     this.name = userDto.getName();
     this.email = userDto.getEmail();
     this.isActive = userDto.isActive();
@@ -86,8 +86,8 @@ public class UserNewValue extends NewValue {
     return this.userUuid;
   }
 
-  public String getLogin() {
-    return this.login;
+  public String getUserLogin() {
+    return this.userLogin;
   }
 
   @CheckForNull
@@ -149,7 +149,7 @@ public class UserNewValue extends NewValue {
   public String toString() {
     StringBuilder sb = new StringBuilder("{");
     addField(sb, "\"userUuid\": ", this.userUuid, true);
-    addField(sb, "\"userLogin\": ", this.login, true);
+    addField(sb, "\"userLogin\": ", this.userLogin, true);
     addField(sb, "\"name\": ", this.name, true);
     addField(sb, "\"email\": ", this.email, true);
     addField(sb, "\"isActive\": ", ObjectUtils.toString(this.isActive), false);
index bcc93c4147396c48b831ae15afc79c73b6c7aac6..6a42acd4957b8d587ada2cec61d0a1b30e901a39 100644 (file)
@@ -60,7 +60,7 @@ public class UserPermissionNewValue extends PermissionNewValue {
   public String toString() {
     StringBuilder sb = new StringBuilder("{");
     addField(sb, "\"permissionUuid\": ", this.permissionUuid, true);
-    addField(sb, "\"role\": ", this.role, true);
+    addField(sb, "\"permission\": ", this.permission, true);
     addField(sb, "\"componentUuid\": ", this.componentUuid, true);
     addField(sb, "\"componentName\": ", this.componentName, true);
     addField(sb, "\"userUuid\": ", this.userUuid, true);
index a50e9b10b16ac6e049c227a0a29800f023eb5c5f..63d0a755617fbe39444a60472f8bd91e5600118c 100644 (file)
@@ -51,7 +51,7 @@ public class GroupPermissionDaoWithPersisterTest {
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE, auditPersister);
 
-  public final SequenceUuidFactory uuidFactory = new SequenceUuidFactory();
+  private final SequenceUuidFactory uuidFactory = new SequenceUuidFactory();
   private final ArgumentCaptor<GroupPermissionNewValue> newValueCaptor = ArgumentCaptor.forClass(GroupPermissionNewValue.class);
   private final DbSession dbSession = db.getSession();
   private final GroupPermissionDao underTest = db.getDbClient().groupPermissionDao();
@@ -172,7 +172,7 @@ public class GroupPermissionDaoWithPersisterTest {
 
   private void assertNewValue(GroupPermissionNewValue newValue, String uuid, String groupUuid, String groupName, String cUuid, String permission, String cName, String qualifier) {
     assertThat(newValue)
-      .extracting("permissionUuid", "groupUuid", "groupName", "componentUuid", "role", "componentName", "qualifier")
+      .extracting("permissionUuid", "groupUuid", "groupName", "componentUuid", "permission", "componentName", "qualifier")
       .containsExactly(uuid, groupUuid, groupName, cUuid, permission, cName, qualifier);
   }
 
index b423bf01e2b36fb3d7b20f456460796d42af8fcc..7be718c1c12b080ebb1805ad34dd4c9fe0a79192 100644 (file)
@@ -59,20 +59,14 @@ public class UserPermissionDaoWithPersisterTest {
 
     verify(auditPersister).addUserPermission(eq(dbSession), newValueCaptor.capture());
     UserPermissionNewValue newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin,
-        UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
-      .containsExactly(dto.getUuid(), user.getUuid(), user.getLogin(), null, dto.getPermission(), null, null);
+    assertNewValue(newValue, dto.getUuid(), user.getUuid(), user.getLogin(), null, dto.getPermission(), null, null);
     assertThat(newValue.toString()).doesNotContain("projectUuid");
 
     underTest.deleteGlobalPermission(dbSession, user, SYSTEM_ADMIN);
 
     verify(auditPersister).deleteUserPermission(eq(dbSession), newValueCaptor.capture());
     newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName)
-      .containsExactly(null, user.getUuid(), user.getLogin(), null, dto.getPermission(), null);
+    assertNewValue(newValue, null, user.getUuid(), user.getLogin(), null, dto.getPermission(), null, null);
     assertThat(newValue.toString()).doesNotContain("permissionUuid");
   }
 
@@ -95,22 +89,15 @@ public class UserPermissionDaoWithPersisterTest {
 
     verify(auditPersister).addUserPermission(eq(dbSession), newValueCaptor.capture());
     UserPermissionNewValue newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
-      .containsExactly(dto.getUuid(), user.getUuid(), user.getLogin(), project.uuid(), dto.getPermission(), project.name(), "project");
+    assertNewValue(newValue, dto.getUuid(), user.getUuid(), user.getLogin(), project.uuid(), dto.getPermission(), project.name(), "project");
     assertThat(newValue.toString()).contains("componentUuid");
 
     underTest.deleteProjectPermission(dbSession, user, SYSTEM_ADMIN, project);
 
     verify(auditPersister).deleteUserPermission(eq(dbSession), newValueCaptor.capture());
     newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin,
-        UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName)
-      .containsExactly(null, user.getUuid(), user.getLogin(), project.uuid(), dto.getPermission(), project.name());
-    assertThat(newValue.toString())
-      .doesNotContain("permissionUuid");
+    assertNewValue(newValue, null, user.getUuid(), user.getLogin(), project.uuid(), dto.getPermission(), project.name(), "project");
+    assertThat(newValue.toString()).doesNotContain("permissionUuid");
   }
 
   @Test
@@ -134,12 +121,8 @@ public class UserPermissionDaoWithPersisterTest {
 
     verify(auditPersister).addUserPermission(eq(dbSession), newValueCaptor.capture());
     UserPermissionNewValue newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
-      .containsExactly(dto.getUuid(), user.getUuid(), portfolio.uuid(), dto.getPermission(), portfolio.name(), "portfolio");
-    assertThat(newValue.toString())
-      .contains("componentUuid");
+    assertNewValue(newValue, dto.getUuid(), user.getUuid(), user.getLogin(), portfolio.uuid(), dto.getPermission(), portfolio.name(), "portfolio");
+    assertThat(newValue.toString()).contains("componentUuid");
   }
 
   @Test
@@ -151,12 +134,8 @@ public class UserPermissionDaoWithPersisterTest {
 
     verify(auditPersister).addUserPermission(eq(dbSession), newValueCaptor.capture());
     UserPermissionNewValue newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
-      .containsExactly(dto.getUuid(), user.getUuid(), application.uuid(), dto.getPermission(), application.name(), "application");
-    assertThat(newValue.toString())
-      .contains("componentUuid");
+    assertNewValue(newValue, dto.getUuid(), user.getUuid(), user.getLogin(), application.uuid(), dto.getPermission(), application.name(), "application");
+    assertThat(newValue.toString()).contains("componentUuid");
   }
 
   @Test
@@ -169,10 +148,7 @@ public class UserPermissionDaoWithPersisterTest {
 
     verify(auditPersister).deleteUserPermission(eq(dbSession), newValueCaptor.capture());
     UserPermissionNewValue newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
-      .containsExactly(null, null, null, project.uuid(), SCAN_EXECUTION, project.name(), "project");
+    assertNewValue(newValue, null, null, null, project.uuid(), dto.getPermission(), project.name(), "project");
     assertThat(newValue.toString()).doesNotContain("userUuid");
   }
 
@@ -196,10 +172,7 @@ public class UserPermissionDaoWithPersisterTest {
 
     verify(auditPersister).deleteUserPermission(eq(dbSession), newValueCaptor.capture());
     UserPermissionNewValue newValue = newValueCaptor.getValue();
-    assertThat(newValue)
-      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
-      .containsExactly(null, user.getUuid(), user.getLogin(), null, null, null, null);
+    assertNewValue(newValue, null, user.getUuid(), user.getLogin(), null, null, null, null);
     assertThat(newValue.toString()).contains("userUuid");
   }
 
@@ -213,7 +186,15 @@ public class UserPermissionDaoWithPersisterTest {
     verifyNoMoreInteractions(auditPersister);
   }
 
+  private void assertNewValue(UserPermissionNewValue newValue, String permissionUuid, String userUuid, String userLogin, String componentUuid, String permission,
+    String componentName, String qualifier) {
+    assertThat(newValue)
+      .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin,
+        UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
+      .containsExactly(permissionUuid, userUuid, userLogin, componentUuid, permission, componentName, qualifier);
+  }
+
   private UserDto insertUser(Consumer<UserDto> populateUserDto) {
-   return db.users().insertUser(populateUserDto);
+    return db.users().insertUser(populateUserDto);
   }
 }
index 695a3e49dad6569d44fd6ba2fa169be043b6b448..c4db20ec07f1e1093e8867ea4a44d1ef1d094523 100644 (file)
@@ -69,7 +69,7 @@ public class UserDaoWithPersisterTest {
     verify(auditPersister).addUser(eq(db.getSession()), newValueCaptor.capture());
     UserNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
-      .extracting(UserNewValue::getUserUuid, UserNewValue::getLogin)
+      .extracting(UserNewValue::getUserUuid, UserNewValue::getUserLogin)
       .containsExactly(user.getUuid(), user.getLogin());
     assertThat(newValue.toString()).doesNotContain("name");
   }
@@ -108,7 +108,7 @@ public class UserDaoWithPersisterTest {
     verify(auditPersister).updateUser(eq(db.getSession()), newValueCaptor.capture());
     UserNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
-      .extracting(UserNewValue::getUserUuid, UserNewValue::getLogin, UserNewValue::getName, UserNewValue::getEmail, UserNewValue::isActive,
+      .extracting(UserNewValue::getUserUuid, UserNewValue::getUserLogin, UserNewValue::getName, UserNewValue::getEmail, UserNewValue::isActive,
         UserNewValue::getScmAccounts, UserNewValue::getExternalId, UserNewValue::getExternalLogin, UserNewValue::getExternalIdentityProvider,
         UserNewValue::isLocal, UserNewValue::isOnboarded, UserNewValue::isRoot, UserNewValue::getLastConnectionDate)
       .containsExactly(updatedUser.getUuid(), updatedUser.getLogin(), updatedUser.getName(), updatedUser.getEmail(), updatedUser.isActive(),
@@ -148,7 +148,7 @@ public class UserDaoWithPersisterTest {
 
     verify(auditPersister).deactivateUser(eq(db.getSession()), newValueCaptor.capture());
     assertThat(newValueCaptor.getValue())
-      .extracting(UserNewValue::getUserUuid, UserNewValue::getLogin)
+      .extracting(UserNewValue::getUserUuid, UserNewValue::getUserLogin)
       .containsExactly(user.getUuid(), user.getLogin());
   }
 
index 2f23bd4a569846c81dec6c12874d6c6c26acad67..bdd710fbc044d41ebd851bf2de37fd072f43ca81 100644 (file)
@@ -21,20 +21,20 @@ package org.sonar.server.permission;
 
 import javax.annotation.Nullable;
 import org.sonar.db.component.ComponentDto;
-import org.sonar.db.user.UserIdDto;
+import org.sonar.db.user.UserId;
 
 import static java.util.Objects.requireNonNull;
 
 public class UserPermissionChange extends PermissionChange {
 
-  private final UserIdDto userId;
+  private final UserId userId;
 
-  public UserPermissionChange(Operation operation, String permission, @Nullable ComponentDto project, UserIdDto userId, PermissionService permissionService) {
+  public UserPermissionChange(Operation operation, String permission, @Nullable ComponentDto project, UserId userId, PermissionService permissionService) {
     super(operation, permission, project, permissionService);
     this.userId = requireNonNull(userId);
   }
 
-  public UserIdDto getUserId() {
+  public UserId getUserId() {
     return userId;
   }
 }
index 3cd8361e068942bd667f882774328d2985351b86..3603ab090032ee2c08cf1e5009c4073097d5336e 100644 (file)
@@ -27,10 +27,10 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.user.UserId;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionService;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.db.user.UserIdDto;
 import org.sonar.server.permission.UserPermissionChange;
 import org.sonar.server.user.UserSession;
 
@@ -86,7 +86,7 @@ public class AddUserAction implements PermissionsWsAction {
   @Override
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
-      UserIdDto user = wsSupport.findUser(dbSession, request.mandatoryParam(PARAM_USER_LOGIN));
+      UserId user = wsSupport.findUser(dbSession, request.mandatoryParam(PARAM_USER_LOGIN));
       Optional<ComponentDto> project = wsSupport.findProject(dbSession, request);
       checkProjectAdmin(userSession, configuration, project.orElse(null));
 
index 27a1b09f9a43e223ce9127d4336e16749c211caf..f107f8275d8113c9fa1aee7eac27ce9f7076cb9d 100644 (file)
@@ -28,10 +28,11 @@ import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.permission.template.PermissionTemplateDto;
 import org.sonar.db.user.UserDto;
+import org.sonar.db.user.UserId;
+import org.sonar.db.user.UserIdDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.permission.GroupUuidOrAnyone;
-import org.sonar.db.user.UserIdDto;
 import org.sonar.server.permission.ws.template.WsTemplateRef;
 import org.sonar.server.user.UserSession;
 import org.sonar.server.usergroups.ws.GroupWsRef;
@@ -85,7 +86,7 @@ public class PermissionWsSupport {
     return groupWsSupport.findGroupOrAnyone(dbSession, groupRef);
   }
 
-  public UserIdDto findUser(DbSession dbSession, String login) {
+  public UserId findUser(DbSession dbSession, String login) {
     UserDto dto = ofNullable(dbClient.userDao().selectActiveUserByLogin(dbSession, login))
       .orElseThrow(() -> new NotFoundException(format("User with login '%s' is not found'", login)));
     return new UserIdDto(dto.getUuid(), dto.getLogin());
index c6938cea0e6783c86da207a3c11dd1330e2054d5..84b9e2a0ccaaebd50b9bf73b3516c9523ae07b1a 100644 (file)
@@ -26,11 +26,11 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.user.UserId;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionService;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.db.user.UserIdDto;
 import org.sonar.server.permission.UserPermissionChange;
 import org.sonar.server.user.UserSession;
 
@@ -84,7 +84,7 @@ public class RemoveUserAction implements PermissionsWsAction {
   @Override
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
-      UserIdDto user = wsSupport.findUser(dbSession, request.mandatoryParam(PARAM_USER_LOGIN));
+      UserId user = wsSupport.findUser(dbSession, request.mandatoryParam(PARAM_USER_LOGIN));
       String permission = request.mandatoryParam(PARAM_PERMISSION);
       if (ADMINISTER.getKey().equals(permission) && user.getLogin().equals(userSession.getLogin())) {
         throw BadRequestException.create("As an admin, you can't remove your own admin right");
index a508348156b58e861aa3400c5a868baedacdd085..5ab0b023f33813ed525221d560d8b5273e1b0219 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.permission.PermissionQuery;
 import org.sonar.db.permission.template.PermissionTemplateDto;
-import org.sonar.db.user.UserIdDto;
+import org.sonar.db.user.UserId;
 import org.sonar.server.permission.ws.PermissionWsSupport;
 import org.sonar.server.permission.ws.PermissionsWsAction;
 import org.sonar.server.permission.ws.WsParameters;
@@ -95,7 +95,7 @@ public class AddUserToTemplateAction implements PermissionsWsAction {
       PermissionTemplateDto template = wsSupport.findTemplate(dbSession, newTemplateRef(
         request.getTemplateId(), request.getTemplateName()));
       checkGlobalAdmin(userSession);
-      UserIdDto user = wsSupport.findUser(dbSession, userLogin);
+      UserId user = wsSupport.findUser(dbSession, userLogin);
 
       if (!isUserAlreadyAdded(dbSession, template.getUuid(), userLogin, permission)) {
         dbClient.permissionTemplateDao().insertUserPermission(dbSession, template.getUuid(), user.getUuid(), permission,
index 4d014c2e72691f439182f7df067be20948437650..f093ba44447553d8ffb48a70d8ee650761768749 100644 (file)
@@ -27,8 +27,8 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.permission.template.PermissionTemplateDto;
+import org.sonar.db.user.UserId;
 import org.sonar.server.permission.RequestValidator;
-import org.sonar.db.user.UserIdDto;
 import org.sonar.server.permission.ws.PermissionWsSupport;
 import org.sonar.server.permission.ws.PermissionsWsAction;
 import org.sonar.server.permission.ws.WsParameters;
@@ -96,7 +96,7 @@ public class RemoveUserFromTemplateAction implements PermissionsWsAction {
       PermissionTemplateDto template = wsSupport.findTemplate(dbSession, WsTemplateRef.newTemplateRef(request.getTemplateId(), request.getTemplateName()));
       checkGlobalAdmin(userSession);
 
-      UserIdDto user = wsSupport.findUser(dbSession, userLogin);
+      UserId user = wsSupport.findUser(dbSession, userLogin);
 
       dbClient.permissionTemplateDao().deleteUserPermission(dbSession, template.getUuid(), user.getUuid(), permission, template.getName(), user.getLogin());
       dbSession.commit();
index c97a0c5178095b5981a9c8d518c1f396db8e53ab..ee0a2f20e2c2f69fec58b9b2e1efd901a83930dd 100644 (file)
  */
 package org.sonar.server.project.ws;
 
+import java.util.Arrays;
+import java.util.Random;
+import java.util.Set;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.config.Configuration;
@@ -68,11 +73,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.api.CoreProperties.CORE_ALLOW_PERMISSION_MANAGEMENT_FOR_PROJECT_ADMINS_PROPERTY;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
-import java.util.Arrays;
-import java.util.Random;
-import java.util.Set;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
 
 public class UpdateVisibilityActionTest {
   private static final String PARAM_VISIBILITY = "visibility";
@@ -489,28 +489,6 @@ public class UpdateVisibilityActionTest {
       .isEmpty();
   }
 
-  @Test
-  public void update_a_portfolio_to_private_givenWeCanFindUserByUUID_stillUpdatePermissions() {
-    ComponentDto portfolio = dbTester.components().insertPublicPortfolio();
-    GroupDto group = dbTester.users().insertGroup();
-    dbTester.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, portfolio);
-    UserDto userDto = mock(UserDto.class);
-    when(userDto.getUuid()).thenReturn("uuid");
-    when(userDto.getLogin()).thenReturn("login");
-    dbTester.users().insertProjectPermissionOnUser(userDto, UserRole.ADMIN, portfolio);
-    userSessionRule.addProjectPermission(UserRole.ADMIN, portfolio);
-
-    request.setParam(PARAM_PROJECT, portfolio.getDbKey())
-      .setParam(PARAM_VISIBILITY, PRIVATE)
-      .execute();
-
-    assertThat(dbClient.componentDao().selectByUuid(dbSession, portfolio.uuid()).get().isPrivate()).isTrue();
-    assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, group.getUuid(), portfolio.uuid()))
-      .containsOnly(UserRole.USER, UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN);
-    assertThat(dbClient.userPermissionDao().selectProjectPermissionsOfUser(dbSession, "uuid", portfolio.uuid()))
-      .containsOnly(UserRole.USER, UserRole.CODEVIEWER, UserRole.ADMIN);
-  }
-
   @Test
   public void update_a_portfolio_to_private() {
     ComponentDto portfolio = dbTester.components().insertPublicPortfolio();