From 0043949d55cbb4da6ac6e52b62d863560b04f970 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Mon, 17 Oct 2016 12:28:47 +0200 Subject: SONAR-8192 set root flag in UserIdentityAuthenticator depending upon whether groups of the user have or not System Administer permision and whether, when it already exists, the user has user permission "System Administer" --- .../src/test/java/org/sonar/db/user/RootFlagAssertions.java | 8 +++++++- sonar-db/src/test/java/org/sonar/db/user/UserDbTester.java | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'sonar-db') diff --git a/sonar-db/src/test/java/org/sonar/db/user/RootFlagAssertions.java b/sonar-db/src/test/java/org/sonar/db/user/RootFlagAssertions.java index 344d5dcb7ce..af7abd8f7c7 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/RootFlagAssertions.java +++ b/sonar-db/src/test/java/org/sonar/db/user/RootFlagAssertions.java @@ -51,6 +51,12 @@ public class RootFlagAssertions { .isEqualTo(root); assertThat(dto.getUpdatedAt()) .as("UpdatedAt of user '%s' has changed since insertion", userDto.getLogin()) - .isNotEqualTo(userDto); + .isNotEqualTo(userDto.getUpdatedAt()); + } + + public void verify(String login, boolean root) { + assertThat(db.getDbClient().userDao().selectByLogin(db.getSession(), login).isRoot()) + .as("Root flag of user '%s' is '%s'", login, root) + .isEqualTo(root); } } diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserDbTester.java b/sonar-db/src/test/java/org/sonar/db/user/UserDbTester.java index 31ef077d935..3f8e9f63dfb 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/UserDbTester.java +++ b/sonar-db/src/test/java/org/sonar/db/user/UserDbTester.java @@ -172,6 +172,16 @@ public class UserDbTester { return groupDto; } + /** + * Creates a group with the specified name in the specified organization with {@link GlobalPermissions#SYSTEM_ADMIN} + * permission. + */ + public GroupDto insertAdminGroup(OrganizationDto organizationDto, String name) { + GroupDto groupDto = insertGroup(organizationDto, name); + insertPermissionOnGroup(groupDto, SYSTEM_ADMIN); + return groupDto; + } + /** * Create group in specified organization */ -- cgit v1.2.3