From 6eae492d28a06d518113367d56821614bc0e51fe Mon Sep 17 00:00:00 2001 From: Wayne Witzel III Date: Thu, 28 Jan 2016 10:58:44 -0500 Subject: [PATCH] updating commands tests updating test imports, again relocate base and make tests a module added pytest config for awx/lib/site-packages restrucuting more test imports more test refactoring refactoring commands tests --- awx/main/tests/__init__.py | 0 awx/main/tests/{functional => }/base.py | 0 awx/main/tests/data/__init__.py | 0 .../data/large_ec2_inventory.py | 0 .../tests/{functional => }/data/largeinv.py | 0 .../{functional => }/data/splunk_inventory.py | 0 awx/main/tests/data/ssh.py | 169 ++++++++++++++++ awx/main/tests/functional/activity_stream.py | 2 +- awx/main/tests/functional/ad_hoc.py | 8 +- .../tests/functional/commands/age_deleted.py | 4 +- .../functional/commands/cleanup_facts.py | 4 +- .../commands/{base.py => command_base.py} | 2 +- .../commands/commands_monolithic.py | 2 +- .../functional/commands/remove_instance.py | 4 +- .../commands/run_fact_cache_receiver.py | 4 +- .../functional/commands/update_password.py | 4 +- awx/main/tests/functional/fact/fact_api.py | 2 +- awx/main/tests/functional/inventory.py | 52 ++--- .../functional/jobs/{base.py => job_base.py} | 4 +- awx/main/tests/functional/jobs/job_launch.py | 2 +- .../tests/functional/jobs/job_relaunch.py | 4 +- .../tests/functional/jobs/jobs_monolithic.py | 30 +-- .../tests/functional/jobs/start_cancel.py | 6 +- .../tests/functional/jobs/survey_password.py | 2 +- awx/main/tests/functional/licenses.py | 6 +- awx/main/tests/functional/organizations.py | 32 +-- awx/main/tests/functional/projects.py | 32 +-- awx/main/tests/functional/redact.py | 18 +- awx/main/tests/functional/schedules.py | 2 +- awx/main/tests/functional/scripts.py | 4 +- awx/main/tests/functional/settings.py | 2 +- awx/main/tests/functional/tasks.py | 183 +----------------- awx/main/tests/functional/users.py | 28 +-- awx/main/tests/functional/views.py | 9 +- pytest.ini | 1 + 35 files changed, 319 insertions(+), 303 deletions(-) create mode 100644 awx/main/tests/__init__.py rename awx/main/tests/{functional => }/base.py (100%) create mode 100644 awx/main/tests/data/__init__.py rename awx/main/tests/{functional => }/data/large_ec2_inventory.py (100%) rename awx/main/tests/{functional => }/data/largeinv.py (100%) rename awx/main/tests/{functional => }/data/splunk_inventory.py (100%) create mode 100644 awx/main/tests/data/ssh.py rename awx/main/tests/functional/commands/{base.py => command_base.py} (98%) rename awx/main/tests/functional/jobs/{base.py => job_base.py} (99%) diff --git a/awx/main/tests/__init__.py b/awx/main/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/awx/main/tests/functional/base.py b/awx/main/tests/base.py similarity index 100% rename from awx/main/tests/functional/base.py rename to awx/main/tests/base.py diff --git a/awx/main/tests/data/__init__.py b/awx/main/tests/data/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/awx/main/tests/functional/data/large_ec2_inventory.py b/awx/main/tests/data/large_ec2_inventory.py similarity index 100% rename from awx/main/tests/functional/data/large_ec2_inventory.py rename to awx/main/tests/data/large_ec2_inventory.py diff --git a/awx/main/tests/functional/data/largeinv.py b/awx/main/tests/data/largeinv.py similarity index 100% rename from awx/main/tests/functional/data/largeinv.py rename to awx/main/tests/data/largeinv.py diff --git a/awx/main/tests/functional/data/splunk_inventory.py b/awx/main/tests/data/splunk_inventory.py similarity index 100% rename from awx/main/tests/functional/data/splunk_inventory.py rename to awx/main/tests/data/splunk_inventory.py diff --git a/awx/main/tests/data/ssh.py b/awx/main/tests/data/ssh.py new file mode 100644 index 0000000000..ff5592358e --- /dev/null +++ b/awx/main/tests/data/ssh.py @@ -0,0 +1,169 @@ +TEST_SSH_KEY_DATA = '''-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAyQ8F5bbgjHvk4SZJsKI9OmJKMFxZqRhvx4LaqjLTKbBwRBsY +1/C00NPiZn70dKbeyV7RNVZxuzM6yd3D3lwTdbDu/eJ0x72t3ch+TdLt/aenyy10 +IvZyhSlxCLDkDaVVPFYJOQzVS8TkdOi6ZHc+R0c0A+4ZE8OQ8C0zIKtUTHqRk4/v +gYK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PApQH5EkXQp9BALbH23/Qs0G4sbJ +dKMxT0jGAPCMr7VrLKgRarXxXVImdy99NOAVNGO2+PbGZcEyA9/MJjO71nFb9mgp +1iOVjHmPThUVg90JvWC3QIsYTZ5RiR2Yzqfr0gDsslGb/9LPxLcPbBbKB12l3rKM +6amswvcCgYEAvgcSlTfAkI3ac8rB70HuDmSdqKblIiQjtPtT/ixXaFkZOmHRr4AE +KepMRDnaO/ldPDPEWCGqPzEM0t/0jS8/hCu3zLHHpZ+0LnHq+EXkOI0/GB4P+z5l +Vz3kouC0BTav0rCEnDop/cWMTiAp/XhKXfrTTTOra/F8l2xD8n/mnzY= +-----END RSA PRIVATE KEY-----''' + +TEST_SSH_KEY_DATA_LOCKED = '''-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,6B4E92AF4C29DE26FD8535D81825BDE6 + +pg8YplxPpfzgEGUiko34DGaYklyGyYKXjOrGFGyLoquNAVNFyewT34dDrZi0IAaE +79wMVcdlHbrJfZz8ML8I/ft6zM6BdlwZExH4y9DRAaktY3yIXxSvowBQ6ljh3wUy +M6m0afOfVjT22V8hLFgX0yTQ6P9zTG1cmj6+JQWTsMJ5EP3rnFK5CyrJXP48B3GI +GgE66rkXDvcKlVeIrbrpcTyfmEpafPgVRJYCDFXxeO/BfKgUFVxFq1PgFbvGQMmD +wA6EsyRrN+aoub1sqzj8tM8e4nwEi0EifdRShkFeqH4GUOKypanTXfCqwFBgYi5a +i3YwSnniZZPwCniGR5cl8oetrc5dubq/IR0txsGi2lO6zJEWdSer/EadS0QAll4S +yXrSc/lFaez1VmVe/8aoBKDOHhe7jV3YXAuqCeB4o/SThB/9Gad44MTbqFH3d7cD +k+F0Cjup7LZqZpXeB7ZHRG/Yt9MtBzwDVmEWaxA1WIN5a8xyZEVzRswSi4lZX69z +Va7eTKcrCbHOQmIbLZGRiZbAbfgriwwxQCJWELv80h+A754Bhi23n3WzcT094fRi +cqK//HcHHXxYGmr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S3Q4lS3dxg+gdvgzFHvQd/SV5IDhmLWL +L5Hj+B02+FAiz8zVGumbVykvPtzgTb0E+0rJKNO0/EgGqWsk/oC0 +-----END RSA PRIVATE KEY----- +""" + +TEST_SSH_KEY_DATA_UNLOCK = 'unlockme' diff --git a/awx/main/tests/functional/activity_stream.py b/awx/main/tests/functional/activity_stream.py index 81ebb7dc66..9798695954 100644 --- a/awx/main/tests/functional/activity_stream.py +++ b/awx/main/tests/functional/activity_stream.py @@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse # AWX from awx.main.models import * # noqa -from .base import BaseTest +from awx.main.tests.base import BaseTest class ActivityStreamTest(BaseTest): diff --git a/awx/main/tests/functional/ad_hoc.py b/awx/main/tests/functional/ad_hoc.py index 154a8d69ec..d0e75d2f19 100644 --- a/awx/main/tests/functional/ad_hoc.py +++ b/awx/main/tests/functional/ad_hoc.py @@ -18,8 +18,8 @@ from crum import impersonate # AWX from awx.main.utils import * # noqa from awx.main.models import * # noqa -from .base import BaseJobExecutionTest -from .tasks import TEST_SSH_KEY_DATA, TEST_SSH_KEY_DATA_LOCKED, TEST_SSH_KEY_DATA_UNLOCK +from awx.main.tests.base import BaseJobExecutionTest +from tasks import TEST_SSH_KEY_DATA, TEST_SSH_KEY_DATA_LOCKED, TEST_SSH_KEY_DATA_UNLOCK __all__ = ['RunAdHocCommandTest', 'AdHocCommandApiTest'] @@ -568,7 +568,7 @@ class AdHocCommandApiTest(BaseAdHocCommandTest): with self.current_user('admin'): response = self.run_test_ad_hoc_command(become_enabled=True) self.assertEqual(response['become_enabled'], True) - + # Try to run with expired license. self.create_expired_license_file() with self.current_user('admin'): @@ -1199,7 +1199,7 @@ class AdHocCommandApiTest(BaseAdHocCommandTest): with self.current_user('admin'): response = self.run_test_ad_hoc_command() - # Test the ad hoc command events list for a host. Should return the + # Test the ad hoc command events list for a host. Should return the # events only for that particular host. url = reverse('api:host_ad_hoc_command_events_list', args=(self.host.pk,)) with self.current_user('admin'): diff --git a/awx/main/tests/functional/commands/age_deleted.py b/awx/main/tests/functional/commands/age_deleted.py index eec90814d1..ec5591d28e 100644 --- a/awx/main/tests/functional/commands/age_deleted.py +++ b/awx/main/tests/functional/commands/age_deleted.py @@ -2,8 +2,8 @@ # All Rights Reserved # AWX -from ..base import BaseTest -from .base import BaseCommandMixin +from awx.main.tests.base import BaseTest +from command_base import BaseCommandMixin __all__ = ['AgeDeletedCommandFunctionalTest'] diff --git a/awx/main/tests/functional/commands/cleanup_facts.py b/awx/main/tests/functional/commands/cleanup_facts.py index a637340bd0..fc0f049aad 100644 --- a/awx/main/tests/functional/commands/cleanup_facts.py +++ b/awx/main/tests/functional/commands/cleanup_facts.py @@ -10,9 +10,9 @@ import mock from django.core.management.base import CommandError # AWX -from ..base import BaseTest +from awx.main.tests.base import BaseTest from awx.fact.tests.base import MongoDBRequired, FactScanBuilder, TEST_FACT_PACKAGES, TEST_FACT_ANSIBLE, TEST_FACT_SERVICES -from .base import BaseCommandMixin +from command_base import BaseCommandMixin from awx.main.management.commands.cleanup_facts import Command, CleanupFacts from awx.fact.models.fact import * # noqa diff --git a/awx/main/tests/functional/commands/base.py b/awx/main/tests/functional/commands/command_base.py similarity index 98% rename from awx/main/tests/functional/commands/base.py rename to awx/main/tests/functional/commands/command_base.py index 10d2096c41..2f1d795d27 100644 --- a/awx/main/tests/functional/commands/base.py +++ b/awx/main/tests/functional/commands/command_base.py @@ -11,7 +11,7 @@ from django.core.management import call_command # AWX from awx.main.models import * # noqa -from ..base import BaseTestMixin +from awx.main.tests.base import BaseTestMixin class BaseCommandMixin(BaseTestMixin): def create_test_inventories(self): diff --git a/awx/main/tests/functional/commands/commands_monolithic.py b/awx/main/tests/functional/commands/commands_monolithic.py index fa69a13742..13dae57177 100644 --- a/awx/main/tests/functional/commands/commands_monolithic.py +++ b/awx/main/tests/functional/commands/commands_monolithic.py @@ -24,7 +24,7 @@ from django.test.utils import override_settings # AWX from awx.main.models import * # noqa -from ..base import BaseTest, BaseLiveServerTest +from awx.main.tests.base import BaseTest, BaseLiveServerTest __all__ = ['CreateDefaultOrgTest', 'DumpDataTest', 'CleanupDeletedTest', 'CleanupJobsTest', 'CleanupActivityStreamTest', diff --git a/awx/main/tests/functional/commands/remove_instance.py b/awx/main/tests/functional/commands/remove_instance.py index f9713457bd..6fa8d65d4b 100644 --- a/awx/main/tests/functional/commands/remove_instance.py +++ b/awx/main/tests/functional/commands/remove_instance.py @@ -5,8 +5,8 @@ import uuid # AWX -from ..base import BaseTest -from .base import BaseCommandMixin +from awx.main.tests.base import BaseTest +from command_base import BaseCommandMixin from awx.main.models import * # noqa __all__ = ['RemoveInstanceCommandFunctionalTest'] diff --git a/awx/main/tests/functional/commands/run_fact_cache_receiver.py b/awx/main/tests/functional/commands/run_fact_cache_receiver.py index f5d5e5da09..7dedf7657a 100644 --- a/awx/main/tests/functional/commands/run_fact_cache_receiver.py +++ b/awx/main/tests/functional/commands/run_fact_cache_receiver.py @@ -10,9 +10,9 @@ from copy import deepcopy from mock import MagicMock # AWX -from ..base import BaseTest +from awx.main.tests.base import BaseTest from awx.fact.tests.base import MongoDBRequired -from .base import BaseCommandMixin +from command_base import BaseCommandMixin from awx.main.management.commands.run_fact_cache_receiver import FactCacheReceiver from awx.fact.models.fact import * # noqa diff --git a/awx/main/tests/functional/commands/update_password.py b/awx/main/tests/functional/commands/update_password.py index ec89892c1d..cecbb1667d 100644 --- a/awx/main/tests/functional/commands/update_password.py +++ b/awx/main/tests/functional/commands/update_password.py @@ -2,8 +2,8 @@ # All Rights Reserved # AWX -from ..base import BaseTest -from .base import BaseCommandMixin +from awx.main.tests.base import BaseTest +from command_base import BaseCommandMixin # Django from django.core.management.base import CommandError diff --git a/awx/main/tests/functional/fact/fact_api.py b/awx/main/tests/functional/fact/fact_api.py index 36038b987f..d13b17f060 100644 --- a/awx/main/tests/functional/fact/fact_api.py +++ b/awx/main/tests/functional/fact/fact_api.py @@ -10,7 +10,7 @@ from django.core.urlresolvers import reverse # AWX from awx.main.utils import timestamp_apiformat from awx.main.models import * # noqa -from ..base import BaseLiveServerTest +from awx.main.tests.base import BaseLiveServerTest from awx.fact.models import * # noqa from awx.fact.tests.base import BaseFactTestMixin, FactScanBuilder, TEST_FACT_ANSIBLE, TEST_FACT_PACKAGES, TEST_FACT_SERVICES from awx.main.utils import build_url diff --git a/awx/main/tests/functional/inventory.py b/awx/main/tests/functional/inventory.py index 08c2378bc9..9503b4232c 100644 --- a/awx/main/tests/functional/inventory.py +++ b/awx/main/tests/functional/inventory.py @@ -18,7 +18,7 @@ from django.utils.timezone import now # AWX from awx.main.models import * # noqa -from .base import BaseTest, BaseTransactionTest +from awx.main.tests.base import BaseTest, BaseTransactionTest __all__ = ['InventoryTest', 'InventoryUpdatesTest', 'InventoryCredentialTest'] @@ -151,11 +151,11 @@ class InventoryTest(BaseTest): def test_put_inventory_detail(self): url_a = reverse('api:inventory_detail', args=(self.inventory_a.pk,)) url_b = reverse('api:inventory_detail', args=(self.inventory_b.pk,)) - + # Check put to detail view with invalid authentication. self.check_invalid_auth(url_a, methods=('put',)) self.check_invalid_auth(url_b, methods=('put',)) - + # a super user can update inventory records with self.current_user(self.super_django_user): data = self.get(url_a, expect=200) @@ -200,7 +200,7 @@ class InventoryTest(BaseTest): self.put(url_a, data, expect=403) # Via AC-376: - # Create an inventory. Leave the description empty. + # Create an inventory. Leave the description empty. # Edit the new inventory, change the Name, click Save. list_url = reverse('api:inventory_list') new_data = dict(name='inventory-c', description='', @@ -220,13 +220,13 @@ class InventoryTest(BaseTest): def test_delete_inventory_detail(self): url_a = reverse('api:inventory_detail', args=(self.inventory_a.pk,)) url_b = reverse('api:inventory_detail', args=(self.inventory_b.pk,)) - + # Create test hosts and groups within each inventory. self.inventory_a.hosts.create(name='host-a') self.inventory_a.groups.create(name='group-a') self.inventory_b.hosts.create(name='host-b') self.inventory_b.groups.create(name='group-b') - + # Check put to detail view with invalid authentication. self.check_invalid_auth(url_a, methods=('delete',)) self.check_invalid_auth(url_b, methods=('delete',)) @@ -487,7 +487,7 @@ class InventoryTest(BaseTest): self.post(url5, data=new_group_d, expect=400, auth=self.get_other_credentials()) got = self.get(url5, expect=200, auth=self.get_other_credentials()) self.assertEquals(got['count'], 5) - + # side check: see if root groups URL is operational. These are groups without parents. root_groups = self.get(root_groups, expect=200, auth=self.get_super_credentials()) self.assertEquals(root_groups['count'], 2) @@ -497,7 +497,7 @@ class InventoryTest(BaseTest): self.post(url5, data=remove_me, expect=204, auth=self.get_other_credentials()) got = self.get(url5, expect=200, auth=self.get_other_credentials()) self.assertEquals(got['count'], 4) - + ################################################### # VARIABLES @@ -507,31 +507,31 @@ class InventoryTest(BaseTest): # attempting to get a variable object creates it, even though it does not already exist vdata_url = reverse('api:host_variable_data', args=(added_by_collection_a['id'],)) - + got = self.get(vdata_url, expect=200, auth=self.get_super_credentials()) self.assertEquals(got, {}) # super user can create variable objects # an org admin can create variable objects (defers to inventory permissions) got = self.put(vdata_url, data=vars_a, expect=200, auth=self.get_super_credentials()) - self.assertEquals(got, vars_a) + self.assertEquals(got, vars_a) - # verify that we can update things and get them back + # verify that we can update things and get them back got = self.put(vdata_url, data=vars_c, expect=200, auth=self.get_super_credentials()) - self.assertEquals(got, vars_c) + self.assertEquals(got, vars_c) got = self.get(vdata_url, expect=200, auth=self.get_super_credentials()) - self.assertEquals(got, vars_c) + self.assertEquals(got, vars_c) # a normal user cannot edit variable objects self.put(vdata_url, data=vars_a, expect=403, auth=self.get_nobody_credentials()) # a normal user with inventory write permissions can edit variable objects... got = self.put(vdata_url, data=vars_b, expect=200, auth=self.get_normal_credentials()) - self.assertEquals(got, vars_b) + self.assertEquals(got, vars_b) ################################################### # VARIABLES -> GROUPS - + vars_a = dict(asdf=7777, dog='droopy', cat='battlecat', unstructured=dict(a=[1,1,1],b=dict(x=1,y=2))) vars_b = dict(asdf=8888, dog='snoopy', cat='cheshire', unstructured=dict(a=[2,2,2],b=dict(x=3,y=4))) vars_c = dict(asdf=9999, dog='pluto', cat='five', unstructured=dict(a=[3,3,3],b=dict(z=5))) @@ -547,7 +547,7 @@ class InventoryTest(BaseTest): # an org admin can associate variable objects with groups put = self.put(vdata1_url, data=vars_b, expect=200, auth=self.get_normal_credentials()) - + # a normal user cannot associate variable objects with groups put = self.put(vdata1_url, data=vars_b, expect=403, auth=self.get_nobody_credentials()) @@ -557,11 +557,11 @@ class InventoryTest(BaseTest): ################################################### # VARIABLES -> INVENTORY - + vars_a = dict(asdf=9873, dog='lassie', cat='heathcliff', unstructured=dict(a=[1,1,1],b=dict(x=1,y=2))) vars_b = dict(asdf=2736, dog='benji', cat='garfield', unstructured=dict(a=[2,2,2],b=dict(x=3,y=4))) vars_c = dict(asdf=7692, dog='buck', cat='sylvester', unstructured=dict(a=[3,3,3],b=dict(z=5))) - + vdata_url = reverse('api:inventory_variable_data', args=(self.inventory_a.pk,)) # a super user can associate variable objects with inventory @@ -700,7 +700,7 @@ class InventoryTest(BaseTest): new_data = dict(inventory=inv.pk, name='completely new', description='blarg?') kids = self.get(subgroups_url2, expect=200, auth=self.get_normal_credentials()) self.assertEqual(kids['count'], 1) - posted2 = self.post(subgroups_url2, data=new_data, expect=201, auth=self.get_normal_credentials()) + posted2 = self.post(subgroups_url2, data=new_data, expect=201, auth=self.get_normal_credentials()) # a group can't be it's own grandparent subsub = posted2['related']['children'] @@ -715,16 +715,16 @@ class InventoryTest(BaseTest): # double post causes conflict error (actually, should it? -- just got a 204, already associated) # self.post(subgroups_url2, data=got, expect=409, auth=self.get_normal_credentials()) - checked = self.get(subgroups_url2, expect=200, auth=self.get_normal_credentials()) + checked = self.get(subgroups_url2, expect=200, auth=self.get_normal_credentials()) # a normal user cannot set subgroups self.post(subgroups_url3, data=got, expect=403, auth=self.get_nobody_credentials()) # a normal user with inventory edit permissions can associate subgroups (but not when they belong to different inventories!) #self.post(subgroups_url3, data=got, expect=204, auth=self.get_other_credentials()) - #checked = self.get(subgroups_url3, expect=200, auth=self.get_normal_credentials()) + #checked = self.get(subgroups_url3, expect=200, auth=self.get_normal_credentials()) #self.assertEqual(checked['count'], 1) - + # slight detour # can see all hosts under a group, even if it has subgroups # this URL is NOT postable @@ -739,7 +739,7 @@ class InventoryTest(BaseTest): result = checked['results'][0] result['disassociate'] = 1 self.post(subgroups_url3, data=result, expect=204, auth=self.get_other_credentials()) - checked = self.get(subgroups_url3, expect=200, auth=self.get_normal_credentials()) + checked = self.get(subgroups_url3, expect=200, auth=self.get_normal_credentials()) self.assertEqual(checked['count'], 0) # try to double disassociate to see what happens (should no-op) self.post(subgroups_url3, data=result, expect=204, auth=self.get_other_credentials()) @@ -803,7 +803,7 @@ class InventoryTest(BaseTest): # FIXME: RELATED FIELDS # on an inventory resource, I can see related resources for hosts and groups and permissions - # and these work + # and these work # on a host resource, I can see related resources variables and inventories # and these work # on a group resource, I can see related resources for variables, inventories, and children @@ -884,11 +884,11 @@ class InventoryTest(BaseTest): g_d = self.inventory_a.groups.create(name='D') g_d.inventory_source g_d.parents.add(g_c) - + url = reverse('api:inventory_tree_view', args=(self.inventory_a.pk,)) with self.current_user(self.super_django_user): response = self.get(url, expect=200) - + self.assertTrue(isinstance(response, list)) self.assertEqual(len(response), 1) self.assertEqual(response[0]['id'], g_a.pk) diff --git a/awx/main/tests/functional/jobs/base.py b/awx/main/tests/functional/jobs/job_base.py similarity index 99% rename from awx/main/tests/functional/jobs/base.py rename to awx/main/tests/functional/jobs/job_base.py index 1c45e94e4d..769ba406a5 100644 --- a/awx/main/tests/functional/jobs/base.py +++ b/awx/main/tests/functional/jobs/job_base.py @@ -3,7 +3,7 @@ import uuid # AWX from awx.main.models import * # noqa -from ..base import BaseTestMixin +from awx.main.tests.base import BaseTestMixin TEST_PLAYBOOK = '''- hosts: all gather_facts: false @@ -256,7 +256,7 @@ class BaseJobTestMixin(BaseTestMixin): self.team_ops_testers.users.add(self.user_billybob) # Each user has his/her own set of credentials. - from ..tasks import (TEST_SSH_KEY_DATA, + from awx.main.tests.data.ssh import (TEST_SSH_KEY_DATA, TEST_SSH_KEY_DATA_LOCKED, TEST_SSH_KEY_DATA_UNLOCK) self.cred_sue = self.user_sue.credentials.create( diff --git a/awx/main/tests/functional/jobs/job_launch.py b/awx/main/tests/functional/jobs/job_launch.py index 66a0ca5a72..00bfbb8b2b 100644 --- a/awx/main/tests/functional/jobs/job_launch.py +++ b/awx/main/tests/functional/jobs/job_launch.py @@ -10,7 +10,7 @@ from django.core.urlresolvers import reverse # AWX from awx.main.models import * # noqa -from .base import BaseJobTestMixin +from job_base import BaseJobTestMixin import yaml __all__ = ['JobTemplateLaunchTest', 'JobTemplateLaunchPasswordsTest'] diff --git a/awx/main/tests/functional/jobs/job_relaunch.py b/awx/main/tests/functional/jobs/job_relaunch.py index 6fcc1b8b82..0c9eff99bd 100644 --- a/awx/main/tests/functional/jobs/job_relaunch.py +++ b/awx/main/tests/functional/jobs/job_relaunch.py @@ -10,8 +10,8 @@ from django.core.urlresolvers import reverse # AWX from awx.main.models import * # noqa -from ..base import BaseLiveServerTest -from .base import BaseJobTestMixin +from awx.main.tests.base import BaseLiveServerTest +from job_base import BaseJobTestMixin __all__ = ['JobRelaunchTest',] diff --git a/awx/main/tests/functional/jobs/jobs_monolithic.py b/awx/main/tests/functional/jobs/jobs_monolithic.py index 7f3e337503..0ea0661cd7 100644 --- a/awx/main/tests/functional/jobs/jobs_monolithic.py +++ b/awx/main/tests/functional/jobs/jobs_monolithic.py @@ -22,7 +22,7 @@ import requests # AWX from awx.main.models import * # noqa -from base import BaseJobTestMixin +from job_base import BaseJobTestMixin __all__ = ['JobTemplateTest', 'JobTest', 'JobTemplateCallbackTest', 'JobTransactionTest', 'JobTemplateSurveyTest'] @@ -218,7 +218,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TestCase): resp = self.get(url, expect=200) print [x['name'] for x in resp['results']] self.assertEquals(resp['count'], 3) - + # Chuck has permission to see all Eng Job Templates as Lead Engineer # Note: Since chuck is an org admin he can also see the support scan template with self.current_user(self.user_chuck): @@ -270,7 +270,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TestCase): resp = self.get(url, expect=200) print [x['name'] for x in resp['results']] self.assertEquals(resp['count'], 6) - + def test_credentials_list(self): url = reverse('api:credential_list') @@ -331,7 +331,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TestCase): d['job_type'] = 'world domination' response = self.post(url, d, expect=400) self.assertTrue('job_type' in response) - + # Test playbook not in list of project playbooks. with self.current_user(self.user_sue): d = dict(data.items()) @@ -603,11 +603,11 @@ class JobTest(BaseJobTestMixin, django.test.TestCase): data = self.get('/api/v1/job_templates/', expect=401) data = self.get('/api/v1/job_templates/', expect=200, auth=self.get_normal_credentials()) self.assertTrue(data['count'], 2) - + rec = dict( - name = 'job-foo', - credential = self.credential.pk, - inventory = self.inventory.pk, + name = 'job-foo', + credential = self.credential.pk, + inventory = self.inventory.pk, project = self.project.pk, job_type = PERM_INVENTORY_DEPLOY ) @@ -617,7 +617,7 @@ class JobTest(BaseJobTestMixin, django.test.TestCase): self.assertEquals(posted['url'], '/api/v1/job_templates/3/') # other_django_user is on a team that can deploy, so can create both deploy and check type jobs - rec['name'] = 'job-foo2' + rec['name'] = 'job-foo2' posted = self.post('/api/v1/job_templates/', rec, expect=201, auth=self.get_other_credentials()) rec['name'] = 'job-foo3' rec['job_type'] = PERM_INVENTORY_CHECK @@ -732,7 +732,7 @@ class JobTemplateCallbackTest(BaseJobTestMixin, django.test.LiveServerTestCase): raise socket.herror('unknown test host') raddr = '.'.join(list(reversed(ip.split('.'))) + ['in-addr', 'arpa']) return (host, [raddr], [ip]) - + def getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0): if family or socktype or proto or flags: return self._original_getaddrinfo(host, port, family, socktype, @@ -765,7 +765,7 @@ class JobTemplateCallbackTest(BaseJobTestMixin, django.test.LiveServerTestCase): host_vars['ansible_ssh_host'] = ip host.variables = json.dumps(host_vars) host.save() - + # Find a valid job template to use to test the callback. job_template = None qs = JobTemplate.objects.filter(job_type='run', @@ -1095,7 +1095,7 @@ class JobTemplateSurveyTest(BaseJobTestMixin, django.test.TestCase): jt_url = reverse('api:job_template_detail', args=(response['id'],)) with self.current_user(self.user_sue): self.patch(jt_url, dict(survey_enabled=True), expect=402) - + def test_post_job_template_survey(self): url = reverse('api:job_template_list') data = dict( @@ -1220,11 +1220,11 @@ class JobTemplateSurveyTest(BaseJobTestMixin, django.test.TestCase): self.get(url, expect=200) with self.current_user(self.user_chuck): - self.get(url, expect=200) + self.get(url, expect=200) # Doug and Juan can't with self.current_user(self.user_doug): self.get(url, expect=403) - + with self.current_user(self.user_juan): - self.get(url, expect=403) + self.get(url, expect=403) diff --git a/awx/main/tests/functional/jobs/start_cancel.py b/awx/main/tests/functional/jobs/start_cancel.py index 676ad13f3b..afacb4f863 100644 --- a/awx/main/tests/functional/jobs/start_cancel.py +++ b/awx/main/tests/functional/jobs/start_cancel.py @@ -10,8 +10,8 @@ from django.conf import settings # AWX from awx.main.models import * # noqa -from ..base import BaseLiveServerTest -from .base import BaseJobTestMixin +from awx.main.tests.base import BaseLiveServerTest +from job_base import BaseJobTestMixin __all__ = ['JobStartCancelTest',] @@ -92,7 +92,7 @@ class JobStartCancelTest(BaseJobTestMixin, BaseLiveServerTest): # self.assertEqual(job.status, 'failed') # Test with a job that prompts for SSH unlock key, given the right key. - from ..tasks import TEST_SSH_KEY_DATA_UNLOCK + from awx.main.tests.data.ssh import TEST_SSH_KEY_DATA_UNLOCK # job = self.jt_ops_west_run.create_job( # credential=self.cred_greg, # created_by=self.user_sue, diff --git a/awx/main/tests/functional/jobs/survey_password.py b/awx/main/tests/functional/jobs/survey_password.py index fc46fcfc48..f7588301d8 100644 --- a/awx/main/tests/functional/jobs/survey_password.py +++ b/awx/main/tests/functional/jobs/survey_password.py @@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse # AWX from awx.main.models import * # noqa -from ..base import BaseTest, QueueStartStopTestMixin +from awx.main.tests.base import BaseTest, QueueStartStopTestMixin __all__ = ['SurveyPasswordRedactedTest'] diff --git a/awx/main/tests/functional/licenses.py b/awx/main/tests/functional/licenses.py index 0c0c43fcfa..d6cde2a0a4 100644 --- a/awx/main/tests/functional/licenses.py +++ b/awx/main/tests/functional/licenses.py @@ -6,7 +6,7 @@ import os import tempfile from awx.main.models import Host, Inventory, Organization -from .base import BaseTest +from awx.main.tests.base import BaseTest import awx.main.task_engine from awx.main.task_engine import * # noqa @@ -46,7 +46,7 @@ class LicenseTests(BaseTest): def test_license_writer(self): - writer = TaskEngager( + writer = TaskEngager( company_name='acmecorp', contact_name='Michael DeHaan', contact_email='michael@ansibleworks.com', @@ -58,7 +58,7 @@ class LicenseTests(BaseTest): assert data['instance_count'] == 500 assert data['contact_name'] == 'Michael DeHaan' assert data['contact_email'] == 'michael@ansibleworks.com' - assert data['license_date'] == 25000 + assert data['license_date'] == 25000 assert data['license_key'] == "11bae31f31c6a6cdcb483a278cdbe98bd8ac5761acd7163a50090b0f098b3a13" strdata = writer.get_string() diff --git a/awx/main/tests/functional/organizations.py b/awx/main/tests/functional/organizations.py index e10d6dd92a..cf3c64ab87 100644 --- a/awx/main/tests/functional/organizations.py +++ b/awx/main/tests/functional/organizations.py @@ -12,7 +12,7 @@ from django.utils.timezone import now as tz_now # AWX from awx.main.models import * # noqa -from .base import BaseTest +from awx.main.tests.base import BaseTest __all__ = ['AuthTokenLimitUnitTest', 'OrganizationsTest'] @@ -62,7 +62,7 @@ class OrganizationsTest(BaseTest): # TODO: Test non-enterprise license self.create_test_license_file() self.setup_users() - + self.organizations = self.make_organizations(self.super_django_user, 10) self.projects = self.make_projects(self.normal_django_user, 10) @@ -71,7 +71,7 @@ class OrganizationsTest(BaseTest): self.organizations[0].projects.add(project) for project in self.projects[3:8]: self.organizations[1].projects.add(project) - for project in self.projects[9:10]: + for project in self.projects[9:10]: self.organizations[2].projects.add(project) self.organizations[0].projects.add(self.projects[-1]) self.organizations[9].projects.add(self.projects[-2]) @@ -91,7 +91,7 @@ class OrganizationsTest(BaseTest): x.admins.add(self.super_django_user) x.users.add(self.super_django_user) x.users.add(self.other_django_user) - + self.organizations[0].users.add(self.normal_django_user) self.organizations[1].admins.add(self.normal_django_user) @@ -251,11 +251,11 @@ class OrganizationsTest(BaseTest): def test_post_item(self): new_org = dict(name='magic test org', description='8675309') - + # need to be a valid user self.post(self.collection(), new_org, expect=401, auth=None) self.post(self.collection(), new_org, expect=401, auth=self.get_invalid_credentials()) - + # only super users can create organizations self.post(self.collection(), new_org, expect=403, auth=self.get_normal_credentials()) self.post(self.collection(), new_org, expect=403, auth=self.get_other_credentials()) @@ -267,22 +267,22 @@ class OrganizationsTest(BaseTest): # look at what we got back from the post, make sure we added an org last_org = Organization.objects.order_by('-pk')[0] self.assertTrue(data1['url'].endswith("/%d/" % last_org.pk)) - + # Test that not even super users can create an organization with a basic license self.create_basic_license_file() cant_org = dict(name='silly user org', description='4815162342') self.post(self.collection(), cant_org, expect=402, auth=self.get_super_credentials()) def test_post_item_subobjects_projects(self): - + # first get all the orgs orgs = self.get(self.collection(), expect=200, auth=self.get_super_credentials()) - + # find projects attached to the first org projects0_url = orgs['results'][0]['related']['projects'] projects1_url = orgs['results'][1]['related']['projects'] projects2_url = orgs['results'][2]['related']['projects'] - + # get all the projects on the first org projects0 = self.get(projects0_url, expect=200, auth=self.get_super_credentials()) a_project = projects0['results'][-1] @@ -303,7 +303,7 @@ class OrganizationsTest(BaseTest): self.post(projects1_url, a_project, expect=204, auth=self.get_super_credentials()) projects1 = self.get(projects1_url, expect=200, auth=self.get_super_credentials()) self.assertEquals(projects1['count'], 5) - + a_project = projects1['results'][-1] a_project['disassociate'] = 1 projects1 = self.get(projects1_url, expect=200, auth=self.get_super_credentials()) @@ -324,7 +324,7 @@ class OrganizationsTest(BaseTest): # and can't do post a project he can read to an organization he cannot self.post(projects2_url, dict(id=new_project_a.pk), expect=403, auth=self.get_normal_credentials()) - + def test_post_item_subobjects_users(self): @@ -411,8 +411,8 @@ class OrganizationsTest(BaseTest): # any attempt to put a subobject should be a 405, edit the actual resource or POST with 'disassociate' to delete # this is against a collection URL anyway, so we really need not repeat this test for other object types - # as a PUT against a collection doesn't make much sense. - + # as a PUT against a collection doesn't make much sense. + orgs = self.get(self.collection(), expect=200, auth=self.get_super_credentials()) projects0_url = orgs['results'][0]['related']['projects'] sub_projects = self.get(projects0_url, expect=200, auth=self.get_super_credentials()) @@ -425,14 +425,14 @@ class OrganizationsTest(BaseTest): # first get some urls urls = self.get_urls(self.collection(), auth=self.get_super_credentials()) urldata1 = self.get(urls[1], auth=self.get_super_credentials()) - + # check authentication -- admins of the org and superusers can delete objects only self.delete(urls[0], expect=401, auth=None) self.delete(urls[0], expect=401, auth=self.get_invalid_credentials()) self.delete(urls[8], expect=403, auth=self.get_normal_credentials()) self.delete(urls[1], expect=204, auth=self.get_normal_credentials()) self.delete(urls[0], expect=204, auth=self.get_super_credentials()) - + # check that when we have deleted an object it comes back 404 via GET # but that it's still in the database as inactive self.get(urls[1], expect=404, auth=self.get_normal_credentials()) diff --git a/awx/main/tests/functional/projects.py b/awx/main/tests/functional/projects.py index eb1579fdea..b7378d14ef 100644 --- a/awx/main/tests/functional/projects.py +++ b/awx/main/tests/functional/projects.py @@ -20,8 +20,14 @@ from django.utils.timezone import now # AWX from awx.main.models import * # noqa -from .base import BaseTransactionTest -from .tasks import TEST_SSH_KEY_DATA, TEST_SSH_KEY_DATA_LOCKED, TEST_SSH_KEY_DATA_UNLOCK, TEST_OPENSSH_KEY_DATA, TEST_OPENSSH_KEY_DATA_LOCKED +from awx.main.tests.base import BaseTransactionTest +from awx.main.tests.data.ssh import ( + TEST_SSH_KEY_DATA, + TEST_SSH_KEY_DATA_LOCKED, + TEST_SSH_KEY_DATA_UNLOCK, + TEST_OPENSSH_KEY_DATA, + TEST_OPENSSH_KEY_DATA_LOCKED, +) from awx.main.utils import decrypt_field, update_scm_url TEST_PLAYBOOK = '''- hosts: mygroup @@ -238,7 +244,7 @@ class ProjectsTest(BaseTransactionTest): auth=self.get_super_credentials()) response = self.put(project_detail, project_data, expect=200, auth=self.get_super_credentials()) - + # cannot update using local_path from another project. project_data['local_path'] = self.projects[2].local_path response = self.put(project_detail, project_data, expect=400, @@ -391,14 +397,14 @@ class ProjectsTest(BaseTransactionTest): # ===================================================================== # TEAM PROJECTS - + team = Team.objects.filter(active=True, organization__pk=self.organizations[1].pk)[0] team_projects = reverse('api:team_projects_list', args=(team.pk,)) - + p1 = self.projects[0] team.projects.add(p1) team.save() - + got = self.get(team_projects, expect=200, auth=self.get_super_credentials()) # FIXME: project postablility tests somewhat incomplete. @@ -430,7 +436,7 @@ class ProjectsTest(BaseTransactionTest): self.post(team_users, data=dict(x, is_superuser=False), expect=204, auth=self.get_normal_credentials()) # The normal admin user can't create a super user vicariously through the team/project - self.post(team_users, data=dict(username='attempted_superuser_create', password='thepassword', + self.post(team_users, data=dict(username='attempted_superuser_create', password='thepassword', is_superuser=True), expect=403, auth=self.get_normal_credentials()) # ... but a superuser can self.post(team_users, data=dict(username='attempted_superuser_create', password='thepassword', @@ -682,7 +688,7 @@ class ProjectsTest(BaseTransactionTest): team = Team.objects.order_by('pk')[0] organization = Organization.objects.order_by('pk')[0] inventory = Inventory.objects.create( - name = 'test inventory', + name = 'test inventory', organization = organization, created_by = self.super_django_user ) @@ -691,10 +697,10 @@ class ProjectsTest(BaseTransactionTest): # can add permissions to a user user_permission = dict( - name='user can deploy a certain project to a certain inventory', + name='user can deploy a certain project to a certain inventory', # user=user.pk, # no need to specify, this will be automatically filled in - inventory=inventory.pk, - project=project.pk, + inventory=inventory.pk, + project=project.pk, permission_type=PERM_INVENTORY_DEPLOY ) team_permission = dict( @@ -993,7 +999,7 @@ class ProjectUpdatesTest(BaseTransactionTest): new_url = new_url or url new_url_u = new_url_u or url new_url_up = new_url_up or url - + # Check existing URL as-is. if is_exception(new_url): self.assertRaises(new_url, update_scm_url, scm_type, url) @@ -1130,7 +1136,7 @@ class ProjectUpdatesTest(BaseTransactionTest): after = file(path, 'rb').read() return path, before, after self.fail('no file found to change!') - + def check_project_scm(self, project): project = Project.objects.get(pk=project.pk) project_path = project.get_project_path(check_if_exists=False) diff --git a/awx/main/tests/functional/redact.py b/awx/main/tests/functional/redact.py index 40e8869398..3ce38bc7ad 100644 --- a/awx/main/tests/functional/redact.py +++ b/awx/main/tests/functional/redact.py @@ -3,7 +3,7 @@ import textwrap # AWX from awx.main.redact import UriCleaner -from .base import BaseTest, URI +from awx.main.tests.base import BaseTest, URI __all__ = ['UriCleanTests'] @@ -38,15 +38,15 @@ uri = URI(scheme="https", username="myusername", password="mypasswordwith%40", h TEST_CLEARTEXT.append({ 'uri' : uri, 'text' : textwrap.dedent("""\ - PLAY [all] ******************************************************************** + PLAY [all] ******************************************************************** - TASK: [delete project directory before update] ******************************** + TASK: [delete project directory before update] ******************************** skipping: [localhost] - TASK: [update project using git and accept hostkey] *************************** + TASK: [update project using git and accept hostkey] *************************** skipping: [localhost] - TASK: [update project using git] ********************************************** + TASK: [update project using git] ********************************************** failed: [localhost] => {"cmd": "/usr/bin/git ls-remote https://%s:%s -h refs/heads/HEAD", "failed": true, "rc": 128} stderr: fatal: unable to access '%s': Could not resolve host: nonexistant.ansible.com @@ -54,10 +54,10 @@ TEST_CLEARTEXT.append({ FATAL: all hosts have already failed -- aborting - PLAY RECAP ******************************************************************** + PLAY RECAP ******************************************************************** to retry, use: --limit @/root/project_update.retry - localhost : ok=0 changed=0 unreachable=0 failed=1 + localhost : ok=0 changed=0 unreachable=0 failed=1 """ % (uri.username, uri.password, str(uri), str(uri))), 'host_occurrences' : 2 @@ -69,11 +69,11 @@ TEST_CLEARTEXT.append({ 'text' : textwrap.dedent("""\ TASK: [update project using git] ** failed: [localhost] => {"cmd": "/usr/bin/git ls-remote https://REDACTED:********", "failed": true, "rc": 128} - stderr: error: Couldn't resolve host '@%s' while accessing %s + stderr: error: Couldn't resolve host '@%s' while accessing %s fatal: HTTP request failed - msg: error: Couldn't resolve host '@%s' while accessing %s + msg: error: Couldn't resolve host '@%s' while accessing %s fatal: HTTP request failed """ % (uri.host, str(uri), uri.host, str(uri))), diff --git a/awx/main/tests/functional/schedules.py b/awx/main/tests/functional/schedules.py index 1beeff6286..4a4a0bcee3 100644 --- a/awx/main/tests/functional/schedules.py +++ b/awx/main/tests/functional/schedules.py @@ -10,7 +10,7 @@ from django.utils.timezone import now # AWX from awx.main.models import * # noqa -from .base import BaseTest +from awx.main.tests.base import BaseTest __all__ = ['ScheduleTest'] diff --git a/awx/main/tests/functional/scripts.py b/awx/main/tests/functional/scripts.py index 50dd336ac2..bdd81a7f7e 100644 --- a/awx/main/tests/functional/scripts.py +++ b/awx/main/tests/functional/scripts.py @@ -10,7 +10,7 @@ import urlparse # AWX from awx.main.models import * # noqa -from .base import BaseLiveServerTest +from awx.main.tests.base import BaseLiveServerTest __all__ = ['InventoryScriptTest'] @@ -93,7 +93,7 @@ class InventoryScriptTest(BaseScriptTest): # add localhost just to make sure it's thrown into all (Ansible github bug) local = inventory.hosts.create(name='localhost', inventory=inventory, variables={}) - hosts.append(local) + hosts.append(local) self.hosts.extend(hosts) groups = [] diff --git a/awx/main/tests/functional/settings.py b/awx/main/tests/functional/settings.py index 14e4285d09..a727213454 100644 --- a/awx/main/tests/functional/settings.py +++ b/awx/main/tests/functional/settings.py @@ -1,7 +1,7 @@ # Copyright (c) 2016 Ansible, Inc. # All Rights Reserved. -from .base import BaseTest +from awx.main.tests.base import BaseTest from awx.main.models import * # noqa from django.core.urlresolvers import reverse diff --git a/awx/main/tests/functional/tasks.py b/awx/main/tests/functional/tasks.py index 7bf0648957..a57202a958 100644 --- a/awx/main/tests/functional/tasks.py +++ b/awx/main/tests/functional/tasks.py @@ -21,7 +21,14 @@ from crum import impersonate # AWX from awx.main.utils import * # noqa from awx.main.models import * # noqa -from .base import BaseJobExecutionTest +from awx.main.tests.base import BaseJobExecutionTest +from awx.main.tests.data.ssh import ( + TEST_SSH_KEY_DATA, + TEST_SSH_KEY_DATA_LOCKED, + TEST_OPENSSH_KEY_DATA, + TEST_SSH_CERT_KEY, + TEST_SSH_KEY_DATA_UNLOCK, +) TEST_PLAYBOOK = u''' - name: test success @@ -230,176 +237,6 @@ TEST_VAULT_PLAYBOOK = '''$ANSIBLE_VAULT;1.1;AES256 TEST_VAULT_PASSWORD = '1234' -TEST_SSH_KEY_DATA = '''-----BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAyQ8F5bbgjHvk4SZJsKI9OmJKMFxZqRhvx4LaqjLTKbBwRBsY -1/C00NPiZn70dKbeyV7RNVZxuzM6yd3D3lwTdbDu/eJ0x72t3ch+TdLt/aenyy10 -IvZyhSlxCLDkDaVVPFYJOQzVS8TkdOi6ZHc+R0c0A+4ZE8OQ8C0zIKtUTHqRk4/v -gYK5guhNS0DdgWkBj6K+r/9D4bqdPTJPt4S7H75vb1tBgseiqftEkLYOhTK2gsCi -5uJgpG4zPQY4Kk/97dbW7pwcvPkr1rKkAwEJ27Bfo+DBv3oEx3SinpXQtOrH1aEO -RHSXldBaymdBtVLUhjxDlnnQ7Ps+fNX04R7N4QIDAQABAoIBAQClEDxbNyRqsVxa -q8BbzxZNVFxsD6Vceb9rIDa8/DT4SO4iO8zNm8QWnZ2FYDz5d/X3hGxlSa7dbVWa -XQJtD1K6kKPks4IEaejP58Ypxj20vWu4Fnz+Jy4lvLwb0n2n5lBv1IKF389NATw9 -7sL3sB3lDsPZZiQYYbogNDuBWqc+kP0zD84bONsM/B2HMRm9BRv2UsZf+zKU4pTA -UqHffyjmw7LqHmbtVjwVcUsC+xcE4kCuWLvabFnTWOSnWECyIw2+trxKdwCXbfzG -s5rn4Dj+aEKimzFaRpTSVx6w4yw9xw/EjsSaZ88jKSpTP8ocCut6zv+P/JwlukEX -4A4FxqyxAoGBAOp3G9EIAAWijcIgO5OdiZNEqVyqd3yyPzT6d/q7bf4dpVCZiLNA -bRmge83aMc4g2Dpkn/++It3bDmnXXGg+BZSX5KT9JLklXchaw9phv9J0diZEUvYS -mSQafbUGIqYnYzns3TU0cbgITs1iVIEstHYjGr3J88nDG+HFCHboxa93AoGBANuG -cDFgyvm79+haK2fHhUCZgaFFYBpkpuz+zjDjzIytOzymWa2gD9jIa7mvdvoH2ge3 -AVG0vy+n9cJaqJMuLkhdI01wVlqY9wvDHFyZCXyIvKVPMljKeTvCNGCupsG4R171 -gSKT5ryOx58MGbE7knAZC+QWpwxFpdpbfej6g7NnAoGBAMz6ipAJbXN/tG0FnvAj -pxXfzizcPw/+CTI40tGaMMQbiN5ZC+CiL39bBUFnQ2mQ31jVheegg3zvuL8hb4EW -z+wjitoPEZ7nowC5EUaHdJr6BBzaWKkWg1nD6yhqj7ow7xfCE3YjPlQEt1fpYjV4 -LuClOgi4WPCIKYUMq6TBRaprAoGAVrEjs0xPPApQH5EkXQp9BALbH23/Qs0G4sbJ -dKMxT0jGAPCMr7VrLKgRarXxXVImdy99NOAVNGO2+PbGZcEyA9/MJjO71nFb9mgp -1iOVjHmPThUVg90JvWC3QIsYTZ5RiR2Yzqfr0gDsslGb/9LPxLcPbBbKB12l3rKM -6amswvcCgYEAvgcSlTfAkI3ac8rB70HuDmSdqKblIiQjtPtT/ixXaFkZOmHRr4AE -KepMRDnaO/ldPDPEWCGqPzEM0t/0jS8/hCu3zLHHpZ+0LnHq+EXkOI0/GB4P+z5l -Vz3kouC0BTav0rCEnDop/cWMTiAp/XhKXfrTTTOra/F8l2xD8n/mnzY= ------END RSA PRIVATE KEY-----''' - -TEST_SSH_KEY_DATA_LOCKED = '''-----BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-128-CBC,6B4E92AF4C29DE26FD8535D81825BDE6 - -pg8YplxPpfzgEGUiko34DGaYklyGyYKXjOrGFGyLoquNAVNFyewT34dDrZi0IAaE -79wMVcdlHbrJfZz8ML8I/ft6zM6BdlwZExH4y9DRAaktY3yIXxSvowBQ6ljh3wUy -M6m0afOfVjT22V8hLFgX0yTQ6P9zTG1cmj6+JQWTsMJ5EP3rnFK5CyrJXP48B3GI -GgE66rkXDvcKlVeIrbrpc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L6OhMti -LmuD4v8pOU+GP7U6oCs15slaKVUARFi80OlA3fmcyzgOQ6f/kV+NKzu0+ZsnY9p/ -hjsK4VsKZ6qgfJd1DgDLxusCgYArXCDcLRfycA9ascmG3sEhESkgOO0M2LN9zBpx -KqtfZ/cB2CgdZ3xzMylNPbkx7yuYXPNDoHbLQgNq1EfJ80P7VlmiCUDmrcNtWKsw -L9emRSnALx7nsPqnIAKG4dRX8Bpj1E67BXFTjtu7bFI0Im/0FFqIlnLSn6TDQGeT -Cf87gQKBgCgW/kFaQAhP5Pdb7oOQcaF4/dq50QNDyQMFOPKWHY/5IrsIrDVI5V/D -o1npLPB+YE3baQqo58JX1UuO83F4zlwzS3Q4lS3dxg+gdvgzFHvQd/SV5IDhmLWL -L5Hj+B02+FAiz8zVGumbVykvPtzgTb0E+0rJKNO0/EgGqWsk/oC0 ------END RSA PRIVATE KEY----- -""" - -TEST_SSH_KEY_DATA_UNLOCK = 'unlockme' - class RunJobTest(BaseJobExecutionTest): ''' Test cases for RunJob celery task. @@ -1077,7 +914,7 @@ class RunJobTest(BaseJobExecutionTest): self.assertTrue('"--become-method"' in job.job_args) self.assertTrue('"--ask-become-pass"' in job.job_args) self.assertTrue('"--become"' in job.job_args) - + def test_unlocked_ssh_key(self): self.create_test_credential(ssh_key_data=TEST_SSH_KEY_DATA) self.create_test_project(TEST_PLAYBOOK) @@ -1395,7 +1232,7 @@ class RunJobTest(BaseJobExecutionTest): # Hide local settings path. settings.AWX_PROOT_HIDE_PATHS = [os.path.join(settings.BASE_DIR, 'settings')] # Create another project alongside the one we're using to verify it - # is hidden. + # is hidden. self.create_test_credential() self.create_test_project(TEST_PLAYBOOK) other_project_path = self.project.local_path diff --git a/awx/main/tests/functional/users.py b/awx/main/tests/functional/users.py index 11f27a6fd4..91720212ff 100644 --- a/awx/main/tests/functional/users.py +++ b/awx/main/tests/functional/users.py @@ -15,7 +15,7 @@ from django.test.utils import override_settings # AWX from awx.main.models import * # noqa -from .base import BaseTest +from awx.main.tests.base import BaseTest from awx.main.conf import tower_settings __all__ = ['AuthTokenTimeoutTest', 'AuthTokenLimitTest', 'AuthTokenProxyTest', 'UsersTest', 'LdapTest'] @@ -61,7 +61,7 @@ class AuthTokenLimitTest(BaseTest): 'token': response['token'] } self.get(user_me_url, expect=200, auth=auth_token1) - + mock_get_request_hash.return_value = "session_2" response = self.post(auth_token_url, data, expect=200, auth=None) auth_token2 = { @@ -133,7 +133,7 @@ class AuthTokenProxyTest(BaseTest): remote_addr = '192.168.75.1' auth_token = self._request_auth_token(remote_addr) - + # Verify we can access our own user information, from the remote address specified via HTTP_X_FORWARDED_FOR client_kwargs = {'HTTP_X_FORWARDED_FOR': remote_addr} response = self._get_me(expect=200, auth=auth_token, remote_addr=remote_addr, client_kwargs=client_kwargs) @@ -183,7 +183,7 @@ class UsersTest(BaseTest): url = reverse('api:user_list') new_user = dict(username='blippy') self.post(url, expect=400, data=new_user, auth=self.get_super_credentials()) - + def test_only_super_user_or_org_admin_can_add_users(self): url = reverse('api:user_list') new_user = dict(username='blippy', password='hippy') @@ -269,7 +269,7 @@ class UsersTest(BaseTest): # auth method was used in the request. response_header = response.response.get('WWW-Authenticate', '') self.assertEqual(response_header.split()[0], 'Token') - + # Request a new auth token from the new remote address. data = dict(zip(('username', 'password'), self.get_normal_credentials())) response = self.post(auth_token_url, data, expect=200, auth=None, @@ -298,7 +298,7 @@ class UsersTest(BaseTest): response = self.get(user_me_url, expect=401) response_header = response.response.get('WWW-Authenticate', '') self.assertEqual(response_header.split()[0], 'Basic') - + # A request that attempts Basic auth should request Basic auth again. response = self.get(user_me_url, expect=401, auth=('invalid', 'password')) @@ -431,7 +431,7 @@ class UsersTest(BaseTest): self.get(url, expect=404, auth=self.get_super_credentials()) obj = User.objects.get(pk=user_pk) self.assertEquals(obj.is_active, False) - + def test_non_org_admin_user_cannot_delete_any_user_including_himself(self): url1 = reverse('api:user_detail', args=(self.super_django_user.pk,)) url2 = reverse('api:user_detail', args=(self.normal_django_user.pk,)) @@ -471,11 +471,11 @@ class UsersTest(BaseTest): url = reverse('api:user_organizations_list', args=(self.normal_django_user.pk,)) data = self.get(url, expect=200, auth=self.get_normal_credentials()) - self.assertEquals(data['count'], 1) + self.assertEquals(data['count'], 1) # also accessible via superuser data = self.get(url, expect=200, auth=self.get_super_credentials()) - self.assertEquals(data['count'], 1) - # and also by other user... + self.assertEquals(data['count'], 1) + # and also by other user... data = self.get(url, expect=200, auth=self.get_other_credentials()) # but not by nobody user data = self.get(url, expect=403, auth=self.get_nobody_credentials()) @@ -492,7 +492,7 @@ class UsersTest(BaseTest): data = self.get(url, expect=200, auth=self.get_other_credentials()) # but not by nobody user data = self.get(url, expect=403, auth=self.get_nobody_credentials()) - + # teams the user is on, should be 0 url = reverse('api:user_teams_list', args=(self.normal_django_user.pk,)) data = self.get(url, expect=200, auth=self.get_normal_credentials()) @@ -566,7 +566,7 @@ class UsersTest(BaseTest): qs = base_qs.filter(username__exact='normal') self.assertTrue(qs.count()) self.check_get_list(url, self.super_django_user, qs) - + # Filter by username with __iexact suffix. url = '%s?username__iexact=NORMAL' % base_url qs = base_qs.filter(username__iexact='NORMAL') @@ -707,7 +707,7 @@ class UsersTest(BaseTest): self.assertTrue(qs.count()) self.check_get_list(url, self.super_django_user, qs) - # Filter by is_staff (field not exposed via API). FIXME: Should + # Filter by is_staff (field not exposed via API). FIXME: Should # eventually not be allowed! url = '%s?is_staff=true' % base_url qs = base_qs.filter(is_staff=True) @@ -792,7 +792,7 @@ class UsersTest(BaseTest): qs = base_qs.filter(organizations__admins__username__startswith='norm') self.assertTrue(qs.count()) self.check_get_list(url, self.super_django_user, qs) - + # Filter by username with __in list. url = '%s?username__in=normal,admin' % base_url qs = base_qs.filter(username__in=('normal', 'admin')) diff --git a/awx/main/tests/functional/views.py b/awx/main/tests/functional/views.py index e53fdce500..4ccd6f64ec 100644 --- a/awx/main/tests/functional/views.py +++ b/awx/main/tests/functional/views.py @@ -2,8 +2,11 @@ from django.core.urlresolvers import reverse # Reuse Test code -from .base import BaseLiveServerTest, QueueStartStopTestMixin -from .base import URI +from awx.main.tests.base import ( + BaseLiveServerTest, + QueueStartStopTestMixin, + URI, +) from awx.main.models.projects import * # noqa __all__ = ['UnifiedJobStdoutRedactedTests'] @@ -31,7 +34,7 @@ class UnifiedJobStdoutRedactedTests(BaseLiveServerTest, QueueStartStopTestMixin) def setUp(self): super(UnifiedJobStdoutRedactedTests, self).setUp() self.setup_instances() - self.setup_users() + self.setup_users() self.test_cases = [] self.negative_test_cases = [] diff --git a/pytest.ini b/pytest.ini index 751ebbb85f..a679c1bdc4 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,6 @@ [pytest] DJANGO_SETTINGS_MODULE = awx.settings.development python_paths = awx/lib/site-packages +site_dirs = awx/lib/site-packages python_files = *.py addopts = --create-db