use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class GoConfigMother method configWithPackageRepo.
public static CruiseConfig configWithPackageRepo(String... ids) throws Exception {
final CruiseConfig config = new BasicCruiseConfig();
PackageConfigurations configuration = new PackageConfigurations();
configuration.addConfiguration(new PackageConfiguration("key1"));
configuration.addConfiguration(new PackageConfiguration("key2").with(PackageConfiguration.SECURE, true));
RepositoryMetadataStore.getInstance().addMetadataFor("plugin-1", configuration);
for (String id : ids) {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setId(id);
packageRepository.setName("name" + id);
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-1", "1.0.0"));
packageRepository.setPackages(new Packages(PackageDefinitionMother.create(id + "-pkg-1", packageRepository), PackageDefinitionMother.create(id + "-pkg-2", packageRepository)));
GoCipher cipher = new GoCipher();
ConfigurationProperty p1 = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"));
ConfigurationProperty p2 = new ConfigurationProperty(new ConfigurationKey("key2"), null, new EncryptedConfigurationValue(cipher.encrypt("value2")), cipher);
packageRepository.setConfiguration(new Configuration(p1, p2));
config.setPackageRepositories(new PackageRepositories(packageRepository));
}
return config;
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue.
@Test
public void shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue() throws Exception {
Configuration configuration = new Configuration(getConfigurationProperty("url", false, "http://go"));
Packages packages = new Packages();
PackageRepository repository = createPackageRepository("plugin-id", "version", "id", "name", configuration, packages);
PackageDefinition aPackage = new PackageDefinition("package-id", "package-name", configuration);
aPackage.setAutoUpdate(true);
packages.add(aPackage);
aPackage.setRepository(repository);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
xmlWriter.write(cruiseConfig, output, false);
assertThat(output.toString().contains("autoUpdate=\"true\""), is(false));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteRepositoryConfigurationWithPackages.
@Test
public void shouldWriteRepositoryConfigurationWithPackages() throws Exception {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setId("id");
packageRepository.setName("name");
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-id", "version"));
packageRepository.setConfiguration(new Configuration(getConfigurationProperty("url", false, "http://go"), getConfigurationProperty("secure", true, "secure")));
PackageDefinition packageDefinition = new PackageDefinition("id", "name", new Configuration(getConfigurationProperty("name", false, "go-agent")));
packageDefinition.setRepository(packageRepository);
packageRepository.getPackages().add(packageDefinition);
cruiseConfig.getPackageRepositories().add(packageRepository);
xmlWriter.write(cruiseConfig, output, false);
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(output.toString());
PackageRepositories packageRepositories = goConfigHolder.config.getPackageRepositories();
assertThat(packageRepositories, is(cruiseConfig.getPackageRepositories()));
assertThat(packageRepositories.get(0).getConfiguration().first().getConfigurationValue().getValue(), is("http://go"));
assertThat(packageRepositories.get(0).getConfiguration().first().getEncryptedConfigurationValue(), is(nullValue()));
assertThat(packageRepositories.get(0).getConfiguration().last().getEncryptedValue(), is(new GoCipher().encrypt("secure")));
assertThat(packageRepositories.get(0).getConfiguration().last().getConfigurationValue(), is(nullValue()));
assertThat(packageRepositories.get(0).getPackages().get(0), is(packageDefinition));
assertThat(packageRepositories.get(0).getPackages().get(0).getConfiguration().first().getConfigurationValue().getValue(), is("go-agent"));
assertThat(packageRepositories.get(0).getPackages().get(0).getConfiguration().first().getEncryptedConfigurationValue(), is(nullValue()));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteRepositoryConfigurationWithPackagesWhenNoRepoAndPkgIdIsProvided.
@Test
public void shouldWriteRepositoryConfigurationWithPackagesWhenNoRepoAndPkgIdIsProvided() throws Exception {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setName("name");
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-id", "version"));
packageRepository.setConfiguration(new Configuration(getConfigurationProperty("url", false, "http://go"), getConfigurationProperty("secure", true, "secure")));
PackageDefinition packageDefinition = new PackageDefinition(null, "name", new Configuration(getConfigurationProperty("name", false, "go-agent")));
packageDefinition.setRepository(packageRepository);
packageRepository.getPackages().add(packageDefinition);
cruiseConfig.getPackageRepositories().add(packageRepository);
xmlWriter.write(cruiseConfig, output, false);
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(output.toString());
PackageRepositories packageRepositories = goConfigHolder.config.getPackageRepositories();
assertThat(packageRepositories.size(), is(cruiseConfig.getPackageRepositories().size()));
assertThat(packageRepositories.get(0).getId(), is(notNullValue()));
assertThat(packageRepositories.get(0).getPackages().size(), is(1));
assertThat(packageRepositories.get(0).getPackages().get(0).getId(), is(notNullValue()));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class DeletePackageConfigCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
PackageRepositories repositories = modifiedConfig.getPackageRepositories();
PackageRepository packageRepository = repositories.findPackageRepositoryHaving(this.packageDefinition.getId());
packageRepository.removePackage(this.packageDefinition.getId());
modifiedConfig.setPackageRepositories(repositories);
}
Aggregations