use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class JsonMessageHandler1_0Test method shouldBuildRepositoryConfigurationFromResponseBody.
@Test
public void shouldBuildRepositoryConfigurationFromResponseBody() throws Exception {
String responseBody = "{" + "\"key-one\":{}," + "\"key-two\":{\"default-value\":\"two\",\"part-of-identity\":true,\"secure\":true,\"required\":true,\"display-name\":\"display-two\",\"display-order\":\"1\"}," + "\"key-three\":{\"default-value\":\"three\",\"part-of-identity\":false,\"secure\":false,\"required\":false,\"display-name\":\"display-three\",\"display-order\":\"2\"}" + "}";
RepositoryConfiguration repositoryConfiguration = messageHandler.responseMessageForRepositoryConfiguration(responseBody);
assertPropertyConfiguration((PackageMaterialProperty) repositoryConfiguration.get("key-one"), "key-one", "", true, true, false, "", 0);
assertPropertyConfiguration((PackageMaterialProperty) repositoryConfiguration.get("key-two"), "key-two", "two", true, true, true, "display-two", 1);
assertPropertyConfiguration((PackageMaterialProperty) repositoryConfiguration.get("key-three"), "key-three", "three", false, false, false, "display-three", 2);
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class JsonMessageHandler1_0Test method setUp.
@BeforeEach
public void setUp() throws Exception {
messageHandler = new JsonMessageHandler1_0();
repositoryConfiguration = new RepositoryConfiguration();
repositoryConfiguration.add(new PackageMaterialProperty("key-one", "value-one"));
repositoryConfiguration.add(new PackageMaterialProperty("key-two", "value-two"));
packageConfiguration = new PackageConfiguration();
packageConfiguration.add(new PackageMaterialProperty("key-three", "value-three"));
packageConfiguration.add(new PackageMaterialProperty("key-four", "value-four"));
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class PackageMaterialPoller method buildRepositoryConfigurations.
private RepositoryConfiguration buildRepositoryConfigurations(PackageRepository packageRepository) {
RepositoryConfiguration repositoryConfiguration = new RepositoryConfiguration();
populateConfiguration(packageRepository.getConfiguration(), repositoryConfiguration);
return repositoryConfiguration;
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class PackageMaterialPoller method latestModification.
@Override
public List<Modification> latestModification(final PackageMaterial material, File baseDir, SubprocessExecutionContext execCtx) {
PackageConfiguration packageConfiguration = buildPackageConfigurations(material.getPackageDefinition());
RepositoryConfiguration repositoryConfiguration = buildRepositoryConfigurations(material.getPackageDefinition().getRepository());
PackageRevision packageRevision = packageRepositoryExtension.getLatestRevision(material.getPluginId(), packageConfiguration, repositoryConfiguration);
return getModifications(packageRevision);
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration in project gocd by gocd.
the class PackageDefinitionServiceTest method shouldSendResolvedValuesDuringCheckConnectionOnPackage.
@Test
void shouldSendResolvedValuesDuringCheckConnectionOnPackage() {
Configuration configuration = new Configuration();
configuration.add(ConfigurationPropertyMother.create("required", false, "{{SECRET:[secret_config_id][username]}}"));
configuration.add(ConfigurationPropertyMother.create("required_secure", true, "v2"));
PackageDefinition packageDefinition = PackageDefinitionMother.create("1", "name", configuration, packageRepository);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
when(packageRepositoryExtension.checkConnectionToPackage(eq(packageRepository.getPluginConfiguration().getId()), any(), any())).thenReturn(new Result().withSuccessMessages("Got Package!!!"));
doAnswer(invocation -> {
PackageDefinition config = invocation.getArgument(0);
config.getSecretParams().get(0).setValue("resolved-value");
return config;
}).when(secretParamResolver).resolve(packageDefinition);
service.checkConnection(packageDefinition, result);
ArgumentCaptor<com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration> packageConfigurationsCaptor = ArgumentCaptor.forClass(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration.class);
ArgumentCaptor<RepositoryConfiguration> packageRepositoryConfigurationsCaptor = ArgumentCaptor.forClass(RepositoryConfiguration.class);
assertThat(result.isSuccessful()).isTrue();
assertThat(result.message()).isEqualTo("OK. Got Package!!!");
verify(packageRepositoryExtension).checkConnectionToPackage(anyString(), packageConfigurationsCaptor.capture(), packageRepositoryConfigurationsCaptor.capture());
assertPackageConfiguration(packageRepositoryConfigurationsCaptor.getValue().list(), packageRepository.getConfiguration());
assertThat(packageConfigurationsCaptor.getValue().list().get(0).getValue()).isEqualTo("resolved-value");
}
Aggregations