Update system grant policies for system member
This commit ensures users with the ``member`` role on the system can perform read-only operations against the system assignment API. - system admin functionality - domain user test coverage - project user test coverage Change-Id: I834475da2343ba87fb169689f71d4cb4713f6786 Related-Bug: 1805368 Related-Bug: 1750669 Related-Bug: 1806762
This commit is contained in:
parent
465a8bb59b
commit
bb4192e88d
|
@ -61,37 +61,7 @@ class _SystemUserSystemAssignmentTests(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SystemReaderTests(base_classes.TestCaseWithBootstrap,
|
class _SystemMemberAndReaderSystemAssignmentTests(object):
|
||||||
common_auth.AuthTestMixin,
|
|
||||||
_SystemUserSystemAssignmentTests):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(SystemReaderTests, self).setUp()
|
|
||||||
self.loadapp()
|
|
||||||
self.useFixture(ksfixtures.Policy(self.config_fixture))
|
|
||||||
self.config_fixture.config(group='oslo_policy', enforce_scope=True)
|
|
||||||
|
|
||||||
system_reader = unit.new_user_ref(
|
|
||||||
domain_id=CONF.identity.default_domain_id
|
|
||||||
)
|
|
||||||
self.user_id = PROVIDERS.identity_api.create_user(
|
|
||||||
system_reader
|
|
||||||
)['id']
|
|
||||||
PROVIDERS.assignment_api.create_system_grant_for_user(
|
|
||||||
self.user_id, self.bootstrapper.reader_role_id
|
|
||||||
)
|
|
||||||
|
|
||||||
auth = self.build_authentication_request(
|
|
||||||
user_id=self.user_id, password=system_reader['password'],
|
|
||||||
system=True
|
|
||||||
)
|
|
||||||
|
|
||||||
# Grab a token using the persona we're testing and prepare headers
|
|
||||||
# for requests we'll be making in the tests.
|
|
||||||
with self.test_client() as c:
|
|
||||||
r = c.post('/v3/auth/tokens', json=auth)
|
|
||||||
self.token_id = r.headers['X-Subject-Token']
|
|
||||||
self.headers = {'X-Auth-Token': self.token_id}
|
|
||||||
|
|
||||||
def test_user_cannot_grant_system_assignments(self):
|
def test_user_cannot_grant_system_assignments(self):
|
||||||
user = PROVIDERS.identity_api.create_user(
|
user = PROVIDERS.identity_api.create_user(
|
||||||
|
@ -122,3 +92,79 @@ class SystemReaderTests(base_classes.TestCaseWithBootstrap,
|
||||||
), headers=self.headers,
|
), headers=self.headers,
|
||||||
expected_status_code=http_client.FORBIDDEN
|
expected_status_code=http_client.FORBIDDEN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SystemReaderTests(base_classes.TestCaseWithBootstrap,
|
||||||
|
common_auth.AuthTestMixin,
|
||||||
|
_SystemUserSystemAssignmentTests,
|
||||||
|
_SystemMemberAndReaderSystemAssignmentTests):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(SystemReaderTests, self).setUp()
|
||||||
|
self.loadapp()
|
||||||
|
self.useFixture(ksfixtures.Policy(self.config_fixture))
|
||||||
|
self.config_fixture.config(group='oslo_policy', enforce_scope=True)
|
||||||
|
|
||||||
|
system_reader = unit.new_user_ref(
|
||||||
|
domain_id=CONF.identity.default_domain_id
|
||||||
|
)
|
||||||
|
self.user_id = PROVIDERS.identity_api.create_user(
|
||||||
|
system_reader
|
||||||
|
)['id']
|
||||||
|
PROVIDERS.assignment_api.create_system_grant_for_user(
|
||||||
|
self.user_id, self.bootstrapper.reader_role_id
|
||||||
|
)
|
||||||
|
|
||||||
|
auth = self.build_authentication_request(
|
||||||
|
user_id=self.user_id, password=system_reader['password'],
|
||||||
|
system=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Grab a token using the persona we're testing and prepare headers
|
||||||
|
# for requests we'll be making in the tests.
|
||||||
|
with self.test_client() as c:
|
||||||
|
r = c.post('/v3/auth/tokens', json=auth)
|
||||||
|
self.token_id = r.headers['X-Subject-Token']
|
||||||
|
self.headers = {'X-Auth-Token': self.token_id}
|
||||||
|
|
||||||
|
|
||||||
|
class SystemMemberTests(base_classes.TestCaseWithBootstrap,
|
||||||
|
common_auth.AuthTestMixin,
|
||||||
|
_SystemUserSystemAssignmentTests,
|
||||||
|
_SystemMemberAndReaderSystemAssignmentTests):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(SystemMemberTests, self).setUp()
|
||||||
|
self.loadapp()
|
||||||
|
self.useFixture(ksfixtures.Policy(self.config_fixture))
|
||||||
|
self.config_fixture.config(group='oslo_policy', enforce_scope=True)
|
||||||
|
|
||||||
|
system_member = unit.new_user_ref(
|
||||||
|
domain_id=CONF.identity.default_domain_id
|
||||||
|
)
|
||||||
|
self.user_id = PROVIDERS.identity_api.create_user(
|
||||||
|
system_member
|
||||||
|
)['id']
|
||||||
|
PROVIDERS.assignment_api.create_system_grant_for_user(
|
||||||
|
self.user_id, self.bootstrapper.member_role_id
|
||||||
|
)
|
||||||
|
self.expected = [
|
||||||
|
# assignment of the user running the test case
|
||||||
|
{
|
||||||
|
'user_id': self.user_id,
|
||||||
|
'system': 'all',
|
||||||
|
'role_id': self.bootstrapper.member_role_id
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
auth = self.build_authentication_request(
|
||||||
|
user_id=self.user_id, password=system_member['password'],
|
||||||
|
system=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Grab a token using the persona we're testing and prepare headers
|
||||||
|
# for requests we'll be making in the tests.
|
||||||
|
with self.test_client() as c:
|
||||||
|
r = c.post('/v3/auth/tokens', json=auth)
|
||||||
|
self.token_id = r.headers['X-Subject-Token']
|
||||||
|
self.headers = {'X-Auth-Token': self.token_id}
|
||||||
|
|
Loading…
Reference in New Issue