@@ -284,3 +284,76 @@ def test_positive_clone_job_template(module_org, module_target_sat):
284284 module_target_sat .cli .JobTemplate .delete ({'name' : template_name })
285285 with pytest .raises (CLIReturnCodeError ):
286286 module_target_sat .cli .JobTemplate .info ({'name' : template_name })
287+
288+
289+ def test_positive_job_template_lock (module_org , module_target_sat ):
290+ """Verify Locked field
291+
292+ :id: 18c8bd52-1457-453c-b50d-49b5b6d2b8ef
293+
294+ :steps:
295+ 1. Create a job template
296+ 2. Verify that Locked field is present and template is unlocked
297+ 3. Lock job template
298+ 4. Verify that template cannot be updated
299+ 5. Unlock job template
300+ 6. Verify that template can be updated
301+
302+ :expectedresults: When unlocked, template can be edited. When locked, template cannot be edited.
303+
304+ :CaseImportance: High
305+
306+ :Verifies: SAT-38149
307+ """
308+
309+ # Create job template
310+ template_name = gen_string ('alpha' , 7 )
311+ description = gen_string ('alpha' , 10 )
312+ module_target_sat .cli_factory .job_template (
313+ {
314+ 'description' : description ,
315+ 'organizations' : module_org .name ,
316+ 'name' : template_name ,
317+ 'file' : TEMPLATE_FILE ,
318+ }
319+ )
320+
321+ template = module_target_sat .cli .JobTemplate .info ({'name' : template_name })
322+
323+ # Verify that template is unlocked
324+ assert 'locked' in template
325+ assert template ['locked' ] == 'false'
326+
327+ # Lock template
328+ module_target_sat .cli .JobTemplate .update (
329+ {
330+ 'id' : template ['id' ],
331+ 'locked' : 'true' ,
332+ }
333+ )
334+ template = module_target_sat .cli .JobTemplate .info ({'name' : template_name })
335+ assert template ['locked' ] == 'true'
336+
337+ # Verify that template cannot be updated when locked
338+ new_description = gen_string ('alpha' )
339+ with pytest .raises (CLIReturnCodeError ):
340+ module_target_sat .cli .JobTemplate .update (
341+ {'id' : template ['id' ], 'description' : new_description }
342+ )
343+ template = module_target_sat .cli .JobTemplate .info ({'name' : template_name })
344+ assert description in template ['description' ]
345+
346+ # Unlock template
347+ module_target_sat .cli .JobTemplate .update (
348+ {
349+ 'id' : template ['id' ],
350+ 'locked' : 'false' ,
351+ }
352+ )
353+ template = module_target_sat .cli .JobTemplate .info ({'name' : template_name })
354+ assert template ['locked' ] == 'false'
355+
356+ # Verify that template can be updated when unlocked
357+ module_target_sat .cli .JobTemplate .update ({'id' : template ['id' ], 'description' : new_description })
358+ template = module_target_sat .cli .JobTemplate .info ({'name' : template_name })
359+ assert new_description in template ['description' ]
0 commit comments