This is an automated email from the ASF dual-hosted git repository.

pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/master by this push:
     new d247fece1 RANGER-3807: getUserRoles API gives 200 for non existing 
user passed to this API
d247fece1 is described below

commit d247fece1055555d926b4487cfd43fcefedad94c
Author: pradeep <prad...@apache.org>
AuthorDate: Fri Jun 24 16:40:46 2022 +0530

    RANGER-3807: getUserRoles API gives 200 for non existing user passed to 
this API
---
 security-admin/src/main/java/org/apache/ranger/rest/RoleREST.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/security-admin/src/main/java/org/apache/ranger/rest/RoleREST.java 
b/security-admin/src/main/java/org/apache/ranger/rest/RoleREST.java
index e00767643..d2bc59a02 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/RoleREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/RoleREST.java
@@ -698,6 +698,9 @@ public class RoleREST {
             LOG.debug("==> getUserRoles()");
         }
         try {
+            if (xUserService.getXUserByUserName(userName) == null) {
+                throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, "User:" + 
userName + " not found", false);
+            }
             Set<RangerRole> roleList = roleStore.getRoleNames(userName, 
userMgr.getGroupsForUser(userName));
             for (RangerRole role : roleList) {
                 ret.add(role.getName());

Reply via email to