@@ -295,4 +295,44 @@ class OdsComponentStageScanWithAquaSpec extends PipelineSpockTestBase {
295295 assertJobStatusSuccess()
296296 }
297297
298+ def " forwards branches config into ScanWithAquaStage" () {
299+ given :
300+ // Use the same base config but ensure the stage is enabled so the ctor is reached.
301+ def c = config + [environment : ' dev' ]
302+ IContext context = new Context (null , c, logger)
303+
304+ // Only OpenShift is needed pre-ctor; we stub it to enable the stage.
305+ OpenShiftService openShiftService = Stub (OpenShiftService . class)
306+ openShiftService. getConfigMapData(' ods' , ScanWithAquaStage . AQUA_CONFIG_MAP_NAME ) >> [
307+ enabled : true , alertEmails : " mail1@mail.com" , url : " http://aqua" , registry : " internal"
308+ ]
309+ openShiftService. getConfigMapData(" foo" , ScanWithAquaStage . AQUA_CONFIG_MAP_NAME ) >> [enabled : true ]
310+ ServiceRegistry . instance. add(OpenShiftService , openShiftService)
311+
312+ and : " spy the stage constructor to capture the inherited config"
313+ Map capturedCfg = null
314+ GroovySpy (ScanWithAquaStage , global : true )
315+ _ * new ScanWithAquaStage (_, _, _) >> { Object [] args ->
316+ capturedCfg = (Map ) args[2 ]
317+ // return a dummy stage that does nothing so we don't need other service stubs
318+ return Stub (ScanWithAquaStage ) {
319+ execute() >> null
320+ run() >> null
321+ }
322+ }
323+
324+ when :
325+ def script = loadScript(' vars/odsComponentStageScanWithAqua.groovy' )
326+ script. call(
327+ context,
328+ [resourceName : ' my-image' , branches : [' master' , ' release/' ]]
329+ )
330+
331+ then :
332+ capturedCfg != null
333+ capturedCfg. resourceName == ' my-image'
334+ capturedCfg. branches == [' master' , ' release/' ]
335+ assertJobStatusSuccess()
336+ }
337+
298338}
0 commit comments