use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class PackageConfigurationsTest method shouldConstructPackageConfigurationFromApiRepositoryConfiguration.
@Test
public void shouldConstructPackageConfigurationFromApiRepositoryConfiguration() throws Exception {
RepositoryConfiguration configuration = new RepositoryConfiguration();
configuration.add(new PackageMaterialProperty("k1", "v1").with(Property.SECURE, Boolean.TRUE));
PackageConfigurations packageConfigurations = new PackageConfigurations(configuration);
assertThat(packageConfigurations.list().size(), is(1));
assertThat(packageConfigurations.list().get(0).getKey(), is("k1"));
assertThat(packageConfigurations.list().get(0).getValue(), is("v1"));
assertThat(packageConfigurations.list().get(0).getOption(PackageConfiguration.REQUIRED), is(true));
assertThat(packageConfigurations.list().get(0).getOption(PackageConfiguration.PART_OF_IDENTITY), is(true));
assertThat(packageConfigurations.list().get(0).getOption(PackageConfiguration.SECURE), is(true));
assertThat(packageConfigurations.list().get(0).getOption(PackageConfiguration.DISPLAY_NAME), is(""));
assertThat(packageConfigurations.list().get(0).getOption(PackageConfiguration.DISPLAY_ORDER), is(0));
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class PackageMaterialPollerTest method setup.
@BeforeEach
void setup() {
// setup material
material = new PackageMaterial();
PackageRepository packageRepository = PackageRepositoryMother.create("id", "name", "plugin-id", "plugin-version", new Configuration(ConfigurationPropertyMother.create("url", false, "http://some-url")));
PackageDefinition packageDefinition = create("id", "package", new Configuration(ConfigurationPropertyMother.create("name", false, "go-agent"), ConfigurationPropertyMother.create("secure", true, "value")), packageRepository);
material.setPackageDefinition(packageDefinition);
packageRepositoryExtension = mock(PackageRepositoryExtension.class);
poller = new com.thoughtworks.go.server.service.materials.PackageMaterialPoller(packageRepositoryExtension);
packageConfiguration = ArgumentCaptor.forClass(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration.class);
repositoryConfiguration = ArgumentCaptor.forClass(RepositoryConfiguration.class);
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class PackageRepositoryServiceTest method shouldSendResolvedValuesForValidateRepositoryConfigurationOnPlugin.
@Test
void shouldSendResolvedValuesForValidateRepositoryConfigurationOnPlugin() {
String pluginId = "yum";
RepositoryMetadataStore.getInstance().addMetadataFor(pluginId, new PackageConfigurations());
PackageRepository packageRepository = packageRepository(pluginId);
packageRepository.getConfiguration().get(0).setConfigurationValue(new ConfigurationValue("{{SECRET:[secret_config_id][username]}}"));
PackageRepositoryService service = new PackageRepositoryService(pluginManager, packageRepositoryExtension, goConfigService, securityService, entityHashingService, secretParamResolver);
when(packageRepositoryExtension.isRepositoryConfigurationValid(eq(pluginId), any())).thenReturn(new ValidationResult());
doAnswer(invocation -> {
PackageRepository config = invocation.getArgument(0);
config.getSecretParams().get(0).setValue("resolved-value");
return config;
}).when(secretParamResolver).resolve(packageRepository);
boolean isValid = service.validateRepositoryConfiguration(packageRepository);
assertThat(isValid).isTrue();
ArgumentCaptor<RepositoryConfiguration> argumentCaptor = ArgumentCaptor.forClass(RepositoryConfiguration.class);
verify(packageRepositoryExtension).isRepositoryConfigurationValid(eq(pluginId), argumentCaptor.capture());
RepositoryConfiguration packageConfigurations = argumentCaptor.getValue();
assertThat(packageConfigurations.list().get(0).getValue()).isEqualTo("resolved-value");
}
Aggregations