getUserPerms should throw GenericError when no user found
This commit is contained in:
parent
3c7aeeaef3
commit
2838f7fd9e
2 changed files with 27 additions and 1 deletions
|
|
@ -10599,7 +10599,8 @@ class RootExports(object):
|
|||
|
||||
def getUserPerms(self, userID):
|
||||
"""Get a list of the permissions granted to the user with the given ID."""
|
||||
return koji.auth.get_user_perms(userID)
|
||||
user_info = get_user(userID, strict=True)
|
||||
return koji.auth.get_user_perms(user_info['id'])
|
||||
|
||||
def getAllPerms(self):
|
||||
"""Get a list of all permissions in the system. Returns a list of maps. Each
|
||||
|
|
|
|||
25
tests/test_hub/test_get_user_perms.py
Normal file
25
tests/test_hub/test_get_user_perms.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import mock
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
|
||||
class TestGetUserPerms(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.get_user = mock.patch('kojihub.get_user').start()
|
||||
self.get_user_perms = mock.patch('koji.auth.get_user_perms').start()
|
||||
|
||||
def tearDown(self):
|
||||
mock.patch.stopall()
|
||||
|
||||
def test_no_user(self):
|
||||
self.get_user.side_effect = koji.GenericError
|
||||
with self.assertRaises(koji.GenericError):
|
||||
kojihub.RootExports().getUserPerms(123)
|
||||
self.get_user_perms.assert_not_called()
|
||||
|
||||
def test_normal(self):
|
||||
self.get_user.return_value = {'id': 123, 'name': 'testuser'}
|
||||
kojihub.RootExports().getUserPerms(123)
|
||||
self.get_user_perms.assert_called_once_with(123)
|
||||
Loading…
Add table
Add a link
Reference in a new issue