use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteToFileWithValueOfFalseForPackageDefinitionAutoUpdateWhenFalse.
@Test
public void shouldWriteToFileWithValueOfFalseForPackageDefinitionAutoUpdateWhenFalse() throws Exception {
Configuration configuration = new Configuration(getConfigurationProperty("url", false, "http://go"));
Packages packages = new Packages();
PackageDefinition aPackage = new PackageDefinition("package-id", "package-name", configuration);
aPackage.setAutoUpdate(false);
packages.add(aPackage);
PackageRepository repository = createPackageRepository("plugin-id", "version", "id", "name", configuration, packages);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
xmlWriter.write(cruiseConfig, output, false);
assertThat(output.toString().contains("autoUpdate=\"false\""), is(true));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesRepositoryWithInvalidName.
@Test
public void shouldNotAllowPackagesRepositoryWithInvalidName() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name with space", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two repositories with same id");
} catch (GoConfigInvalidException e) {
assertThat(e.getMessage(), is("Invalid PackageRepository name 'name with space'. This must be alphanumeric and can contain underscores, hyphens and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldLoadAutoUpdateValueForPackageWhenLoadedFromConfigFile.
@Test
void shouldLoadAutoUpdateValueForPackageWhenLoadedFromConfigFile() throws Exception {
String configTemplate = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>" + "<repositories>" + " <repository id='2ef830d7-dd66-42d6-b393-64a84646e557' name='GoYumRepo'>" + " <pluginConfiguration id='yum' version='1' />" + " <configuration>" + " <property>" + " <key>REPO_URL</key>" + " <value>http://fake-yum-repo/go/yum/no-arch</value>" + " </property>" + " </configuration>" + " <packages>" + " <package id='88a3beca-cbe2-4c4d-9744-aa0cda3f371c' name='1' autoUpdate='%s'>" + " <configuration>" + " <property>" + " <key>REPO_URL</key>" + " <value>http://fake-yum-repo/go/yum/no-arch</value>" + " </property>" + " </configuration>" + " </package>" + " </packages>" + " </repository>" + "</repositories>" + "</cruise>";
String configContent = String.format(configTemplate, false);
GoConfigHolder holder = xmlLoader.loadConfigHolder(configContent);
PackageRepository packageRepository = holder.config.getPackageRepositories().find("2ef830d7-dd66-42d6-b393-64a84646e557");
PackageDefinition aPackage = packageRepository.findPackage("88a3beca-cbe2-4c4d-9744-aa0cda3f371c");
assertThat(aPackage.isAutoUpdate()).isFalse();
configContent = String.format(configTemplate, true);
holder = xmlLoader.loadConfigHolder(configContent);
packageRepository = holder.config.getPackageRepositories().find("2ef830d7-dd66-42d6-b393-64a84646e557");
aPackage = packageRepository.findPackage("88a3beca-cbe2-4c4d-9744-aa0cda3f371c");
assertThat(aPackage.isAutoUpdate()).isTrue();
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class RulesService method validateSecretConfigReferences.
public void validateSecretConfigReferences(PackageMaterial packageMaterial) {
PackageRepository pkgRepository = packageMaterial.getPackageDefinition().getRepository();
Map<CaseInsensitiveString, StringBuilder> errors = validate(packageMaterial.getSecretParams(), pkgRepository.getClass(), pkgRepository.getName(), "Package Material");
if (!errors.isEmpty()) {
throw new RulesViolationException(errorString(errors));
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class PackageRepositoryRepresenter method fromJSON.
public static PackageRepository fromJSON(JsonReader jsonReader) {
PackageRepository packageRepository = new PackageRepository();
jsonReader.readStringIfPresent("id", packageRepository::setId);
jsonReader.readStringIfPresent("name", packageRepository::setName);
return packageRepository;
}
Aggregations