aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMichal Duda <michal.duda@sonarsource.com>2020-12-14 21:18:50 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:36 +0000
commita8cd264afd2a7532ee0f3d9809db2d5cb8c32e6e (patch)
tree66ff12305b5060bc93b844dae11649540de14b3f /server
parent31c59b718a3c074deb51bfadf8152fb6317a826a (diff)
downloadsonarqube-a8cd264afd2a7532ee0f3d9809db2d5cb8c32e6e.tar.gz
sonarqube-a8cd264afd2a7532ee0f3d9809db2d5cb8c32e6e.zip
SONAR-13999 remove organizations from user WS
Diffstat (limited to 'server')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupDao.java5
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupMapper.java3
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserGroupMapper.xml6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/user/UserGroupDaoTest.java41
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/organization/MemberUpdater.java20
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/user/UserUpdater.java19
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java28
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java20
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java39
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java5
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java19
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java22
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java5
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java28
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java22
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java5
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java25
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java7
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java9
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java13
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java15
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java25
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionHomepageTest.java12
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java1
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java21
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetHomepageActionTest.java18
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java21
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java7
45 files changed, 198 insertions, 314 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupDao.java
index 73247cd9155..9add82f0b9d 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupDao.java
@@ -19,6 +19,7 @@
*/
package org.sonar.db.user;
+import java.util.Set;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
@@ -29,6 +30,10 @@ public class UserGroupDao implements Dao {
return dto;
}
+ public Set<String> selectUserUuidsInGroup(DbSession session, String groupUuid) {
+ return mapper(session).selectUserUuidsInGroup(groupUuid);
+ }
+
public void delete(DbSession session, String groupUuid, String userUuid) {
mapper(session).delete(groupUuid, userUuid);
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupMapper.java
index 9e67fd7c6aa..58a7848f6f8 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserGroupMapper.java
@@ -19,12 +19,15 @@
*/
package org.sonar.db.user;
+import java.util.Set;
import org.apache.ibatis.annotations.Param;
public interface UserGroupMapper {
void insert(UserGroupDto dto);
+ Set<String> selectUserUuidsInGroup(@Param("groupUuid") String groupUuid);
+
void delete(@Param("groupUuid") String groupUuid, @Param("userUuid") String userUuid);
void deleteByGroupUuid(@Param("groupUuid") String groupUuid);
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserGroupMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserGroupMapper.xml
index 9e98f945e5f..8151f29ea83 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserGroupMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserGroupMapper.xml
@@ -13,6 +13,12 @@
)
</insert>
+ <select id="selectUserUuidsInGroup" resultType="String">
+ select gu.user_uuid
+ from groups_users gu
+ where gu.group_uuid=#{groupUuid,jdbcType=VARCHAR}
+ </select>
+
<delete id="delete" parameterType="map">
delete from groups_users
where user_uuid = #{userUuid,jdbcType=VARCHAR} and
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserGroupDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserGroupDaoTest.java
index af3333241a1..2fe88a7dff0 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserGroupDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserGroupDaoTest.java
@@ -19,10 +19,10 @@
*/
package org.sonar.db.user;
+import java.util.Set;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
@@ -32,10 +32,9 @@ public class UserGroupDaoTest {
@Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
- private DbClient dbClient = dbTester.getDbClient();
- private DbSession dbSession = dbTester.getSession();
- private UserGroupDao underTest = dbTester.getDbClient().userGroupDao();
+ private final DbSession dbSession = dbTester.getSession();
+ private final UserGroupDao underTest = dbTester.getDbClient().userGroupDao();
@Test
public void insert() {
@@ -50,6 +49,40 @@ public class UserGroupDaoTest {
}
@Test
+ public void select_user_uuids_in_group() {
+ UserDto user1 = dbTester.users().insertUser();
+ UserDto user2 = dbTester.users().insertUser();
+ UserDto user3 = dbTester.users().insertUser();
+ GroupDto group1 = dbTester.users().insertGroup();
+ GroupDto group2 = dbTester.users().insertGroup();
+ UserGroupDto userGroupDto1 = new UserGroupDto().setUserUuid(user1.getUuid()).setGroupUuid(group1.getUuid());
+ UserGroupDto userGroupDto2 = new UserGroupDto().setUserUuid(user2.getUuid()).setGroupUuid(group2.getUuid());
+ UserGroupDto userGroupDto3 = new UserGroupDto().setUserUuid(user3.getUuid()).setGroupUuid(group2.getUuid());
+ underTest.insert(dbSession, userGroupDto1);
+ underTest.insert(dbSession, userGroupDto2);
+ underTest.insert(dbSession, userGroupDto3);
+ dbTester.getSession().commit();
+
+ Set<String> userUuids = underTest.selectUserUuidsInGroup(dbTester.getSession(), group2.getUuid());
+
+ assertThat(userUuids).containsExactlyInAnyOrder(user2.getUuid(), user3.getUuid());
+ }
+
+ @Test
+ public void select_user_uuids_in_group_returns_empty_set_when_nothing_found() {
+ UserDto user1 = dbTester.users().insertUser();
+ GroupDto group1 = dbTester.users().insertGroup();
+ GroupDto group2 = dbTester.users().insertGroup();
+ UserGroupDto userGroupDto1 = new UserGroupDto().setUserUuid(user1.getUuid()).setGroupUuid(group1.getUuid());
+ underTest.insert(dbSession, userGroupDto1);
+ dbTester.getSession().commit();
+
+ Set<String> userUuids = underTest.selectUserUuidsInGroup(dbTester.getSession(), group2.getUuid());
+
+ assertThat(userUuids).isEmpty();
+ }
+
+ @Test
public void delete_members_by_group_uuid() {
UserDto user1 = dbTester.users().insertUser();
UserDto user2 = dbTester.users().insertUser();
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/organization/MemberUpdater.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/organization/MemberUpdater.java
index f24d55a9cc0..63c66c7e334 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/organization/MemberUpdater.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/organization/MemberUpdater.java
@@ -28,7 +28,6 @@ import org.sonar.db.DbSession;
import org.sonar.db.alm.ALM;
import org.sonar.db.alm.OrganizationAlmBindingDto;
import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.organization.OrganizationMemberDto;
import org.sonar.db.user.UserDto;
import org.sonar.db.user.UserGroupDto;
import org.sonar.server.user.index.UserIndexer;
@@ -56,12 +55,12 @@ public class MemberUpdater {
this.userIndexer = userIndexer;
}
- public void addMember(DbSession dbSession, OrganizationDto organization, UserDto user) {
- addMembers(dbSession, organization, singletonList(user));
+ public void addMember(DbSession dbSession, UserDto user) {
+ addMembers(dbSession, singletonList(user));
}
- public void addMembers(DbSession dbSession, OrganizationDto organization, List<UserDto> users) {
- Set<String> currentMemberUuids = new HashSet<>(dbClient.organizationMemberDao().selectUserUuidsByOrganizationUuid(dbSession, organization.getUuid()));
+ public void addMembers(DbSession dbSession, List<UserDto> users) {
+ Set<String> currentMemberUuids = dbClient.userGroupDao().selectUserUuidsInGroup(dbSession, defaultGroupFinder.findDefaultGroup(dbSession).getUuid());
List<UserDto> usersToAdd = users.stream()
.filter(UserDto::isActive)
.filter(u -> !currentMemberUuids.contains(u.getUuid()))
@@ -69,22 +68,21 @@ public class MemberUpdater {
if (usersToAdd.isEmpty()) {
return;
}
- usersToAdd.forEach(u -> addMemberInDb(dbSession, organization, u));
+ usersToAdd.forEach(u -> addMemberInDb(dbSession, u));
userIndexer.commitAndIndex(dbSession, usersToAdd);
}
- private void addMemberInDb(DbSession dbSession, OrganizationDto organization, UserDto user) {
- dbClient.organizationMemberDao().insert(dbSession, new OrganizationMemberDto()
- .setOrganizationUuid(organization.getUuid())
- .setUserUuid(user.getUuid()));
+ private void addMemberInDb(DbSession dbSession, UserDto user) {
dbClient.userGroupDao().insert(dbSession,
new UserGroupDto().setGroupUuid(defaultGroupFinder.findDefaultGroup(dbSession).getUuid()).setUserUuid(user.getUuid()));
}
+ // TODO remove org param like it was removed from addMembers
public void removeMember(DbSession dbSession, OrganizationDto organization, UserDto user) {
removeMembers(dbSession, organization, singletonList(user));
}
+ // TODO remove org param like it was removed from addMembers
public void removeMembers(DbSession dbSession, OrganizationDto organization, List<UserDto> users) {
Set<String> currentMemberIds = new HashSet<>(dbClient.organizationMemberDao().selectUserUuidsByOrganizationUuid(dbSession, organization.getUuid()));
List<UserDto> usersToRemove = users.stream()
@@ -126,7 +124,7 @@ public class MemberUpdater {
allOrganizationsByUuid.entrySet().stream()
.filter(entry -> organizationUuidsToBeAdded.contains(entry.getKey()))
- .forEach(entry -> addMemberInDb(dbSession, entry.getValue(), user));
+ .forEach(entry -> addMemberInDb(dbSession, user));
allOrganizationsByUuid.entrySet().stream()
.filter(entry -> organizationUuidsToBeRemoved.contains(entry.getKey()))
.forEach(entry -> removeMemberInDb(dbSession, entry.getValue(), user));
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/UserUpdater.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/UserUpdater.java
index ba996626e59..bce94f4ee31 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/UserUpdater.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/UserUpdater.java
@@ -35,12 +35,10 @@ import org.sonar.api.platform.NewUserHandler;
import org.sonar.api.server.ServerSide;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationMemberDto;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
import org.sonar.db.user.UserGroupDto;
import org.sonar.server.authentication.CredentialsLocalAuthentication;
-import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.user.index.UserIndexer;
import org.sonar.server.usergroups.DefaultGroupFinder;
import org.sonar.server.util.Validation;
@@ -75,18 +73,15 @@ public class UserUpdater {
private final NewUserNotifier newUserNotifier;
private final DbClient dbClient;
private final UserIndexer userIndexer;
- private final DefaultOrganizationProvider defaultOrganizationProvider;
private final DefaultGroupFinder defaultGroupFinder;
private final Configuration config;
private final CredentialsLocalAuthentication localAuthentication;
- public UserUpdater(NewUserNotifier newUserNotifier, DbClient dbClient, UserIndexer userIndexer,
- DefaultOrganizationProvider defaultOrganizationProvider, DefaultGroupFinder defaultGroupFinder, Configuration config,
+ public UserUpdater(NewUserNotifier newUserNotifier, DbClient dbClient, UserIndexer userIndexer, DefaultGroupFinder defaultGroupFinder, Configuration config,
CredentialsLocalAuthentication localAuthentication) {
this.newUserNotifier = newUserNotifier;
this.dbClient = dbClient;
this.userIndexer = userIndexer;
- this.defaultOrganizationProvider = defaultOrganizationProvider;
this.defaultGroupFinder = defaultGroupFinder;
this.config = config;
this.localAuthentication = localAuthentication;
@@ -120,7 +115,7 @@ public class UserUpdater {
setOnboarded(reactivatedUser);
updateDto(dbSession, updateUser, reactivatedUser);
updateUser(dbSession, reactivatedUser);
- addUserToDefaultOrganizationAndDefaultGroup(dbSession, reactivatedUser);
+ addUserToDefaultGroup(dbSession, reactivatedUser);
}
public void updateAndCommit(DbSession dbSession, UserDto dto, UpdateUser updateUser, Consumer<UserDto> beforeCommit, UserDto... otherUsersToIndex) {
@@ -416,7 +411,7 @@ public class UserUpdater {
private UserDto saveUser(DbSession dbSession, UserDto userDto) {
userDto.setActive(true);
UserDto res = dbClient.userDao().insert(dbSession, userDto);
- addUserToDefaultOrganizationAndDefaultGroup(dbSession, userDto);
+ addUserToDefaultGroup(dbSession, userDto);
return res;
}
@@ -437,16 +432,10 @@ public class UserUpdater {
return userGroups.stream().anyMatch(group -> defaultGroup.getUuid().equals(group.getUuid()));
}
- private void addUserToDefaultOrganizationAndDefaultGroup(DbSession dbSession, UserDto userDto) {
- addUserToDefaultOrganization(dbSession, userDto);
+ private void addUserToDefaultGroup(DbSession dbSession, UserDto userDto) {
addDefaultGroup(dbSession, userDto);
}
- private void addUserToDefaultOrganization(DbSession dbSession, UserDto userDto) {
- String defOrgUuid = defaultOrganizationProvider.get().getUuid();
- dbClient.organizationMemberDao().insert(dbSession, new OrganizationMemberDto().setOrganizationUuid(defOrgUuid).setUserUuid(userDto.getUuid()));
- }
-
private void addDefaultGroup(DbSession dbSession, UserDto userDto) {
List<GroupDto> userGroups = dbClient.groupDao().selectByUserLogin(dbSession, userDto.getLogin());
GroupDto defaultGroup = defaultGroupFinder.findDefaultGroup(dbSession);
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java
index c97df1924a5..c5daa4ab305 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java
@@ -40,8 +40,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.authentication.event.AuthenticationEvent;
import org.sonar.server.authentication.event.AuthenticationEvent.Source;
import org.sonar.server.es.EsTester;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.user.NewUserNotifier;
import org.sonar.server.user.UserUpdater;
import org.sonar.server.user.index.UserIndexer;
@@ -63,7 +61,7 @@ import static org.sonar.server.authentication.event.AuthenticationExceptionMatch
public class HttpHeadersAuthenticationTest {
- private MapSettings settings = new MapSettings();
+ private final MapSettings settings = new MapSettings();
@Rule
public ExpectedException expectedException = none();
@@ -93,24 +91,20 @@ public class HttpHeadersAuthenticationTest {
private GroupDto group2;
private GroupDto sonarUsers;
- private System2 system2 = mock(System2.class);
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+ private final System2 system2 = mock(System2.class);
+ private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
- private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
+ private final UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
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, defaultGroupFinder, settings.asConfig(),
- localAuthentication),
+ private final UserRegistrarImpl userIdentityAuthenticator = new UserRegistrarImpl(db.getDbClient(),
+ new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), userIndexer, defaultGroupFinder, settings.asConfig(), localAuthentication),
defaultGroupFinder);
-
- private HttpServletResponse response = mock(HttpServletResponse.class);
- private JwtHttpHandler jwtHttpHandler = mock(JwtHttpHandler.class);
- private AuthenticationEvent authenticationEvent = mock(AuthenticationEvent.class);
-
- private HttpHeadersAuthentication underTest = new HttpHeadersAuthentication(system2, settings.asConfig(), userIdentityAuthenticator, jwtHttpHandler, authenticationEvent);
+ private final HttpServletResponse response = mock(HttpServletResponse.class);
+ private final JwtHttpHandler jwtHttpHandler = mock(JwtHttpHandler.class);
+ private final AuthenticationEvent authenticationEvent = mock(AuthenticationEvent.class);
+ private final HttpHeadersAuthentication underTest = new HttpHeadersAuthentication(system2, settings.asConfig(), userIdentityAuthenticator, jwtHttpHandler,
+ authenticationEvent);
@Before
public void setUp() {
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
index f73873bc814..438361bd358 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
@@ -37,8 +37,6 @@ import org.sonar.server.authentication.event.AuthenticationEvent;
import org.sonar.server.authentication.event.AuthenticationEvent.Source;
import org.sonar.server.authentication.exception.EmailAlreadyExistsRedirectionException;
import org.sonar.server.es.EsTester;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.user.NewUserNotifier;
import org.sonar.server.user.UserUpdater;
import org.sonar.server.user.index.UserIndexer;
@@ -54,22 +52,22 @@ import static org.sonar.server.authentication.event.AuthenticationEvent.Method.B
import static org.sonar.server.authentication.event.AuthenticationExceptionMatcher.authenticationException;
public class UserRegistrarImplTest {
- private static String USER_LOGIN = "johndoo";
+ private static final String USER_LOGIN = "johndoo";
- private static UserIdentity USER_IDENTITY = UserIdentity.builder()
+ private static final UserIdentity USER_IDENTITY = UserIdentity.builder()
.setProviderId("ABCD")
.setProviderLogin("johndoo")
.setName("John")
.setEmail("john@email.com")
.build();
- private static TestIdentityProvider IDENTITY_PROVIDER = new TestIdentityProvider()
+ private static final TestIdentityProvider IDENTITY_PROVIDER = new TestIdentityProvider()
.setKey("github")
.setName("name of github")
.setEnabled(true)
.setAllowsUsersToSignUp(true);
- private MapSettings settings = new MapSettings();
+ private final MapSettings settings = new MapSettings();
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -77,20 +75,18 @@ public class UserRegistrarImplTest {
public DbTester db = DbTester.create(new AlwaysIncreasingSystem2());
@Rule
public EsTester es = EsTester.create();
- private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+ private final UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
+ private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
private final DefaultGroupFinder groupFinder = new DefaultGroupFinder(db.getDbClient());
- private UserUpdater userUpdater = new UserUpdater(
+ private final UserUpdater userUpdater = new UserUpdater(
mock(NewUserNotifier.class),
db.getDbClient(),
userIndexer,
- defaultOrganizationProvider,
groupFinder,
settings.asConfig(),
localAuthentication);
- private UserRegistrarImpl underTest = new UserRegistrarImpl(db.getDbClient(), userUpdater, groupFinder);
+ private final UserRegistrarImpl underTest = new UserRegistrarImpl(db.getDbClient(), userUpdater, groupFinder);
private GroupDto defaultGroup;
@Before
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java
index 897f737c37f..b2c279063ef 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java
@@ -41,8 +41,6 @@ import org.sonar.server.authentication.CredentialsLocalAuthentication;
import org.sonar.server.authentication.CredentialsLocalAuthentication.HashMethod;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.user.index.UserIndexDefinition;
import org.sonar.server.user.index.UserIndexer;
import org.sonar.server.usergroups.DefaultGroupFinder;
@@ -62,7 +60,7 @@ public class UserUpdaterCreateTest {
private static final String DEFAULT_LOGIN = "marius";
- private System2 system2 = new AlwaysIncreasingSystem2();
+ private final System2 system2 = new AlwaysIncreasingSystem2();
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -71,16 +69,14 @@ public class UserUpdaterCreateTest {
@Rule
public DbTester db = DbTester.create(system2);
- private DbClient dbClient = db.getDbClient();
- private NewUserNotifier newUserNotifier = mock(NewUserNotifier.class);
- private ArgumentCaptor<NewUserHandler.Context> newUserHandler = ArgumentCaptor.forClass(NewUserHandler.Context.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,
+ private final DbClient dbClient = db.getDbClient();
+ private final NewUserNotifier newUserNotifier = mock(NewUserNotifier.class);
+ private final ArgumentCaptor<NewUserHandler.Context> newUserHandler = ArgumentCaptor.forClass(NewUserHandler.Context.class);
+ private final DbSession session = db.getSession();
+ private final UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
+ private final MapSettings settings = new MapSettings();
+ private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+ private final UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer,
new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication);
@Test
@@ -300,7 +296,7 @@ public class UserUpdaterCreateTest {
}
@Test
- public void does_not_set_notifications_readDate_setting_when_creating_user_when_not_on_and_organization_disabled() {
+ public void does_not_set_notifications_readDate_setting_when_creating_user_when_not_on() {
createDefaultGroup();
UserDto user = underTest.createAndCommit(db.getSession(), NewUser.builder()
@@ -589,21 +585,6 @@ public class UserUpdaterCreateTest {
});
}
- @Test
- public void add_user_as_member_of_default_organization_when_creating_user_and_organizations_are_disabled() {
- createDefaultGroup();
-
- UserDto dto = underTest.createAndCommit(db.getSession(), NewUser.builder()
- .setLogin("user")
- .setName("User")
- .setEmail("user@mail.com")
- .setPassword("PASSWORD")
- .build(), u -> {
- });
-
- assertThat(dbClient.organizationMemberDao().select(db.getSession(), defaultOrganizationProvider.get().getUuid(), dto.getUuid())).isPresent();
- }
-
private GroupDto createDefaultGroup() {
return db.users().insertDefaultGroup();
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java
index f64f25069a8..98ba2cac36c 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java
@@ -35,8 +35,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.authentication.CredentialsLocalAuthentication;
import org.sonar.server.authentication.CredentialsLocalAuthentication.HashMethod;
import org.sonar.server.es.EsTester;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.user.index.UserIndexer;
import org.sonar.server.usergroups.DefaultGroupFinder;
@@ -61,10 +59,9 @@ public class UserUpdaterReactivateTest {
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,
+ private final UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer,
new DefaultGroupFinder(dbClient),
settings.asConfig(), localAuthentication);
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java
index 63995f29ce7..f195d3d4ca4 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java
@@ -39,8 +39,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.authentication.CredentialsLocalAuthentication;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.user.index.UserIndexDefinition;
import org.sonar.server.user.index.UserIndexer;
import org.sonar.server.usergroups.DefaultGroupFinder;
@@ -63,21 +61,20 @@ public class UserUpdaterUpdateTest {
private static final Consumer<UserDto> EMPTY_USER_CONSUMER = userDto -> {
};
- private System2 system2 = new AlwaysIncreasingSystem2();
+ private final System2 system2 = new AlwaysIncreasingSystem2();
@Rule
public EsTester es = EsTester.create();
@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,
+ 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 MapSettings settings = new MapSettings();
+ private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+ private final UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer,
new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication);
@Test
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java
index 514981585cc..c044754a4a0 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java
@@ -45,6 +45,8 @@ import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_ORGA
import static org.sonar.server.ws.KeyExamples.KEY_ORG_EXAMPLE_001;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
+//TODO remove when getting rid of organizations
+@Deprecated
public class AddMemberAction implements OrganizationsWsAction {
private final DbClient dbClient;
private final UserSession userSession;
@@ -96,7 +98,7 @@ public class AddMemberAction implements OrganizationsWsAction {
userSession.checkPermission(GlobalPermission.ADMINISTER);
wsSupport.checkMemberSyncIsDisabled(dbSession, organization);
UserDto user = checkFound(dbClient.userDao().selectByLogin(dbSession, login), "User '%s' is not found", login);
- memberUpdater.addMember(dbSession, organization, user);
+ memberUpdater.addMember(dbSession, user);
int groups = dbClient.groupMembershipDao().countGroups(dbSession, GroupMembershipQuery.builder().membership(IN).build(), user.getUuid());
AddMemberWsResponse wsResponse = buildResponse(user, groups);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java
index fe2e4e5d92a..ce8eece577c 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java
@@ -24,16 +24,13 @@ import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.ServerSide;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.permission.GlobalPermission;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.user.UserSession;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static org.sonar.server.exceptions.BadRequestException.checkRequest;
import static org.sonar.server.exceptions.NotFoundException.checkFound;
@@ -45,18 +42,10 @@ public class QProfileWsSupport {
private final DbClient dbClient;
private final UserSession userSession;
- private final DefaultOrganizationProvider defaultOrganizationProvider;
- public QProfileWsSupport(DbClient dbClient, UserSession userSession, DefaultOrganizationProvider defaultOrganizationProvider) {
+ public QProfileWsSupport(DbClient dbClient, UserSession userSession) {
this.dbClient = dbClient;
this.userSession = userSession;
- this.defaultOrganizationProvider = defaultOrganizationProvider;
- }
-
- public OrganizationDto getDefaultOrganization(DbSession dbSession) {
- String organizationOrDefaultKey = defaultOrganizationProvider.get().getKey();
- return checkFoundWithOptional(dbClient.organizationDao().selectByKey(dbSession, organizationOrDefaultKey),
- "No organization with key '%s'", organizationOrDefaultKey);
}
public RuleDefinitionDto getRule(DbSession dbSession, RuleKey ruleKey) {
@@ -92,7 +81,6 @@ public class QProfileWsSupport {
public UserDto getUser(DbSession dbSession, String login) {
UserDto user = dbClient.userDao().selectActiveUserByLogin(dbSession, login);
checkFound(user, "User with login '%s' is not found'", login);
- checkMembership(dbSession, getDefaultOrganization(dbSession), user);
return user;
}
@@ -126,12 +114,4 @@ public class QProfileWsSupport {
void checkNotBuiltIn(QProfileDto profile) {
checkRequest(!profile.isBuiltIn(), "Operation forbidden for built-in Quality Profile '%s' with language '%s'", profile.getName(), profile.getLanguage());
}
-
- private void checkMembership(DbSession dbSession, OrganizationDto organization, UserDto user) {
- checkArgument(isMember(dbSession, organization, user.getUuid()), "User '%s' is not member of organization '%s'", user.getLogin(), organization.getKey());
- }
-
- private boolean isMember(DbSession dbSession, OrganizationDto organization, String userUuid) {
- return dbClient.organizationMemberDao().select(dbSession, organization.getUuid(), userUuid).isPresent();
- }
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java
index 402a2be68d9..da2bc3ee57b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DeactivateAction.java
@@ -92,7 +92,6 @@ public class DeactivateAction implements UsersWsAction {
dbClient.userPermissionDao().deleteByUserUuid(dbSession, userUuid);
dbClient.permissionTemplateDao().deleteUserPermissionsByUserUuid(dbSession, userUuid);
dbClient.qProfileEditUsersDao().deleteByUser(dbSession, user);
- dbClient.organizationMemberDao().deleteByUserUuid(dbSession, userUuid);
dbClient.userPropertiesDao().deleteByUser(dbSession, user);
dbClient.almPatDao().deleteByUser(dbSession, user);
dbClient.sessionTokensDao().deleteByUser(dbSession, user);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java
index cb18e7d7b0e..e07057725f0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java
@@ -41,7 +41,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileRules;
import org.sonar.server.qualityprofile.RuleActivation;
import org.sonar.server.tester.UserSessionRule;
@@ -71,7 +70,7 @@ public class ActivateRuleActionTest {
private ArgumentCaptor<Collection<RuleActivation>> ruleActivationCaptor = ArgumentCaptor.forClass(Collection.class);
private DbClient dbClient = db.getDbClient();
private QProfileRules qProfileRules = mock(QProfileRules.class);
- private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession);
private WsActionTester ws = new WsActionTester(new ActivateRuleAction(dbClient, qProfileRules, userSession, wsSupport));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java
index f82e13b1373..5fb445e6d53 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java
@@ -34,7 +34,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileRules;
import org.sonar.server.rule.ws.RuleQueryFactory;
import org.sonar.server.tester.UserSessionRule;
@@ -60,7 +59,7 @@ public class ActivateRulesActionTest {
public ExpectedException expectedException = ExpectedException.none();
private DbClient dbClient = db.getDbClient();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession);
private RuleQueryFactory ruleQueryFactory = mock(RuleQueryFactory.class, Mockito.RETURNS_MOCKS);
private QProfileRules qProfileRules = mock(QProfileRules.class, Mockito.RETURNS_DEEP_STUBS);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java
index 896f4d8e655..3c4e0549aa1 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java
@@ -36,7 +36,6 @@ import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
@@ -59,7 +58,7 @@ public class AddGroupActionTest {
@Rule
public DbTester db = DbTester.create();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private UuidFactory uuidFactory = UuidFactoryFast.getInstance();
private WsActionTester ws = new WsActionTester(new AddGroupAction(db.getDbClient(), uuidFactory, wsSupport, LANGUAGES));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java
index 112f4c2e754..8b7aa5a1505 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java
@@ -38,7 +38,6 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.TestResponse;
@@ -62,7 +61,7 @@ public class AddProjectActionTest {
private DbClient dbClient = db.getDbClient();
private Languages languages = LanguageTesting.newLanguages(LANGUAGE_1, LANGUAGE_2);
- private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
+ private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession);
private AddProjectAction underTest = new AddProjectAction(dbClient, userSession, languages, TestComponentFinder.from(db), wsSupport);
private WsActionTester tester = new WsActionTester(underTest);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java
index c36a555fb3a..93ba68ee5b8 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java
@@ -35,7 +35,6 @@ import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
@@ -59,7 +58,7 @@ public class AddUserActionTest {
@Rule
public DbTester db = DbTester.create();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db));
+ private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private UuidFactory uuidFactory = UuidFactoryFast.getInstance();
private WsActionTester ws = new WsActionTester(new AddUserAction(db.getDbClient(), uuidFactory, wsSupport, LANGUAGES));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java
index ff66282af44..340394bc72d 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java
@@ -27,8 +27,6 @@ import org.sonar.api.server.ws.WebService.Param;
import org.sonar.db.DbTester;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileBackuper;
import org.sonar.server.qualityprofile.QProfileBackuperImpl;
import org.sonar.server.qualityprofile.QProfileParser;
@@ -50,8 +48,7 @@ public class BackupActionTest {
public UserSessionRule userSession = UserSessionRule.standalone();
private QProfileBackuper backuper = new QProfileBackuperImpl(db.getDbClient(), null, null, null, new QProfileParser());
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, defaultOrganizationProvider);
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private Languages languages = LanguageTesting.newLanguages(A_LANGUAGE);
private WsActionTester tester = new WsActionTester(new BackupAction(db.getDbClient(), backuper, wsSupport, languages));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
index 36824bb6093..59f80628c29 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
@@ -49,7 +49,6 @@ import org.sonar.server.es.SearchOptions;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileTreeImpl;
import org.sonar.server.qualityprofile.RuleActivator;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
@@ -108,8 +107,7 @@ public class ChangeParentActionTest {
new Languages(),
new QProfileWsSupport(
dbClient,
- userSession,
- TestDefaultOrganizationProvider.from(db)),
+ userSession),
userSession);
ws = new WsActionTester(underTest);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
index 6ef77454d93..cd800af8792 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
@@ -37,8 +37,6 @@ import org.sonar.db.qualityprofile.QProfileChangeDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.ActiveRuleChange;
import org.sonar.server.qualityprofile.ActiveRuleInheritance;
import org.sonar.server.tester.UserSessionRule;
@@ -63,7 +61,7 @@ public class ChangelogActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db));
+ private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private WsActionTester ws = new WsActionTester(new ChangelogAction(wsSupport, new Languages(), db.getDbClient()));
@Test
@@ -232,16 +230,16 @@ public class ChangelogActionTest {
.setParam(PARAM_SINCE, "2011-04-25T01:15:42+0100")
.execute()
.getInput()).isSimilarTo("{\n" +
- " \"events\": [\n" +
- " {\n" +
- " \"date\": \"2011-04-25T01:15:42+0100\",\n" +
- " \"authorLogin\": \"" + user.getLogin() + "\",\n" +
- " \"action\": \"ACTIVATED\",\n" +
- " \"ruleKey\": \"" + rule.getKey() + "\",\n" +
- " \"ruleName\": \"" + rule.getName() + "\",\n" +
- " }\n" +
- " ]\n" +
- "}");
+ " \"events\": [\n" +
+ " {\n" +
+ " \"date\": \"2011-04-25T01:15:42+0100\",\n" +
+ " \"authorLogin\": \"" + user.getLogin() + "\",\n" +
+ " \"action\": \"ACTIVATED\",\n" +
+ " \"ruleKey\": \"" + rule.getKey() + "\",\n" +
+ " \"ruleName\": \"" + rule.getName() + "\",\n" +
+ " }\n" +
+ " ]\n" +
+ "}");
assertJson(ws.newRequest()
.setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
@@ -249,8 +247,8 @@ public class ChangelogActionTest {
.setParam(PARAM_SINCE, "2011-04-25T01:15:43+0100")
.execute()
.getInput()).isSimilarTo("{\n" +
- " \"events\": []\n" +
- "}");
+ " \"events\": []\n" +
+ "}");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java
index b4ffa852c7c..8b0ef3fb3df 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java
@@ -37,8 +37,6 @@ import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileBackuper;
import org.sonar.server.qualityprofile.QProfileCopier;
import org.sonar.server.qualityprofile.QProfileFactory;
@@ -66,15 +64,14 @@ public class CopyActionTest {
public UserSessionRule userSession = UserSessionRule.standalone();
@Rule
public JUnitTempFolder tempDir = new JUnitTempFolder();
- private ActiveRuleIndexer activeRuleIndexer = mock(ActiveRuleIndexer.class);
- private TestBackuper backuper = new TestBackuper();
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private QProfileFactory profileFactory = new QProfileFactoryImpl(db.getDbClient(), new SequenceUuidFactory(), System2.INSTANCE, activeRuleIndexer);
- private QProfileCopier profileCopier = new QProfileCopier(db.getDbClient(), profileFactory, backuper);
- private Languages languages = LanguageTesting.newLanguages(A_LANGUAGE);
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, defaultOrganizationProvider);
- private CopyAction underTest = new CopyAction(db.getDbClient(), profileCopier, languages, userSession, wsSupport);
- private WsActionTester tester = new WsActionTester(underTest);
+ private final ActiveRuleIndexer activeRuleIndexer = mock(ActiveRuleIndexer.class);
+ private final TestBackuper backuper = new TestBackuper();
+ private final QProfileFactory profileFactory = new QProfileFactoryImpl(db.getDbClient(), new SequenceUuidFactory(), System2.INSTANCE, activeRuleIndexer);
+ private final QProfileCopier profileCopier = new QProfileCopier(db.getDbClient(), profileFactory, backuper);
+ private final Languages languages = LanguageTesting.newLanguages(A_LANGUAGE);
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
+ private final CopyAction underTest = new CopyAction(db.getDbClient(), profileCopier, languages, userSession, wsSupport);
+ private final WsActionTester tester = new WsActionTester(underTest);
@Test
public void test_definition() {
@@ -295,7 +292,8 @@ public class CopyActionTest {
throw new UnsupportedOperationException();
}
- @Override public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) {
+ @Override
+ public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) {
this.copiedProfile = from;
this.toProfile = to;
return null;
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java
index 9b4c64f02e0..78a907c4338 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java
@@ -39,7 +39,6 @@ import org.sonar.db.rule.RuleTesting;
import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileRules;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
@@ -67,7 +66,7 @@ public class DeactivateRuleActionTest {
private ArgumentCaptor<Collection<String>> ruleUuidsCaptor = ArgumentCaptor.forClass(Collection.class);
private DbClient dbClient = db.getDbClient();
private QProfileRules qProfileRules = mock(QProfileRules.class);
- private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession);
private DeactivateRuleAction underTest = new DeactivateRuleAction(dbClient, qProfileRules, userSession, wsSupport);
private WsActionTester ws = new WsActionTester(underTest);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java
index 3d90ac7226a..217d6d1b289 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java
@@ -31,7 +31,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileRules;
import org.sonar.server.rule.ws.RuleQueryFactory;
import org.sonar.server.tester.UserSessionRule;
@@ -60,7 +59,7 @@ public class DeactivateRulesActionTest {
private DbClient dbClient = db.getDbClient();
private QProfileRules qProfileRules = mock(QProfileRules.class, RETURNS_DEEP_STUBS);
- private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession);
private RuleQueryFactory ruleQueryFactory = mock(RuleQueryFactory.class, RETURNS_DEEP_STUBS);
private DeactivateRulesAction underTest = new DeactivateRulesAction(ruleQueryFactory, userSession, qProfileRules, wsSupport, dbClient);
private WsActionTester ws = new WsActionTester(underTest);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java
index d8482f295d3..85f27004939 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java
@@ -39,7 +39,6 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileFactoryImpl;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
import org.sonar.server.tester.UserSessionRule;
@@ -71,7 +70,7 @@ public class DeleteActionTest {
private DeleteAction underTest = new DeleteAction(
new Languages(LanguageTesting.newLanguage(A_LANGUAGE)),
new QProfileFactoryImpl(dbClient, UuidFactoryFast.getInstance(), System2.INSTANCE, activeRuleIndexer), dbClient, userSession,
- new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db)));
+ new QProfileWsSupport(dbClient, userSession));
private WsActionTester ws = new WsActionTester(underTest);
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
index 8e47d987fe1..92aa1e75a7e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
@@ -42,7 +42,6 @@ import org.sonar.db.rule.RuleTesting;
import org.sonar.server.es.EsClient;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileRules;
import org.sonar.server.qualityprofile.QProfileRulesImpl;
import org.sonar.server.qualityprofile.QProfileTree;
@@ -89,7 +88,7 @@ public class InheritanceActionTest {
private WsActionTester ws = new WsActionTester(new InheritanceAction(
dbClient,
- new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db)),
+ new QProfileWsSupport(dbClient, userSession),
new Languages()));
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java
index 8bace09eaf8..df6615c65bc 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java
@@ -28,8 +28,6 @@ import org.sonar.db.qualityprofile.QualityProfileTesting;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import static java.lang.String.format;
@@ -44,8 +42,7 @@ public class QProfileWsSupportTest {
@Rule
public UserSessionRule userSession = UserSessionRule.standalone();
- private DefaultOrganizationProvider defaultOrgProvider = TestDefaultOrganizationProvider.from(db);
- private QProfileWsSupport underTest = new QProfileWsSupport(db.getDbClient(), userSession, defaultOrgProvider);
+ private final QProfileWsSupport underTest = new QProfileWsSupport(db.getDbClient(), userSession);
@Test
public void getProfile_returns_the_profile_specified_by_key() {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
index 16e3dfd4fc8..ea77a357e52 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
@@ -22,7 +22,6 @@ package org.sonar.server.qualityprofile.ws;
import com.google.common.collect.ImmutableSet;
import java.util.Collections;
import java.util.Optional;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.rule.RuleKey;
@@ -33,7 +32,6 @@ import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.qualityprofile.QProfileDto;
@@ -42,8 +40,6 @@ import org.sonar.db.rule.RuleTesting;
import org.sonar.server.es.EsTester;
import org.sonar.server.es.SearchOptions;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileName;
import org.sonar.server.qualityprofile.QProfileRules;
import org.sonar.server.qualityprofile.QProfileRulesImpl;
@@ -88,20 +84,13 @@ public class QProfilesWsMediumTest {
private TypeValidations typeValidations = new TypeValidations(emptyList());
private RuleActivator ruleActivator = new RuleActivator(System2.INSTANCE, dbClient, typeValidations, userSessionRule);
private QProfileRules qProfileRules = new QProfileRulesImpl(dbClient, ruleActivator, ruleIndex, activeRuleIndexer);
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(dbTester);
- private QProfileWsSupport qProfileWsSupport = new QProfileWsSupport(dbClient, userSessionRule, defaultOrganizationProvider);
- private RuleQueryFactory ruleQueryFactory = new RuleQueryFactory(dbClient);
- private OrganizationDto organization;
-
- private WsActionTester wsDeactivateRule = new WsActionTester(new DeactivateRuleAction(dbClient, qProfileRules, userSessionRule, qProfileWsSupport));
- private WsActionTester wsDeactivateRules = new WsActionTester(new DeactivateRulesAction(ruleQueryFactory, userSessionRule, qProfileRules, qProfileWsSupport, dbClient));
- private WsActionTester wsActivateRule = new WsActionTester(new ActivateRuleAction(dbClient, qProfileRules, userSessionRule, qProfileWsSupport));
- private WsActionTester wsActivateRules = new WsActionTester(new ActivateRulesAction(ruleQueryFactory, userSessionRule, qProfileRules, qProfileWsSupport, dbClient));
-
- @Before
- public void setUp() {
- organization = dbTester.organizations().insert();
- }
+ private final QProfileWsSupport qProfileWsSupport = new QProfileWsSupport(dbClient, userSessionRule);
+ private final RuleQueryFactory ruleQueryFactory = new RuleQueryFactory(dbClient);
+
+ private final WsActionTester wsDeactivateRule = new WsActionTester(new DeactivateRuleAction(dbClient, qProfileRules, userSessionRule, qProfileWsSupport));
+ private final WsActionTester wsDeactivateRules = new WsActionTester(new DeactivateRulesAction(ruleQueryFactory, userSessionRule, qProfileRules, qProfileWsSupport, dbClient));
+ private final WsActionTester wsActivateRule = new WsActionTester(new ActivateRuleAction(dbClient, qProfileRules, userSessionRule, qProfileWsSupport));
+ private final WsActionTester wsActivateRules = new WsActionTester(new ActivateRulesAction(ruleQueryFactory, userSessionRule, qProfileRules, qProfileWsSupport, dbClient));
@Test
public void deactivate_rule() {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java
index 3f977a4150a..85fc13c707c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java
@@ -33,7 +33,6 @@ import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
@@ -56,7 +55,7 @@ public class RemoveGroupActionTest {
@Rule
public DbTester db = DbTester.create();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private WsActionTester ws = new WsActionTester(new RemoveGroupAction(db.getDbClient(), wsSupport, LANGUAGES));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
index 5a9658a68ac..046269a7b5f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java
@@ -39,7 +39,6 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.TestResponse;
@@ -62,7 +61,7 @@ public class RemoveProjectActionTest {
private DbClient dbClient = db.getDbClient();
private Languages languages = LanguageTesting.newLanguages(LANGUAGE_1, LANGUAGE_2);
- private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession);
private RemoveProjectAction underTest = new RemoveProjectAction(dbClient, userSession, languages,
new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)), wsSupport);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java
index 7155fdc6a51..efb6b5f8a30 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java
@@ -33,7 +33,6 @@ import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
@@ -57,7 +56,7 @@ public class RemoveUserActionTest {
@Rule
public DbTester db = DbTester.create();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db));
+ private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private WsActionTester ws = new WsActionTester(new RemoveUserAction(db.getDbClient(), wsSupport, LANGUAGES));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java
index a03220b768f..13479a45d91 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java
@@ -29,7 +29,6 @@ import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.qualityprofile.QualityProfileTesting;
import org.sonar.db.user.UserDto;
@@ -37,7 +36,6 @@ import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
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.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
@@ -62,16 +60,13 @@ public class RenameActionTest {
private String xoo1Key = "xoo1";
private String xoo2Key = "xoo2";
- private OrganizationDto organization;
@Before
public void setUp() {
- TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, defaultOrganizationProvider);
+ QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession);
RenameAction underTest = new RenameAction(dbClient, userSession, wsSupport);
ws = new WsActionTester(underTest);
- organization = db.organizations().getDefaultOrganization();
createProfiles();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java
index 5418bf2e246..319cc795a37 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java
@@ -32,7 +32,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse;
@@ -63,7 +62,7 @@ public class SearchGroupsActionTest {
@Rule
public DbTester db = DbTester.create();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private WsActionTester ws = new WsActionTester(new SearchGroupsAction(db.getDbClient(), wsSupport, LANGUAGES));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java
index 25060043424..0e8a5abbcc6 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java
@@ -35,7 +35,6 @@ import org.sonar.server.issue.AvatarResolver;
import org.sonar.server.issue.AvatarResolverImpl;
import org.sonar.server.issue.FakeAvatarResolver;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Qualityprofiles.SearchUsersResponse;
@@ -66,7 +65,7 @@ public class SearchUsersActionTest {
@Rule
public DbTester db = DbTester.create();
- private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db));
+ private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession);
private AvatarResolver avatarResolver = new FakeAvatarResolver();
private WsActionTester ws = new WsActionTester(new SearchUsersAction(db.getDbClient(), wsSupport, LANGUAGES, avatarResolver));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java
index 731db2f1966..7b7ef93bd13 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java
@@ -28,15 +28,12 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.qualityprofile.QualityProfileTesting;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.language.LanguageTesting;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
@@ -59,14 +56,12 @@ public class SetDefaultActionTest {
@Rule
public UserSessionRule userSessionRule = UserSessionRule.standalone();
- private DefaultOrganizationProvider defaultOrganizationProvider;
private DbClient dbClient;
private QProfileWsSupport wsSupport;
private SetDefaultAction underTest;
private WsActionTester ws;
- private OrganizationDto organization;
/** Single, default quality profile for language xoo1 */
private QProfileDto xoo1Profile;
/** Parent quality profile for language xoo2 (not a default) */
@@ -76,10 +71,8 @@ public class SetDefaultActionTest {
@Before
public void setUp() {
- defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
dbClient = db.getDbClient();
- wsSupport = new QProfileWsSupport(dbClient, userSessionRule, defaultOrganizationProvider);
- organization = db.organizations().getDefaultOrganization();
+ wsSupport = new QProfileWsSupport(dbClient, userSessionRule);
underTest = new SetDefaultAction(LanguageTesting.newLanguages(XOO_1_KEY, XOO_2_KEY), dbClient, userSessionRule, wsSupport);
xoo1Profile = QualityProfileTesting.newQualityProfileDto().setLanguage(XOO_1_KEY);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
index bc1ad771512..c4b615ab451 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
@@ -34,7 +34,6 @@ import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleIndexer;
@@ -75,7 +74,7 @@ public class ShowActionTest {
private RuleIndex ruleIndex = new RuleIndex(es.client(), System2.INSTANCE);
private WsActionTester ws = new WsActionTester(
- new ShowAction(db.getDbClient(), new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db)), LANGUAGES, ruleIndex));
+ new ShowAction(db.getDbClient(), new QProfileWsSupport(db.getDbClient(), userSession), LANGUAGES, ruleIndex));
@Test
public void profile_info() {
@@ -172,7 +171,7 @@ public class ShowActionTest {
CompareToSonarWay result = call(ws.newRequest()
.setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
- .getCompareToSonarWay();
+ .getCompareToSonarWay();
assertThat(result)
.extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount)
@@ -192,7 +191,7 @@ public class ShowActionTest {
CompareToSonarWay result = call(ws.newRequest()
.setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
- .getCompareToSonarWay();
+ .getCompareToSonarWay();
assertThat(result)
.extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount)
@@ -255,7 +254,7 @@ public class ShowActionTest {
CompareToSonarWay result = call(ws.newRequest()
.setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
- .getCompareToSonarWay();
+ .getCompareToSonarWay();
assertThat(result)
.extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName)
@@ -271,7 +270,7 @@ public class ShowActionTest {
CompareToSonarWay result = call(ws.newRequest()
.setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
- .getCompareToSonarWay();
+ .getCompareToSonarWay();
assertThat(result)
.extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName)
@@ -335,7 +334,7 @@ public class ShowActionTest {
.forEach(project -> db.qualityProfiles().associateWithProject(project, profile));
ws = new WsActionTester(
- new ShowAction(db.getDbClient(), new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db)), new Languages(cs), ruleIndex));
+ new ShowAction(db.getDbClient(), new QProfileWsSupport(db.getDbClient(), userSession), new Languages(cs), ruleIndex));
String result = ws.newRequest().setParam(PARAM_KEY, profile.getKee()).execute().getInput();
assertJson(result).ignoreFields("rulesUpdatedAt", "lastUsed", "userUpdatedAt").isSimilarTo(ws.getDef().responseExampleAsString());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
index 9b8dbc14ba5..2be63c68326 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
@@ -31,7 +31,6 @@ import org.sonar.server.es.EsTester;
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.user.NewUserNotifier;
import org.sonar.server.user.UserUpdater;
@@ -56,17 +55,13 @@ public class ChangePasswordActionTest {
@Rule
public UserSessionRule userSessionRule = UserSessionRule.standalone().logIn();
- private TestDefaultOrganizationProvider testDefaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
+ private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
- private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+ private final UserUpdater userUpdater = new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(),
+ new UserIndexer(db.getDbClient(), es.client()), new DefaultGroupFinder(db.getDbClient()),
+ new MapSettings().asConfig(), localAuthentication);
- private UserUpdater userUpdater = new UserUpdater(
- mock(NewUserNotifier.class), db.getDbClient(), new UserIndexer(db.getDbClient(), es.client()), testDefaultOrganizationProvider,
- new DefaultGroupFinder(db.getDbClient()),
- new MapSettings().asConfig(),
- localAuthentication);
-
- private WsActionTester tester = new WsActionTester(new ChangePasswordAction(db.getDbClient(), userUpdater, userSessionRule, localAuthentication));
+ private final WsActionTester tester = new WsActionTester(new ChangePasswordAction(db.getDbClient(), userUpdater, userSessionRule, localAuthentication));
@Before
public void setUp() {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
index 4ecf507e701..93cc9c5a80b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
@@ -29,7 +29,6 @@ import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
-import org.sonar.core.config.CorePropertyDefinitions;
import org.sonar.db.DbTester;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
@@ -37,8 +36,6 @@ import org.sonar.server.authentication.CredentialsLocalAuthentication;
import org.sonar.server.es.EsClient;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.user.NewUserNotifier;
import org.sonar.server.user.UserUpdater;
@@ -66,8 +63,8 @@ import static org.sonar.server.user.index.UserIndexDefinition.FIELD_SCM_ACCOUNTS
public class CreateActionTest {
- private MapSettings settings = new MapSettings();
- private System2 system2 = new AlwaysIncreasingSystem2();
+ private final MapSettings settings = new MapSettings();
+ private final System2 system2 = new AlwaysIncreasingSystem2();
@Rule
public DbTester db = DbTester.create(system2);
@@ -78,15 +75,11 @@ public class CreateActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
+ private final UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
private GroupDto defaultGroup;
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
- private WsActionTester tester = new WsActionTester(new CreateAction(
- db.getDbClient(),
- new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), userIndexer, defaultOrganizationProvider,
- new DefaultGroupFinder(db.getDbClient()), settings.asConfig(), localAuthentication),
- userSessionRule));
+ private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+ private final WsActionTester tester = new WsActionTester(new CreateAction(db.getDbClient(), new UserUpdater(mock(NewUserNotifier.class),
+ db.getDbClient(), userIndexer, new DefaultGroupFinder(db.getDbClient()), settings.asConfig(), localAuthentication), userSessionRule));
@Before
public void setUp() {
@@ -124,7 +117,7 @@ public class CreateActionTest {
assertThat(dbUser).isPresent();
assertThat(dbUser.get().isRoot()).isFalse();
- // member of default group in default organization
+ // member of default group
assertThat(db.users().selectGroupUuidsOfUser(dbUser.get())).containsOnly(defaultGroup.getUuid());
}
@@ -376,8 +369,4 @@ public class CreateActionTest {
return request.executeProtobuf(CreateWsResponse.class);
}
- private void enableCreatePersonalOrg(boolean flag) {
- settings.setProperty(CorePropertyDefinitions.ORGANIZATIONS_CREATE_PERSONAL_ORG, flag);
- }
-
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionHomepageTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionHomepageTest.java
index 0c4fb688385..12f1ffef772 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionHomepageTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionHomepageTest.java
@@ -86,7 +86,7 @@ public class CurrentActionHomepageTest {
@UseDataProvider("enterpriseAndAbove")
public void return_homepage_when_set_to_a_portfolio(EditionProvider.Edition edition) {
setPlatformEdition(edition);
- ComponentDto portfolio = db.components().insertPrivatePortfolio(db.getDefaultOrganization());
+ ComponentDto portfolio = db.components().insertPrivatePortfolio();
UserDto user = db.users().insertUser(u -> u.setHomepageType("PORTFOLIO").setHomepageParameter(portfolio.uuid()));
userSessionRule.logIn(user).addProjectPermission(USER, portfolio);
@@ -101,7 +101,7 @@ public class CurrentActionHomepageTest {
@UseDataProvider("enterpriseAndAbove")
public void return_default_when_set_to_a_portfolio_but_no_rights_on_this_portfolio(EditionProvider.Edition edition) {
setPlatformEdition(edition);
- ComponentDto portfolio = db.components().insertPrivatePortfolio(db.getDefaultOrganization());
+ ComponentDto portfolio = db.components().insertPrivatePortfolio();
UserDto user = db.users().insertUser(u -> u.setHomepageType("PORTFOLIO").setHomepageParameter(portfolio.uuid()));
userSessionRule.logIn(user);
@@ -116,7 +116,7 @@ public class CurrentActionHomepageTest {
@UseDataProvider("enterpriseAndAbove")
public void return_homepage_when_set_to_an_application(EditionProvider.Edition edition) {
setPlatformEdition(edition);
- ComponentDto application = db.components().insertPrivateApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPrivateApplication();
UserDto user = db.users().insertUser(u -> u.setHomepageType("APPLICATION").setHomepageParameter(application.uuid()));
userSessionRule.logIn(user).addProjectPermission(USER, application);
@@ -131,7 +131,7 @@ public class CurrentActionHomepageTest {
@UseDataProvider("enterpriseAndAbove")
public void return_default_homepage_when_set_to_an_application_but_no_rights_on_this_application(EditionProvider.Edition edition) {
setPlatformEdition(edition);
- ComponentDto application = db.components().insertPrivateApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPrivateApplication();
UserDto user = db.users().insertUser(u -> u.setHomepageType("APPLICATION").setHomepageParameter(application.uuid()));
userSessionRule.logIn(user);
@@ -211,7 +211,7 @@ public class CurrentActionHomepageTest {
@Test
public void fallback_when_edition_is_null() {
setPlatformEdition(null);
- ComponentDto application = db.components().insertPrivateApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPrivateApplication();
UserDto user = db.users().insertUser(u -> u.setHomepageType("APPLICATION").setHomepageParameter(application.uuid()));
userSessionRule.logIn(user.getLogin());
@@ -237,7 +237,7 @@ public class CurrentActionHomepageTest {
@UseDataProvider("belowEnterprise")
public void fallback_when_user_homepage_application_and_edition_below_enterprise(EditionProvider.Edition edition) {
setPlatformEdition(edition);
- ComponentDto application = db.components().insertPrivateApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPrivateApplication();
UserDto user = db.users().insertUser(u -> u.setHomepageType("APPLICATION").setHomepageParameter(application.uuid()));
userSessionRule.logIn(user.getLogin());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java
index 0c1422130ce..1373c02974c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java
@@ -140,7 +140,6 @@ public class CurrentActionTest {
UserDto user = db.users().insertUser();
userSession
.logIn(user)
- // permissions on default organization
.addPermission(SCAN)
.addPermission(ADMINISTER_QUALITY_PROFILES);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
index ae1e40c7577..27732d65787 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
@@ -21,7 +21,6 @@ package org.sonar.server.user.ws;
import java.util.Optional;
import javax.annotation.Nullable;
-import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.junit.Rule;
import org.junit.Test;
@@ -34,7 +33,6 @@ import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.ce.CeTaskMessageType;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.permission.template.PermissionTemplateDto;
import org.sonar.db.permission.template.PermissionTemplateUserDto;
import org.sonar.db.project.ProjectDto;
@@ -221,22 +219,6 @@ public class DeactivateActionTest {
}
@Test
- public void deactivate_user_deletes_his_organization_membership() {
- createAdminUser();
- logInAsSystemAdministrator();
- UserDto user = db.users().insertUser();
- OrganizationDto organization = db.organizations().insert();
- db.organizations().addMember(organization, user);
- OrganizationDto anotherOrganization = db.organizations().insert();
- db.organizations().addMember(anotherOrganization, user);
-
- deactivate(user.getLogin());
-
- assertThat(dbClient.organizationMemberDao().select(db.getSession(), organization.getUuid(), user.getUuid())).isNotPresent();
- assertThat(dbClient.organizationMemberDao().select(db.getSession(), anotherOrganization.getUuid(), user.getUuid())).isNotPresent();
- }
-
- @Test
public void deactivate_user_deletes_his_user_settings() {
createAdminUser();
logInAsSystemAdministrator();
@@ -389,7 +371,8 @@ public class DeactivateActionTest {
@Test
public void administrators_can_be_deactivated_if_there_are_still_other_administrators() {
- UserDto admin = createAdminUser();;
+ UserDto admin = createAdminUser();
+ ;
UserDto anotherAdmin = createAdminUser();
logInAsSystemAdministrator();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetHomepageActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetHomepageActionTest.java
index e6c5801bdfd..3f338787861 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetHomepageActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetHomepageActionTest.java
@@ -26,7 +26,6 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.component.TestComponentFinder;
import org.sonar.server.exceptions.UnauthorizedException;
@@ -50,9 +49,8 @@ public class SetHomepageActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private DbClient dbClient = db.getDbClient();
-
- private WsActionTester ws = new WsActionTester(new SetHomepageAction(userSession, dbClient, TestComponentFinder.from(db)));
+ private final DbClient dbClient = db.getDbClient();
+ private final WsActionTester ws = new WsActionTester(new SetHomepageAction(userSession, dbClient, TestComponentFinder.from(db)));
@Test
public void verify_definition() {
@@ -82,8 +80,7 @@ public class SetHomepageActionTest {
@Test
public void set_project_homepage() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(organization);
+ ComponentDto project = db.components().insertPrivateProject();
UserDto user = db.users().insertUser();
userSession.logIn(user);
@@ -102,8 +99,7 @@ public class SetHomepageActionTest {
@Test
public void set_branch_homepage() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPublicProject(organization);
+ ComponentDto project = db.components().insertPublicProject();
ComponentDto branch = db.components().insertProjectBranch(project);
UserDto user = db.users().insertUser();
userSession.logIn(user);
@@ -172,8 +168,7 @@ public class SetHomepageActionTest {
@Test
public void set_portfolio_homepage() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto portfolio = db.components().insertPrivatePortfolio(organization);
+ ComponentDto portfolio = db.components().insertPrivatePortfolio();
UserDto user = db.users().insertUser();
userSession.logIn(user);
@@ -191,8 +186,7 @@ public class SetHomepageActionTest {
@Test
public void set_application_homepage() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto application = db.components().insertPrivateApplication(organization);
+ ComponentDto application = db.components().insertPrivateApplication();
UserDto user = db.users().insertUser();
userSession.logIn(user);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
index 7578d98ce92..609b797ef48 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
@@ -35,8 +35,6 @@ import org.sonar.server.authentication.CredentialsLocalAuthentication;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.user.NewUserNotifier;
import org.sonar.server.user.UserUpdater;
@@ -52,8 +50,8 @@ import static org.sonar.db.user.UserTesting.newUserDto;
public class UpdateActionTest {
- private MapSettings settings = new MapSettings();
- private System2 system2 = new System2();
+ private final MapSettings settings = new MapSettings();
+ private final System2 system2 = new System2();
@Rule
public DbTester db = DbTester.create(system2);
@@ -64,15 +62,12 @@ public class UpdateActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private DbClient dbClient = db.getDbClient();
- private DbSession dbSession = db.getSession();
- private UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
-
- private WsActionTester ws = new WsActionTester(new UpdateAction(
- new UserUpdater(mock(NewUserNotifier.class), dbClient, userIndexer, defaultOrganizationProvider,
- new DefaultGroupFinder(db.getDbClient()), settings.asConfig(), localAuthentication),
+ private final DbClient dbClient = db.getDbClient();
+ private final DbSession dbSession = db.getSession();
+ private final UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
+ private final CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient());
+ private final WsActionTester ws = new WsActionTester(new UpdateAction(
+ new UserUpdater(mock(NewUserNotifier.class), dbClient, userIndexer, new DefaultGroupFinder(db.getDbClient()), settings.asConfig(), localAuthentication),
userSession, new UserJsonWriter(userSession), dbClient));
@Before
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java
index 80ab15224a3..1e9e5157ce0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/UpdateLoginActionTest.java
@@ -44,7 +44,7 @@ import static org.mockito.Mockito.mock;
public class UpdateLoginActionTest {
- private System2 system2 = new System2();
+ private final System2 system2 = new System2();
@Rule
public DbTester db = DbTester.create(system2);
@@ -55,9 +55,8 @@ public class UpdateLoginActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private WsActionTester ws = new WsActionTester(new UpdateLoginAction(db.getDbClient(), userSession,
- new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), new UserIndexer(db.getDbClient(), es.client()),
- null,null, null, null)));
+ private final WsActionTester ws = new WsActionTester(new UpdateLoginAction(db.getDbClient(), userSession,
+ new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), new UserIndexer(db.getDbClient(), es.client()), null, null, null)));
@Test
public void update_login_from_sonarqube_account_when_user_is_local() {