mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-16 07:48:38 -05:00
Merge pull request #524 from AlanCoding/yaml_devel
Allow job_template launch to store YAML extra_vars
This commit is contained in:
@@ -11,6 +11,7 @@ from django.core.urlresolvers import reverse
|
||||
# AWX
|
||||
from awx.main.models import * # noqa
|
||||
from .base import BaseJobTestMixin
|
||||
import yaml
|
||||
|
||||
__all__ = ['JobTemplateLaunchTest', 'JobTemplateLaunchPasswordsTest']
|
||||
|
||||
@@ -70,6 +71,28 @@ class JobTemplateLaunchTest(BaseJobTestMixin, django.test.TestCase):
|
||||
j = Job.objects.get(pk=response['job'])
|
||||
self.assertTrue(j.status == 'new')
|
||||
|
||||
def test_launch_extra_vars_json(self):
|
||||
# Sending extra_vars as a JSON string, implicit credentials
|
||||
with self.current_user(self.user_sue):
|
||||
data = dict(extra_vars = '{\"a\":3}')
|
||||
response = self.post(self.launch_url, data, expect=202)
|
||||
j = Job.objects.get(pk=response['job'])
|
||||
ev_dict = yaml.load(j.extra_vars)
|
||||
self.assertIn('a', ev_dict)
|
||||
if 'a' in ev_dict:
|
||||
self.assertEqual(ev_dict['a'], 3)
|
||||
|
||||
def test_launch_extra_vars_yaml(self):
|
||||
# Sending extra_vars as a JSON string, implicit credentials
|
||||
with self.current_user(self.user_sue):
|
||||
data = dict(extra_vars = 'a: 3')
|
||||
response = self.post(self.launch_url, data, expect=202)
|
||||
j = Job.objects.get(pk=response['job'])
|
||||
ev_dict = yaml.load(j.extra_vars)
|
||||
self.assertIn('a', ev_dict)
|
||||
if 'a' in ev_dict:
|
||||
self.assertEqual(ev_dict['a'], 3)
|
||||
|
||||
def test_credential_explicit(self):
|
||||
# Explicit, credential
|
||||
with self.current_user(self.user_sue):
|
||||
@@ -195,4 +218,3 @@ class JobTemplateLaunchPasswordsTest(BaseJobTestMixin, django.test.TestCase):
|
||||
with self.current_user(self.user_sue):
|
||||
response = self.post(self.launch_url, {'ssh_password': ''}, expect=400)
|
||||
self.assertIn('ssh_password', response['passwords_needed_to_start'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user