mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 06:17:36 -02:30
allow credential_id to job template launch. Funnel credential_id into credential.
This commit is contained in:
@@ -482,24 +482,37 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TestCase):
|
||||
# Invalid auth can't trigger the launch endpoint
|
||||
self.check_invalid_auth(launch_url, {}, methods=('post',))
|
||||
|
||||
# Implicit, attached credentials
|
||||
with self.current_user(self.user_sue):
|
||||
response = self.post(launch_url, {}, expect=202)
|
||||
j = Job.objects.get(pk=response['job'])
|
||||
self.assertTrue(j.status == 'new')
|
||||
|
||||
# Explicit, override credentials
|
||||
with self.current_user(self.user_sue):
|
||||
response = self.post(launch_url, {'credential': self.cred_doug.pk}, expect=202)
|
||||
j = Job.objects.get(pk=response['job'])
|
||||
self.assertTrue(j.status == 'new')
|
||||
self.assertEqual(j.credential.pk, self.cred_doug.pk)
|
||||
|
||||
# Explicit, override credentials
|
||||
with self.current_user(self.user_sue):
|
||||
response = self.post(launch_url, {'credential_id': self.cred_doug.pk}, expect=202)
|
||||
j = Job.objects.get(pk=response['job'])
|
||||
self.assertTrue(j.status == 'new')
|
||||
self.assertEqual(j.credential.pk, self.cred_doug.pk)
|
||||
|
||||
# Can't launch a job template without a credential defined (or if we
|
||||
# pass an invalid/inactive credential value).
|
||||
with self.current_user(self.user_sue):
|
||||
response = self.post(no_launch_url, {}, expect=400)
|
||||
response = self.post(no_launch_url, {'credential': 0}, expect=400)
|
||||
response = self.post(no_launch_url, {'credential_id': 0}, expect=400)
|
||||
response = self.post(no_launch_url, {'credential': 'one'}, expect=400)
|
||||
response = self.post(no_launch_url, {'credential_id': 'one'}, expect=400)
|
||||
self.cred_doug.mark_inactive()
|
||||
response = self.post(no_launch_url, {'credential': self.cred_doug.pk}, expect=400)
|
||||
response = self.post(no_launch_url, {'credential_id': self.cred_doug.pk}, expect=400)
|
||||
|
||||
# Job Templates without projects can not be launched
|
||||
with self.current_user(self.user_sue):
|
||||
|
||||
Reference in New Issue
Block a user