AC-537 Work on getting unit tests to pass.

This commit is contained in:
Chris Church
2013-10-29 16:14:51 -04:00
parent d668991899
commit 9b204e737e
3 changed files with 31 additions and 25 deletions

View File

@@ -1032,9 +1032,12 @@ class InventoryUpdatesTest(BaseTransactionTest):
source_regions = getattr(settings, 'TEST_AWS_REGIONS', 'all') source_regions = getattr(settings, 'TEST_AWS_REGIONS', 'all')
if not all([source_username, source_password]): if not all([source_username, source_password]):
self.skipTest('no test ec2 credentials defined!') self.skipTest('no test ec2 credentials defined!')
credential = Credential.objects.create(kind='aws',
user=self.super_django_user,
username=source_username,
password=source_password)
inventory_source = self.update_inventory_source(self.group, inventory_source = self.update_inventory_source(self.group,
source='ec2', source_username=source_username, source='ec2', credential=credential, source_regions=source_regions,
source_password=source_password, source_regions=source_regions,
source_vars='---') source_vars='---')
self.check_inventory_source(inventory_source) self.check_inventory_source(inventory_source)
@@ -1044,7 +1047,11 @@ class InventoryUpdatesTest(BaseTransactionTest):
source_regions = getattr(settings, 'TEST_RACKSPACE_REGIONS', '') source_regions = getattr(settings, 'TEST_RACKSPACE_REGIONS', '')
if not all([source_username, source_password]): if not all([source_username, source_password]):
self.skipTest('no test rackspace credentials defined!') self.skipTest('no test rackspace credentials defined!')
credential = Credential.objects.create(kind='rax',
user=self.super_django_user,
username=source_username,
password=source_password)
inventory_source = self.update_inventory_source(self.group, inventory_source = self.update_inventory_source(self.group,
source='rackspace', source_username=source_username, source='rackspace', credential=credential,
source_password=source_password, source_regions=source_regions) source_regions=source_regions)
self.check_inventory_source(inventory_source) self.check_inventory_source(inventory_source)

View File

@@ -235,60 +235,60 @@ class BaseJobTestMixin(BaseTestMixin):
TEST_SSH_KEY_DATA_LOCKED, TEST_SSH_KEY_DATA_LOCKED,
TEST_SSH_KEY_DATA_UNLOCK) TEST_SSH_KEY_DATA_UNLOCK)
self.cred_bob = self.user_bob.credentials.create( self.cred_bob = self.user_bob.credentials.create(
ssh_username='bob', username='bob',
ssh_password='ASK', password='ASK',
created_by=self.user_sue, created_by=self.user_sue,
) )
self.cred_chuck = self.user_chuck.credentials.create( self.cred_chuck = self.user_chuck.credentials.create(
ssh_username='chuck', username='chuck',
ssh_key_data=TEST_SSH_KEY_DATA, ssh_key_data=TEST_SSH_KEY_DATA,
created_by=self.user_sue, created_by=self.user_sue,
) )
self.cred_doug = self.user_doug.credentials.create( self.cred_doug = self.user_doug.credentials.create(
ssh_username='doug', username='doug',
ssh_password='doug doesn\'t mind his password being saved. this ' password='doug doesn\'t mind his password being saved. this '
'is why we dont\'t let doug actually run jobs.', 'is why we dont\'t let doug actually run jobs.',
created_by=self.user_sue, created_by=self.user_sue,
) )
self.cred_eve = self.user_eve.credentials.create( self.cred_eve = self.user_eve.credentials.create(
ssh_username='eve', username='eve',
ssh_password='ASK', password='ASK',
sudo_username='root', sudo_username='root',
sudo_password='ASK', sudo_password='ASK',
created_by=self.user_sue, created_by=self.user_sue,
) )
self.cred_frank = self.user_frank.credentials.create( self.cred_frank = self.user_frank.credentials.create(
ssh_username='frank', username='frank',
ssh_password='fr@nk the t@nk', password='fr@nk the t@nk',
created_by=self.user_sue, created_by=self.user_sue,
) )
self.cred_greg = self.user_greg.credentials.create( self.cred_greg = self.user_greg.credentials.create(
ssh_username='greg', username='greg',
ssh_key_data=TEST_SSH_KEY_DATA_LOCKED, ssh_key_data=TEST_SSH_KEY_DATA_LOCKED,
ssh_key_unlock='ASK', ssh_key_unlock='ASK',
created_by=self.user_sue, created_by=self.user_sue,
) )
self.cred_holly = self.user_holly.credentials.create( self.cred_holly = self.user_holly.credentials.create(
ssh_username='holly', username='holly',
ssh_password='holly rocks', password='holly rocks',
created_by=self.user_sue, created_by=self.user_sue,
) )
self.cred_iris = self.user_iris.credentials.create( self.cred_iris = self.user_iris.credentials.create(
ssh_username='iris', username='iris',
ssh_password='ASK', password='ASK',
created_by=self.user_sue, created_by=self.user_sue,
) )
# Each operations team also has shared credentials they can use. # Each operations team also has shared credentials they can use.
self.cred_ops_east = self.team_ops_east.credentials.create( self.cred_ops_east = self.team_ops_east.credentials.create(
ssh_username='east', username='east',
ssh_key_data=TEST_SSH_KEY_DATA_LOCKED, ssh_key_data=TEST_SSH_KEY_DATA_LOCKED,
ssh_key_unlock=TEST_SSH_KEY_DATA_UNLOCK, ssh_key_unlock=TEST_SSH_KEY_DATA_UNLOCK,
created_by = self.user_sue, created_by = self.user_sue,
) )
self.cred_ops_west = self.team_ops_west.credentials.create( self.cred_ops_west = self.team_ops_west.credentials.create(
ssh_username='west', username='west',
ssh_password='Heading270', password='Heading270',
created_by = self.user_sue, created_by = self.user_sue,
) )

View File

@@ -192,10 +192,10 @@ class RunJobTest(BaseCeleryTest):
opts = { opts = {
'name': 'test-creds', 'name': 'test-creds',
'user': self.super_django_user, 'user': self.super_django_user,
'ssh_username': '', 'username': '',
'ssh_key_data': '', 'ssh_key_data': '',
'ssh_key_unlock': '', 'ssh_key_unlock': '',
'ssh_password': '', 'password': '',
'sudo_username': '', 'sudo_username': '',
'sudo_password': '', 'sudo_password': '',
} }
@@ -706,8 +706,7 @@ class RunJobTest(BaseCeleryTest):
self.assertTrue('-l' in self.run_job_args) self.assertTrue('-l' in self.run_job_args)
def test_ssh_username_and_password(self): def test_ssh_username_and_password(self):
self.create_test_credential(ssh_username='sshuser', self.create_test_credential(username='sshuser', password='sshpass')
ssh_password='sshpass')
self.create_test_project(TEST_PLAYBOOK) self.create_test_project(TEST_PLAYBOOK)
job_template = self.create_test_job_template() job_template = self.create_test_job_template()
job = self.create_test_job(job_template=job_template) job = self.create_test_job(job_template=job_template)