diff options
Diffstat (limited to 'server/sonar-db-dao')
18 files changed, 107 insertions, 65 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDto.java index 7f41ce65250..e85f6ed8785 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDto.java @@ -51,6 +51,7 @@ public class UserDto { private Long updatedAt; private boolean local = true; private boolean root = false; + private boolean onboarded = false; public Integer getId() { return id; @@ -218,6 +219,15 @@ public class UserDto { this.root = root; } + public boolean isOnboarded() { + return onboarded; + } + + public UserDto setOnboarded(boolean onboarded) { + this.onboarded = onboarded; + return this; + } + public static String encryptPassword(String password, String salt) { requireNonNull(password, "Password cannot be empty"); requireNonNull(salt, "Salt cannot be empty"); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml index 63eafbcef3f..ef9d08398df 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml @@ -16,6 +16,7 @@ u.external_identity_provider as "externalIdentityProvider", u.user_local as "local", u.is_root as "root", + u.onboarded as "onboarded", u.created_at as "createdAt", u.updated_at as "updatedAt" </sql> @@ -155,6 +156,7 @@ salt, crypted_password, is_root, + onboarded, created_at, updated_at ) @@ -170,6 +172,7 @@ #{salt,jdbcType=VARCHAR}, #{cryptedPassword,jdbcType=VARCHAR}, #{root,jdbcType=BOOLEAN}, + #{onboarded,jdbcType=BOOLEAN}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT} ) @@ -184,6 +187,7 @@ external_identity=#{externalIdentity,jdbcType=VARCHAR}, external_identity_provider=#{externalIdentityProvider,jdbcType=VARCHAR}, user_local=#{local,jdbcType=BOOLEAN}, + onboarded=#{onboarded,jdbcType=BOOLEAN}, salt=#{salt,jdbcType=VARCHAR}, crypted_password=#{cryptedPassword,jdbcType=BIGINT}, updated_at=#{updatedAt,jdbcType=BIGINT} diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java index 3acf9a2b530..c6f54ca0503 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java @@ -307,6 +307,7 @@ public class UserDaoTest { .setEmail("jo@hn.com") .setScmAccounts(",jo.hn,john2,") .setActive(true) + .setOnboarded(true) .setSalt("1234") .setCryptedPassword("abcd") .setExternalIdentity("johngithub") @@ -324,6 +325,7 @@ public class UserDaoTest { assertThat(user.getName()).isEqualTo("John"); assertThat(user.getEmail()).isEqualTo("jo@hn.com"); assertThat(user.isActive()).isTrue(); + assertThat(user.isOnboarded()).isTrue(); assertThat(user.getScmAccounts()).isEqualTo(",jo.hn,john2,"); assertThat(user.getSalt()).isEqualTo("1234"); assertThat(user.getCryptedPassword()).isEqualTo("abcd"); @@ -344,7 +346,8 @@ public class UserDaoTest { .setCreatedAt(1418215735482L) .setUpdatedAt(1418215735482L) .setActive(true) - .setLocal(true); + .setLocal(true) + .setOnboarded(false); db.getDbClient().userDao().insert(db.getSession(), existingUser); db.getSession().commit(); @@ -355,6 +358,7 @@ public class UserDaoTest { .setEmail("jodoo@hn.com") .setScmAccounts(",jo.hn,john2,johndoo,") .setActive(false) + .setOnboarded(true) .setSalt("12345") .setCryptedPassword("abcde") .setExternalIdentity("johngithub") @@ -371,6 +375,7 @@ public class UserDaoTest { assertThat(user.getName()).isEqualTo("John Doo"); assertThat(user.getEmail()).isEqualTo("jodoo@hn.com"); assertThat(user.isActive()).isFalse(); + assertThat(user.isOnboarded()).isTrue(); assertThat(user.getScmAccounts()).isEqualTo(",jo.hn,john2,johndoo,"); assertThat(user.getSalt()).isEqualTo("12345"); assertThat(user.getCryptedPassword()).isEqualTo("abcde"); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTesting.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTesting.java index 682699ad4d9..b9bba58527b 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTesting.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTesting.java @@ -23,70 +23,60 @@ import javax.annotation.Nullable; import static java.util.Collections.singletonList; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; +import static org.apache.commons.lang.math.RandomUtils.nextBoolean; import static org.apache.commons.lang.math.RandomUtils.nextInt; import static org.apache.commons.lang.math.RandomUtils.nextLong; public class UserTesting { public static UserDto newUserDto() { - return newUserDto(randomAlphanumeric(30), randomAlphanumeric(30), randomAlphanumeric(30)); - } - - public static UserDto newUserDto(String login, String name, @Nullable String email) { return new UserDto() .setId(nextInt()) .setActive(true) - .setLocal(true) - .setName(name) - .setEmail(email) - .setLogin(login) + .setLocal(nextBoolean()) + .setLogin(randomAlphanumeric(30)) + .setName(randomAlphanumeric(30)) + .setEmail(randomAlphanumeric(30)) + .setOnboarded(nextBoolean()) .setScmAccounts(singletonList(randomAlphanumeric(40))) - .setExternalIdentity(login) - .setExternalIdentityProvider("sonarqube") + .setExternalIdentity(randomAlphanumeric(40)) + .setExternalIdentityProvider(randomAlphanumeric(40)) .setSalt(randomAlphanumeric(40)) .setCryptedPassword(randomAlphanumeric(40)) .setCreatedAt(nextLong()) .setUpdatedAt(nextLong()); } + public static UserDto newUserDto(String login, String name, @Nullable String email) { + return newUserDto() + .setName(name) + .setEmail(email) + .setLogin(login); + } + public static UserDto newLocalUser(String login, String name, @Nullable String email) { - return new UserDto() - .setId(nextInt()) - .setActive(true) + return newUserDto() .setLocal(true) .setName(name) .setEmail(email) .setLogin(login) - .setScmAccounts(singletonList(randomAlphanumeric(40))) .setExternalIdentity(login) - .setExternalIdentityProvider("sonarqube") - .setSalt(randomAlphanumeric(40)) - .setCryptedPassword(randomAlphanumeric(40)) - .setCreatedAt(nextLong()) - .setUpdatedAt(nextLong()); + .setExternalIdentityProvider("sonarqube"); } public static UserDto newExternalUser(String login, String name, @Nullable String email) { - return new UserDto() - .setId(nextInt()) - .setActive(true) + return newUserDto() .setLocal(false) .setName(name) .setEmail(email) .setLogin(login) - .setScmAccounts(singletonList(randomAlphanumeric(40))) .setExternalIdentity(randomAlphanumeric(40)) - .setExternalIdentityProvider(randomAlphanumeric(40)) - .setCreatedAt(nextLong()) - .setUpdatedAt(nextLong()); + .setExternalIdentityProvider(randomAlphanumeric(40)); } public static UserDto newDisabledUser(String login) { - return new UserDto() - .setId(nextInt()) + return newUserDto() .setLogin(login) - .setActive(false) - .setCreatedAt(nextLong()) - .setUpdatedAt(nextLong()); + .setActive(false); } } diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/select_only_enable_users.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/select_only_enable_users.xml index 9ad332d06d7..c3a899ddf49 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/select_only_enable_users.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/select_only_enable_users.xml @@ -4,22 +4,26 @@ login="user1" name="User1" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="201" login="user2" name="User2" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="202" login="user3" name="User3" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="999" login="disabledUser" name="disabledUser" active="[false]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <organization_members user_id="200" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions.xml index 0339e3dbd55..8382a060d27 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions.xml @@ -4,17 +4,20 @@ login="user1" name="User1" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="201" login="user2" name="User2" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="202" login="user3" name="User3" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <organization_members user_id="200" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml index 13a3f1f3e0a..56e76fad3f9 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/permission/template/UserWithPermissionTemplateDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml @@ -4,17 +4,20 @@ login="user3" name="User3" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="201" login="user1" name="User1" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="202" login="user2" name="User2" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <organization_members user_id="200" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/exists_by_email.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/exists_by_email.xml index 63dd4a57e8d..2226bb3ba34 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/exists_by_email.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/exists_by_email.xml @@ -10,7 +10,8 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="sbrandhof" name="Simon Brandhof" @@ -21,6 +22,7 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/insert-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/insert-result.xml index a15c10259bc..fe3a43320a9 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/insert-result.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/insert-result.xml @@ -6,5 +6,6 @@ created_at="1418215735482" updated_at="1418215735482" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectActiveUserByLogin.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectActiveUserByLogin.xml index aa0b64fadf2..fba9650f48b 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectActiveUserByLogin.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectActiveUserByLogin.xml @@ -7,7 +7,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[false]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <!-- active --> <users id="101" @@ -17,7 +18,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="jcdus" @@ -26,7 +28,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByIds.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByIds.xml index 65e155941df..7340c944abb 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByIds.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByIds.xml @@ -6,7 +6,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[false]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="101" login="marius" name="Marius" @@ -14,7 +15,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="jcdus" name="Jean-Claude Dus" @@ -22,6 +24,7 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByLogins.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByLogins.xml index 65e155941df..7340c944abb 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByLogins.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByLogins.xml @@ -6,7 +6,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[false]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="101" login="marius" name="Marius" @@ -14,7 +15,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="jcdus" name="Jean-Claude Dus" @@ -22,6 +24,7 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByQuery.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByQuery.xml index 8f6bacd7c43..246d4caf77e 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByQuery.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByQuery.xml @@ -6,7 +6,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[false]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="101" login="marius" name="Marius" @@ -14,6 +15,7 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByText.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByText.xml index 89b1302e298..c4308ee82af 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByText.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByText.xml @@ -6,7 +6,8 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="sbrandhof" name="Simon Brandhof" @@ -14,6 +15,7 @@ created_at="1418215735482" updated_at="1418215735485" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_by_login.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_by_login.xml index d07ecce8728..2ac78040cab 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_by_login.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_by_login.xml @@ -10,7 +10,8 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="sbrandhof" name="Simon Brandhof" @@ -21,6 +22,7 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh" - is_root="[true]"/> + is_root="[true]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account.xml index 3ded656c9f4..54b486eb3e3 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account.xml @@ -10,7 +10,8 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="sbrandhof" name="Simon Brandhof" @@ -21,6 +22,7 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml index 63dd4a57e8d..2226bb3ba34 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml @@ -10,7 +10,8 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> <users id="102" login="sbrandhof" name="Simon Brandhof" @@ -21,6 +22,7 @@ updated_at="1418215735485" salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366" crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/update_user.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/update_user.xml index a15c10259bc..fe3a43320a9 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/update_user.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/update_user.xml @@ -6,5 +6,6 @@ created_at="1418215735482" updated_at="1418215735482" active="[true]" - is_root="[false]"/> + is_root="[false]" + onboarded="[true]"/> </dataset> |