Add tests for project users interacting with roles
This commit introduces test coverage that explicitly shows how project users are expected to behave global role resources. A subsequent patch will clean up the now obsolete policies in the policy.v3cloudsample.json policy file. Change-Id: Id0dc3022ab294e73aeaa87e130bea4809f8c982b Partial-Bug: 1806713
This commit is contained in:
parent
31eecfb2a4
commit
512f0b4f7b
@ -296,3 +296,71 @@ class DomainUserTests(base_classes.TestCaseWithBootstrap,
|
|||||||
r = c.post('/v3/auth/tokens', json=auth)
|
r = c.post('/v3/auth/tokens', json=auth)
|
||||||
self.token_id = r.headers['X-Subject-Token']
|
self.token_id = r.headers['X-Subject-Token']
|
||||||
self.headers = {'X-Auth-Token': self.token_id}
|
self.headers = {'X-Auth-Token': self.token_id}
|
||||||
|
|
||||||
|
|
||||||
|
class ProjectUserTests(base_classes.TestCaseWithBootstrap,
|
||||||
|
common_auth.AuthTestMixin,
|
||||||
|
_DomainAndProjectUserRoleTests):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ProjectUserTests, self).setUp()
|
||||||
|
self.loadapp()
|
||||||
|
self.useFixture(ksfixtures.Policy(self.config_fixture))
|
||||||
|
self.config_fixture.config(group='oslo_policy', enforce_scope=True)
|
||||||
|
|
||||||
|
self.user_id = self.bootstrapper.admin_user_id
|
||||||
|
auth = self.build_authentication_request(
|
||||||
|
user_id=self.user_id,
|
||||||
|
password=self.bootstrapper.admin_password,
|
||||||
|
project_id=self.bootstrapper.project_id
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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 ProjectUserTestsWithoutEnforceScope(
|
||||||
|
base_classes.TestCaseWithBootstrap,
|
||||||
|
common_auth.AuthTestMixin,
|
||||||
|
_DomainAndProjectUserRoleTests):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ProjectUserTestsWithoutEnforceScope, self).setUp()
|
||||||
|
self.loadapp()
|
||||||
|
self.useFixture(ksfixtures.Policy(self.config_fixture))
|
||||||
|
|
||||||
|
# Explicityly set enforce_scope to False to make sure we maintain
|
||||||
|
# backwards compatibility with project users.
|
||||||
|
self.config_fixture.config(group='oslo_policy', enforce_scope=False)
|
||||||
|
|
||||||
|
domain = PROVIDERS.resource_api.create_domain(
|
||||||
|
uuid.uuid4().hex, unit.new_domain_ref()
|
||||||
|
)
|
||||||
|
user = unit.new_user_ref(domain_id=domain['id'])
|
||||||
|
self.user_id = PROVIDERS.identity_api.create_user(user)['id']
|
||||||
|
|
||||||
|
self.project_id = PROVIDERS.resource_api.create_project(
|
||||||
|
uuid.uuid4().hex, unit.new_project_ref(domain_id=domain['id'])
|
||||||
|
)['id']
|
||||||
|
|
||||||
|
PROVIDERS.assignment_api.create_grant(
|
||||||
|
self.bootstrapper.member_role_id, user_id=self.user_id,
|
||||||
|
project_id=self.project_id
|
||||||
|
)
|
||||||
|
|
||||||
|
auth = self.build_authentication_request(
|
||||||
|
user_id=self.user_id,
|
||||||
|
password=user['password'],
|
||||||
|
project_id=self.project_id
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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
Block a user