public void encryptSecureProperties(CruiseConfig preprocessedConfig, PipelineTemplateConfig pipelineTemplateConfig) { if (doesNotHavePublishAndFetchExternalConfig()) { return; } for (StageConfig stageConfig : getStages()) { stageConfig.encryptSecureProperties(preprocessedConfig, pipelineTemplateConfig); } }
public void encryptSecureProperties(CruiseConfig preprocessedConfig, PipelineConfig preprocessedPipelineConfig) { if (hasTemplate() || doesNotHavePublishAndFetchExternalConfig()) { return; } for (StageConfig stageConfig : getStages()) { stageConfig.encryptSecureProperties(preprocessedConfig, preprocessedPipelineConfig, preprocessedPipelineConfig.getStage(stageConfig.name())); } }
@Test public void shouldNotEncryptSecurePropertiesInStagesIfPipelineHasATemplate() { PipelineConfig pipelineConfig = new PipelineConfig(); pipelineConfig.setTemplateName(new CaseInsensitiveString("some-template")); StageConfig mockStageConfig = mock(StageConfig.class); pipelineConfig.addStageWithoutValidityAssertion(mockStageConfig); pipelineConfig.encryptSecureProperties(new BasicCruiseConfig(), pipelineConfig); verify(mockStageConfig, never()).encryptSecureProperties(eq(new BasicCruiseConfig()), eq(pipelineConfig), ArgumentMatchers.any(StageConfig.class)); }
@Test public void shouldNotAttemptToEncryptPropertiesIfThereAreNoPluginConfigs() { PipelineConfig pipelineConfig = new PipelineConfig(); StageConfig mockStageConfig = mock(StageConfig.class); pipelineConfig.add(mockStageConfig); JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("job")); when(mockStageConfig.getJobs()).thenReturn(new JobConfigs(jobConfig)); when(mockStageConfig.name()).thenReturn(new CaseInsensitiveString("stage")); pipelineConfig.encryptSecureProperties(new BasicCruiseConfig(), pipelineConfig); verify(mockStageConfig, never()).encryptSecureProperties(eq(new BasicCruiseConfig()), eq(pipelineConfig), ArgumentMatchers.any(StageConfig.class)); }
@Test public void shouldEncryptSecurePropertiesInStagesIfPipelineHasStagesDefined() { PipelineConfig pipelineConfig = new PipelineConfig(); StageConfig mockStageConfig = mock(StageConfig.class); pipelineConfig.add(mockStageConfig); JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("job")); jobConfig.artifactConfigs().add(new PluggableArtifactConfig("foo", "bar")); when(mockStageConfig.getJobs()).thenReturn(new JobConfigs(jobConfig)); when(mockStageConfig.name()).thenReturn(new CaseInsensitiveString("stage")); pipelineConfig.encryptSecureProperties(new BasicCruiseConfig(), pipelineConfig); verify(mockStageConfig).encryptSecureProperties(eq(new BasicCruiseConfig()), eq(pipelineConfig), ArgumentMatchers.any(StageConfig.class)); }