mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
Merge pull request #5723 from kdelee/scan_job_cleanup
Scan jobs have been removed, clean up old refs Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -264,18 +264,6 @@ def test_job_launch_fails_without_credential_access(job_template_prompts, runtim
|
|||||||
dict(credentials=runtime_data['credentials']), rando, expect=403)
|
dict(credentials=runtime_data['credentials']), rando, expect=403)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
|
||||||
@pytest.mark.job_runtime_vars
|
|
||||||
def test_job_block_scan_job_type_change(job_template_prompts, post, admin_user):
|
|
||||||
job_template = job_template_prompts(True)
|
|
||||||
|
|
||||||
# Assure that changing the type of a scan job blocks the launch
|
|
||||||
response = post(reverse('api:job_template_launch', kwargs={'pk':job_template.pk}),
|
|
||||||
dict(job_type='scan'), admin_user, expect=400)
|
|
||||||
|
|
||||||
assert 'job_type' in response.data
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_job_launch_JT_with_validation(machine_credential, credential, deploy_jobtemplate):
|
def test_job_launch_JT_with_validation(machine_credential, credential, deploy_jobtemplate):
|
||||||
deploy_jobtemplate.extra_vars = '{"job_template_var": 3}'
|
deploy_jobtemplate.extra_vars = '{"job_template_var": 3}'
|
||||||
|
|||||||
@@ -197,36 +197,6 @@ def test_change_jt_sensitive_data(job_template_with_ids, mocker, user_unit):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def test_jt_add_scan_job_check(job_template_with_ids, user_unit):
|
|
||||||
"Assure that permissions to add scan jobs work correctly"
|
|
||||||
|
|
||||||
access = JobTemplateAccess(user_unit)
|
|
||||||
project = job_template_with_ids.project
|
|
||||||
inventory = job_template_with_ids.inventory
|
|
||||||
project.use_role = Role()
|
|
||||||
inventory.use_role = Role()
|
|
||||||
organization = Organization(name='test-org')
|
|
||||||
inventory.organization = organization
|
|
||||||
organization.admin_role = Role()
|
|
||||||
|
|
||||||
def mock_get_object(Class, **kwargs):
|
|
||||||
if Class == Project:
|
|
||||||
return project
|
|
||||||
elif Class == Inventory:
|
|
||||||
return inventory
|
|
||||||
else:
|
|
||||||
raise Exception('Item requested has not been mocked')
|
|
||||||
|
|
||||||
|
|
||||||
with mock.patch('awx.main.models.rbac.Role.__contains__', return_value=True):
|
|
||||||
with mock.patch('awx.main.access.get_object_or_400', mock_get_object):
|
|
||||||
assert access.can_add({
|
|
||||||
'project': project.pk,
|
|
||||||
'inventory': inventory.pk,
|
|
||||||
'job_type': 'scan'
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
def mock_raise_none(self, add_host=False, feature=None, check_expiration=True):
|
def mock_raise_none(self, add_host=False, feature=None, check_expiration=True):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ options:
|
|||||||
job_type:
|
job_type:
|
||||||
description:
|
description:
|
||||||
- Job_type to use for the job, only used if prompt for job_type is set.
|
- Job_type to use for the job, only used if prompt for job_type is set.
|
||||||
choices: ["run", "check", "scan"]
|
choices: ["run", "check"]
|
||||||
type: str
|
type: str
|
||||||
inventory:
|
inventory:
|
||||||
description:
|
description:
|
||||||
@@ -145,7 +145,7 @@ def update_fields(module, p):
|
|||||||
def main():
|
def main():
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
job_template=dict(required=True, type='str'),
|
job_template=dict(required=True, type='str'),
|
||||||
job_type=dict(choices=['run', 'check', 'scan']),
|
job_type=dict(choices=['run', 'check']),
|
||||||
inventory=dict(type='str', default=None),
|
inventory=dict(type='str', default=None),
|
||||||
credential=dict(type='str', default=None),
|
credential=dict(type='str', default=None),
|
||||||
limit=dict(),
|
limit=dict(),
|
||||||
|
|||||||
@@ -131,8 +131,6 @@ class JobTemplate(
|
|||||||
inventory=Inventory,
|
inventory=Inventory,
|
||||||
project=None,
|
project=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
if not project and job_type != 'scan':
|
|
||||||
project = Project
|
|
||||||
if not inventory and not kwargs.get('ask_inventory_on_launch', False):
|
if not inventory and not kwargs.get('ask_inventory_on_launch', False):
|
||||||
inventory = Inventory
|
inventory = Inventory
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ class Resources(object):
|
|||||||
_inventory_related_root_groups = r'inventories/\d+/root_groups/'
|
_inventory_related_root_groups = r'inventories/\d+/root_groups/'
|
||||||
_inventory_related_script = r'inventories/\d+/script/'
|
_inventory_related_script = r'inventories/\d+/script/'
|
||||||
_inventory_related_update_inventory_sources = r'inventories/\d+/update_inventory_sources/'
|
_inventory_related_update_inventory_sources = r'inventories/\d+/update_inventory_sources/'
|
||||||
_inventory_scan_job_templates = r'inventories/\d+/scan_job_templates/'
|
|
||||||
_inventory_script = r'inventory_scripts/\d+/'
|
_inventory_script = r'inventory_scripts/\d+/'
|
||||||
_inventory_script_copy = r'inventory_scripts/\d+/copy/'
|
_inventory_script_copy = r'inventory_scripts/\d+/copy/'
|
||||||
_inventory_scripts = 'inventory_scripts/'
|
_inventory_scripts = 'inventory_scripts/'
|
||||||
|
|||||||
Reference in New Issue
Block a user