mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 20:07:37 -02:30
Merge pull request #1292 from ryanpetrello/fix-1291
don't require credentials to relaunch a job
This commit is contained in:
@@ -2811,10 +2811,6 @@ class JobRelaunchSerializer(BaseSerializer):
|
|||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
obj = self.context.get('obj')
|
obj = self.context.get('obj')
|
||||||
if not obj.credential and not obj.vault_credential:
|
|
||||||
raise serializers.ValidationError(
|
|
||||||
dict(credential=[_("Neither credential nor vault credential provided.")])
|
|
||||||
)
|
|
||||||
if obj.project is None:
|
if obj.project is None:
|
||||||
raise serializers.ValidationError(dict(errors=[_("Job Template Project is missing or undefined.")]))
|
raise serializers.ValidationError(dict(errors=[_("Job Template Project is missing or undefined.")]))
|
||||||
if obj.inventory is None or obj.inventory.pending_deletion:
|
if obj.inventory is None or obj.inventory.pending_deletion:
|
||||||
|
|||||||
@@ -39,6 +39,21 @@ def test_job_relaunch_permission_denied_response(
|
|||||||
assert 'do not have permission' in r.data['detail']
|
assert 'do not have permission' in r.data['detail']
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_job_relaunch_without_creds(post, inventory, project, admin_user):
|
||||||
|
jt = JobTemplate.objects.create(
|
||||||
|
name='testjt', inventory=inventory,
|
||||||
|
project=project
|
||||||
|
)
|
||||||
|
job = jt.create_unified_job()
|
||||||
|
post(
|
||||||
|
url=reverse('api:job_relaunch', kwargs={'pk':job.pk}),
|
||||||
|
data={},
|
||||||
|
user=admin_user,
|
||||||
|
expect=201
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@pytest.mark.parametrize("status,hosts", [
|
@pytest.mark.parametrize("status,hosts", [
|
||||||
('all', 'host1,host2,host3'),
|
('all', 'host1,host2,host3'),
|
||||||
|
|||||||
Reference in New Issue
Block a user