Skip to content

Commit

Permalink
bug 1310220: Return empty list when user has no roles (#195). r=bhearsum
Browse files Browse the repository at this point in the history
  • Loading branch information
njirap authored and bhearsum committed Dec 20, 2016
1 parent 65b8d22 commit 061f4bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions auslib/admin/views/permissions.py
Expand Up @@ -102,10 +102,7 @@ class UserRolesView(AdminView):

def get(self, username):
roles = dbo.permissions.getUserRoles(username)
if roles:
return jsonify({"roles": roles})
else:
return Response(status=404, response="No roles found for user")
return jsonify({"roles": roles})


class UserRoleView(AdminView):
Expand Down
4 changes: 2 additions & 2 deletions auslib/test/admin/views/test_permissions.py
Expand Up @@ -177,9 +177,9 @@ def testGetRoles(self):
got = set(json.loads(ret.data)["roles"])
self.assertEquals(got, set(["releng", "qa"]))

def testGetRolesMissingUser(self):
def testGetRolesMissingUserReturnsEmptyList(self):
ret = self.client.get("/users/dean/roles")
self.assertStatusCode(ret, 404)
self.assertStatusCode(ret, 200)

def testGrantRole(self):
ret = self._put("/users/ashanti/roles/dev")
Expand Down

0 comments on commit 061f4bb

Please sign in to comment.