From 322e18a7b6ec8d99c8f9df819f714fd0c1a0db61 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 25 May 2017 16:18:15 +0530 Subject: [PATCH] CLOUDSTACK-9928: Allow native CloudStack users to change password in UI This allows native CloudStack users to change password in UI when LDAP is enabled. Overall changes: - A new usersource returned in the listUsers response - Removed ldap check in the UI, replaced with check based on user source - DB changes to include user.source in user_view - Changed UI error message for non-native users trying to change password Signed-off-by: Rohit Yadav --- .travis.yml | 2 +- api/src/com/cloud/user/User.java | 3 +- .../cloudstack/api/response/UserResponse.java | 15 +++++++ .../api/query/dao/UserAccountJoinDaoImpl.java | 1 + .../cloud/api/query/vo/UserAccountJoinVO.java | 29 +++++++----- setup/db/db/schema-4930to41000-cleanup.sql | 45 +++++++++++++++++++ test/integration/component/test_accounts.py | 10 +++-- tools/marvin/marvin/codegenerator.py | 5 ++- ui/l10n/ar.js | 2 +- ui/l10n/ca.js | 2 +- ui/l10n/de_DE.js | 2 +- ui/l10n/en.js | 2 +- ui/l10n/es.js | 2 +- ui/l10n/fr_FR.js | 2 +- ui/l10n/hu.js | 2 +- ui/l10n/it_IT.js | 2 +- ui/l10n/ja_JP.js | 2 +- ui/l10n/ko_KR.js | 2 +- ui/l10n/nb_NO.js | 2 +- ui/l10n/nl_NL.js | 2 +- ui/l10n/pl.js | 2 +- ui/l10n/pt_BR.js | 2 +- ui/l10n/ru_RU.js | 2 +- ui/l10n/zh_CN.js | 2 +- ui/scripts/accounts.js | 7 +-- 25 files changed, 114 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4790edf4b0..4301d7569cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,6 +93,7 @@ env: smoke/misc/test_vm_sync" - TESTS="component/find_hosts_for_migration + component/test_accounts component/test_acl_isolatednetwork_delete component/test_acl_listsnapshot component/test_acl_listvm @@ -146,7 +147,6 @@ env: # - TESTS="component/test_project_resources" # - TESTS="component/test_cpu_domain_limits" # - TESTS="component/test_acl_isolatednetwork" -# - TESTS="component/test_accounts" # - TESTS="component/test_organization_states" before_install: travis_wait 30 ./tools/travis/before_install.sh diff --git a/api/src/com/cloud/user/User.java b/api/src/com/cloud/user/User.java index 0ecdcfa58d4..c3ac66c6979 100644 --- a/api/src/com/cloud/user/User.java +++ b/api/src/com/cloud/user/User.java @@ -22,8 +22,9 @@ import org.apache.cloudstack.api.InternalIdentity; public interface User extends OwnedBy, InternalIdentity { + // UNKNOWN and NATIVE can be used interchangeably public enum Source { - LDAP, SAML2, SAML2DISABLED, UNKNOWN + LDAP, SAML2, SAML2DISABLED, UNKNOWN, NATIVE } public static final long UID_SYSTEM = 1; diff --git a/api/src/org/apache/cloudstack/api/response/UserResponse.java b/api/src/org/apache/cloudstack/api/response/UserResponse.java index d96f632f1a3..dd10510c03c 100644 --- a/api/src/org/apache/cloudstack/api/response/UserResponse.java +++ b/api/src/org/apache/cloudstack/api/response/UserResponse.java @@ -66,6 +66,10 @@ public class UserResponse extends BaseResponse { @Param(description = "the account type of the user") private Short accountType; + @SerializedName("usersource") + @Param(description = "the source type of the user in lowercase, such as native, ldap, saml2") + private String userSource; + @SerializedName(ApiConstants.ROLE_ID) @Param(description = "the ID of the role") private String roleId; @@ -260,4 +264,15 @@ public class UserResponse extends BaseResponse { public void setIsDefault(Boolean isDefault) { this.isDefault = isDefault; } + + public String getUserSource() { + return userSource; + } + + public void setUserSource(User.Source userSource) { + this.userSource = userSource.toString().toLowerCase(); + if (this.userSource.equals(User.Source.UNKNOWN.toString().toLowerCase())) { + this.userSource = User.Source.NATIVE.toString().toLowerCase(); + } + } } diff --git a/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java index 433912bff28..8d06bcd0a26 100644 --- a/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java @@ -58,6 +58,7 @@ public class UserAccountJoinDaoImpl extends GenericDaoBase