Merge pull request #1003 from wwitzel3/devel

Fix notification_data attempting to access name property of an int
This commit is contained in:
Wayne Witzel III 2018-01-18 08:55:50 -05:00 committed by GitHub
commit fc5c5400cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -675,7 +675,7 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana
data.update(dict(inventory=self.inventory.name if self.inventory else None,
project=self.project.name if self.project else None,
playbook=self.playbook,
credential=self.credential.name if self.credential else None,
credential=getattr(self.get_deprecated_credential('ssh'), 'name', None),
limit=self.limit,
extra_vars=self.display_extra_vars(),
hosts=all_hosts))

View File

@ -30,13 +30,15 @@ def test_job_capacity_and_with_inactive_node():
@pytest.mark.django_db
def test_job_notification_data(inventory):
def test_job_notification_data(inventory, machine_credential, project):
encrypted_str = "$encrypted$"
job = Job.objects.create(
job_template=None, inventory=inventory, name='hi world',
extra_vars=json.dumps({"SSN": "123-45-6789"}),
survey_passwords={"SSN": encrypted_str}
survey_passwords={"SSN": encrypted_str},
project=project,
)
job.credentials = [machine_credential]
notification_data = job.notification_data(block=0)
assert json.loads(notification_data['extra_vars'])['SSN'] == encrypted_str