use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPackageMaterialConfig.
@Test
void shouldConvertPackageMaterialConfig() {
PackageRepositories repositories = new PackageRepositories();
PackageRepository packageRepository = new PackageRepository();
PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
packageRepository.addPackage(definition);
repositories.add(packageRepository);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setPackageRepositories(repositories);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(new CaseInsensitiveString("name"), "package-id", definition);
CRPackageMaterial crPackageMaterial = (CRPackageMaterial) configConverter.materialToCRMaterial(packageMaterialConfig);
assertThat(crPackageMaterial.getName()).isEqualTo("name");
assertThat(crPackageMaterial.getPackageId()).isEqualTo("package-id");
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository 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.domain.packagerepository.PackageRepository in project gocd by gocd.
the class PackageRepositoryServiceTest method shouldAddErrorWhenPluginIdIsInvalid.
@Test
void shouldAddErrorWhenPluginIdIsInvalid() {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setPluginConfiguration(new PluginConfiguration("missing-plugin", "1.0"));
service.performPluginValidationsFor(packageRepository);
assertThat(packageRepository.getPluginConfiguration().errors().getAllOn(PluginConfiguration.ID)).isEqualTo(Arrays.asList("Invalid plugin id"));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class PackageRepositoryServiceTest method shouldAddErrorWhenPluginIdIsMissing.
@Test
void shouldAddErrorWhenPluginIdIsMissing() {
PackageRepository packageRepository = new PackageRepository();
service.performPluginValidationsFor(packageRepository);
assertThat(packageRepository.getPluginConfiguration().errors().getAllOn(PluginConfiguration.ID)).isEqualTo(Arrays.asList("Please select package repository plugin"));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository 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