Search in sources :

Example 1 with Packages

use of com.thoughtworks.go.domain.packagerepository.Packages in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldNotAllowMultipleRepositoriesWithSameName.

@Test
public void shouldNotAllowMultipleRepositoriesWithSameName() throws Exception {
    Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
    Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
    CruiseConfig configToSave = new BasicCruiseConfig();
    PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id1", "name", repositoryConfiguration, new Packages(new PackageDefinition("id1", "name1", packageConfiguration)));
    PackageRepository anotherPackageRepository = createPackageRepository("plugin-id", "version", "id2", "name", repositoryConfiguration, new Packages(new PackageDefinition("id2", "name2", packageConfiguration)));
    configToSave.setPackageRepositories(new PackageRepositories(packageRepository, anotherPackageRepository));
    try {
        xmlWriter.write(configToSave, output, false);
        fail("should not have allowed two repositories with same id");
    } catch (GoConfigInvalidException e) {
        assertThat(e.getMessage(), is("You have defined multiple repositories called 'name'. Repository names are case-insensitive and must be unique."));
    }
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) Test(org.junit.Test)

Example 2 with Packages

use of com.thoughtworks.go.domain.packagerepository.Packages in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesRepositoryWithInvalidId.

@Test
public void shouldNotAllowPackagesRepositoryWithInvalidId() throws Exception {
    Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
    Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
    CruiseConfig configToSave = new BasicCruiseConfig();
    PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id wth space", "name", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
    configToSave.setPackageRepositories(new PackageRepositories(packageRepository));
    try {
        xmlWriter.write(configToSave, output, false);
        fail("should not have allowed two repositories with same id");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), is("Repo id is invalid. \"id wth space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
    }
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 3 with Packages

use of com.thoughtworks.go.domain.packagerepository.Packages in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesWithInvalidName.

@Test
public void shouldNotAllowPackagesWithInvalidName() throws Exception {
    Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
    Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
    CruiseConfig configToSave = new BasicCruiseConfig();
    PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name", repositoryConfiguration, new Packages(new PackageDefinition("id", "name with space", packageConfiguration)));
    configToSave.setPackageRepositories(new PackageRepositories(packageRepository));
    try {
        xmlWriter.write(configToSave, output, false);
        fail("should not have allowed two repositories with same id");
    } catch (GoConfigInvalidException e) {
        assertThat(e.getMessage(), is("Invalid Package name 'name with space'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
    }
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) Test(org.junit.Test)

Example 4 with Packages

use of com.thoughtworks.go.domain.packagerepository.Packages in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldNotAllowMultiplePackagesWithSameId.

@Test
public void shouldNotAllowMultiplePackagesWithSameId() throws Exception {
    Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
    Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
    CruiseConfig configToSave = new BasicCruiseConfig();
    PackageRepository packageRepository = createPackageRepository("plugin-id-1", "version", "id1", "name1", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
    PackageRepository anotherPackageRepository = createPackageRepository("plugin-id-2", "version", "id2", "name2", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
    configToSave.setPackageRepositories(new PackageRepositories(packageRepository, anotherPackageRepository));
    try {
        xmlWriter.write(configToSave, output, false);
        fail("should not have allowed two package repositories with same id");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), is("Duplicate unique value [id] declared for identity constraint \"uniquePackageId\" of element \"cruise\"."));
    }
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 5 with Packages

use of com.thoughtworks.go.domain.packagerepository.Packages 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"));
    CruiseConfig configToSave = new BasicCruiseConfig();
    PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name with space", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
    configToSave.setPackageRepositories(new PackageRepositories(packageRepository));
    try {
        xmlWriter.write(configToSave, 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 and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
    }
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) Test(org.junit.Test)

Aggregations

Packages (com.thoughtworks.go.domain.packagerepository.Packages)14 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)13 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)12 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)12 Test (org.junit.Test)12 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)1 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)1 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)1 GoCipher (com.thoughtworks.go.security.GoCipher)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1