From 453772f62c7c8a99ee13c78822eede368f1a43fa Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Thu, 24 Mar 2016 21:16:15 -0400 Subject: [PATCH] Fixed up credential viewability expectations in jobs_monlithic tests Super users can now see all credentials always.. Adjusted test to test for this, as well as original test intent which was to test to ensure after removing a team which has access to a credential, members of that team no longer have access to the credential. --- awx/main/tests/job_base.py | 2 +- awx/main/tests/old/jobs/jobs_monolithic.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/awx/main/tests/job_base.py b/awx/main/tests/job_base.py index 2640d29365..9cea21e2cd 100644 --- a/awx/main/tests/job_base.py +++ b/awx/main/tests/job_base.py @@ -384,7 +384,7 @@ class BaseJobTestMixin(BaseTestMixin): password='Heading0', created_by = self.user_sue, ) - self.team_ops_north.member_role.children.add(self.cred_ops_north.usage_role) + self.team_ops_north.member_role.children.add(self.cred_ops_north.owner_role) self.cred_ops_test = Credential.objects.create( username='testers', diff --git a/awx/main/tests/old/jobs/jobs_monolithic.py b/awx/main/tests/old/jobs/jobs_monolithic.py index 6b6d25681e..e174fd55d5 100644 --- a/awx/main/tests/old/jobs/jobs_monolithic.py +++ b/awx/main/tests/old/jobs/jobs_monolithic.py @@ -281,11 +281,17 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase): self.assertFalse('south' in [x['username'] for x in all_credentials['results']]) url2 = reverse('api:team_detail', args=(self.team_ops_north.id,)) - # Sue shouldn't be able to see the north credential once deleting its team - with self.current_user(self.user_sue): + # Greg shouldn't be able to see the north credential once deleting its team + with self.current_user(self.user_greg): + all_credentials = self.get(url, expect=200) + self.assertTrue('north' in [x['username'] for x in all_credentials['results']]) self.delete(url2, expect=204) all_credentials = self.get(url, expect=200) self.assertFalse('north' in [x['username'] for x in all_credentials['results']]) + # Sue can still see the credential, she's a super user + with self.current_user(self.user_sue): + all_credentials = self.get(url, expect=200) + self.assertTrue('north' in [x['username'] for x in all_credentials['results']]) def test_post_job_template_list(self): self.skipTest('This test makes assumptions about projects being multi-org and needs to be updated/rewritten')