Search in sources :

Example 81 with PackageRepository

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");
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

Example 82 with PackageRepository

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);
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) PackageRepositoryExtension(com.thoughtworks.go.plugin.access.packagematerial.PackageRepositoryExtension) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 83 with PackageRepository

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"));
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

Example 84 with PackageRepository

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"));
}
Also used : PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

Example 85 with PackageRepository

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");
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.jupiter.api.Test)

Aggregations

PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)89 Test (org.junit.jupiter.api.Test)46 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)40 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)39 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)23 Packages (com.thoughtworks.go.domain.packagerepository.Packages)13 Username (com.thoughtworks.go.server.domain.Username)13 Test (org.junit.Test)13 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)9 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)7 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)5 UpdateConfigFromUI (com.thoughtworks.go.config.update.UpdateConfigFromUI)5 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)5 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)5 XsdValidationException (com.thoughtworks.go.util.XsdValidationException)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4