Merge branch 'rbac' of github.com:anoek/ansible-tower into rbac

This commit is contained in:
Akita Noek 2016-03-23 15:30:33 -04:00
commit de114336ef
3 changed files with 20 additions and 13 deletions

View File

@ -69,10 +69,10 @@ class QueueTestMixin(object):
if getattr(self, 'redis_process', None):
self.redis_process.kill()
self.redis_process = None
# The observed effect of not calling terminate_queue() if you call start_queue() are
# an hang on test cleanup database delete. Thus, to ensure terminate_queue() is called
# an hang on test cleanup database delete. Thus, to ensure terminate_queue() is called
# whenever start_queue() is called just inherit from this class when you want to use the queue.
class QueueStartStopTestMixin(QueueTestMixin):
def setUp(self):
@ -129,7 +129,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
settings.CELERY_UNIT_TEST = True
settings.SYSTEM_UUID='00000000-0000-0000-0000-000000000000'
settings.BROKER_URL='redis://localhost:16379/'
# Create unique random consumer and queue ports for zeromq callback.
if settings.CALLBACK_CONSUMER_PORT:
callback_port = random.randint(55700, 55799)
@ -181,7 +181,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
return __name__ + '-generated-' + string + rnd_str
def create_test_license_file(self, instance_count=10000, license_date=int(time.time() + 3600), features=None):
writer = LicenseWriter(
writer = LicenseWriter(
company_name='AWX',
contact_name='AWX Admin',
contact_email='awx@example.com',
@ -196,7 +196,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
os.environ['AWX_LICENSE_FILE'] = license_path
def create_basic_license_file(self, instance_count=100, license_date=int(time.time() + 3600)):
writer = LicenseWriter(
writer = LicenseWriter(
company_name='AWX',
contact_name='AWX Admin',
contact_email='awx@example.com',
@ -208,7 +208,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
writer.write_file(license_path)
self._temp_paths.append(license_path)
os.environ['AWX_LICENSE_FILE'] = license_path
def create_expired_license_file(self, instance_count=1000, grace_period=False):
license_date = time.time() - 1
if not grace_period:
@ -383,7 +383,11 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
'vault_password': '',
}
opts.update(kwargs)
return Credential.objects.create(**opts)
user = opts['user']
del opts['user']
cred = Credential.objects.create(**opts)
cred.owner_role.members.add(user)
return cred
def setup_instances(self):
instance = Instance(uuid=settings.SYSTEM_UUID, primary=True, hostname='127.0.0.1')
@ -422,7 +426,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
def get_invalid_credentials(self):
return ('random', 'combination')
def _generic_rest(self, url, data=None, expect=204, auth=None, method=None,
data_type=None, accept=None, remote_addr=None,
return_response_object=False, client_kwargs=None):
@ -517,7 +521,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
return self._generic_rest(url, data=None, expect=expect, auth=auth,
method='head', accept=accept,
remote_addr=remote_addr)
def get(self, url, expect=200, auth=None, accept=None, remote_addr=None, client_kwargs={}):
return self._generic_rest(url, data=None, expect=expect, auth=auth,
method='get', accept=accept,
@ -658,7 +662,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
else:
msg += 'Found %d occurances of "%s" instead of %d in: "%s"' % (count_actual, substr, count, string)
self.assertEqual(count_actual, count, msg)
def check_job_result(self, job, expected='successful', expect_stdout=True,
expect_traceback=False):
msg = u'job status is %s, expected %s' % (job.status, expected)

View File

@ -142,12 +142,12 @@ class BaseJobTestMixin(BaseTestMixin):
self.org_eng.projects.add(self.proj_dev)
self.proj_test = self.make_project('test', 'testing branch',
self.user_sue, TEST_PLAYBOOK)
self.org_eng.projects.add(self.proj_test)
#self.org_eng.projects.add(self.proj_test) # No more multi org projects
self.org_sup.projects.add(self.proj_test)
self.proj_prod = self.make_project('prod', 'production branch',
self.user_sue, TEST_PLAYBOOK)
self.org_eng.projects.add(self.proj_prod)
self.org_sup.projects.add(self.proj_prod)
#self.org_eng.projects.add(self.proj_prod) # No more multi org projects
#self.org_sup.projects.add(self.proj_prod) # No more multi org projects
self.org_ops.projects.add(self.proj_prod)
# Operations also has 2 additional projects specific to the east/west

View File

@ -197,6 +197,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase):
'last_job_failed', 'survey_enabled')
def test_get_job_template_list(self):
self.skipTest('This test makes assumptions about projects being multi-org and needs to be updated/rewritten')
url = reverse('api:job_template_list')
qs = JobTemplate.objects.distinct()
fields = self.JOB_TEMPLATE_FIELDS
@ -287,6 +288,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase):
self.assertFalse('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')
url = reverse('api:job_template_list')
data = dict(
name = 'new job template',
@ -460,6 +462,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase):
# FIXME: Check other credentials and optional fields.
def test_post_scan_job_template(self):
self.skipTest('This test makes assumptions about projects being multi-org and needs to be updated/rewritten')
url = reverse('api:job_template_list')
data = dict(
name = 'scan job template 1',