use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class GoConfigGraphWalkerTest method shouldNotWalkFieldsWhichAreTaggedWithIgnoreTraversal.
@Test
public void shouldNotWalkFieldsWhichAreTaggedWithIgnoreTraversal() {
PackageRepository repository = mock(PackageRepository.class);
PackageDefinition packageDefinition = new PackageDefinition();
packageDefinition.setRepository(repository);
new GoConfigGraphWalker(packageDefinition).walk(new GoConfigGraphWalker.Handler() {
@Override
public void handle(Validatable validatable, ValidationContext ctx) {
validatable.validate(ctx);
}
});
verify(repository, never()).validate(any(ValidationContext.class));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldResolvePackageRepoReferenceElementForAPackageInConfig.
@Test
void shouldResolvePackageRepoReferenceElementForAPackageInConfig() throws Exception {
String xml = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>\n" + "<repositories>\n" + " <repository id='repo-id' name='name'>\n" + " <pluginConfiguration id='plugin-id' version='1.0'/>\n" + " <configuration>\n" + " <property>\n" + " <key>url</key>\n" + " <value>http://go</value>\n" + " </property>\n" + " </configuration>\n" + " <packages>\n" + " <package id='package-id' name='name'>\n" + " <configuration>\n" + " <property>\n" + " <key>name</key>\n" + " <value>go-agent</value>\n" + " </property>\n" + " </configuration>\n" + " </package>\n" + " </packages>\n" + " </repository>\n" + " </repositories></cruise>";
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(xml);
PackageRepository packageRepository = goConfigHolder.config.getPackageRepositories().first();
PackageDefinition packageDefinition = packageRepository.getPackages().first();
assertThat(packageDefinition.getRepository()).isEqualTo(packageRepository);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldFailValidationIfPackageTypeMaterialForPipelineHasARefToNonExistantPackage.
@Test
public void shouldFailValidationIfPackageTypeMaterialForPipelineHasARefToNonExistantPackage() throws Exception {
String packageId = "does-not-exist";
PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(packageId);
PackageRepository repository = com.thoughtworks.go.domain.packagerepository.PackageRepositoryMother.create("repo-id", "repo-name", "pluginid", "version", new Configuration(com.thoughtworks.go.domain.packagerepository.ConfigurationPropertyMother.create("k1", false, "v1")));
packageMaterialConfig.setPackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinitionMother.create("does-not-exist", "package-name", new Configuration(com.thoughtworks.go.domain.packagerepository.ConfigurationPropertyMother.create("k2", false, "v2")), repository));
JobConfig jobConfig = new JobConfig("ls");
jobConfig.addTask(new AntTask());
cruiseConfig.addPipeline("default", com.thoughtworks.go.helper.PipelineConfigMother.pipelineConfig("test", new MaterialConfigs(packageMaterialConfig), new JobConfigs(jobConfig)));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not allow this");
} catch (XsdValidationException exception) {
assertThat(exception.getMessage(), is("Key 'packageIdReferredByMaterial' with value 'does-not-exist' not found for identity constraint of element 'cruise'."));
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository 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.PackageRepository 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()));
}
Aggregations