Search in sources :

Example 11 with PackageRepositories

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

the class MagicalGoConfigXmlWriterTest method shouldNotAllowMultipleRepositoriesWithSameId.

@Test
public void shouldNotAllowMultipleRepositoriesWithSameId() 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-1", "version", "id", "name1", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
    PackageRepository anotherPackageRepository = createPackageRepository("plugin-id-2", "version", "id", "name2", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
    cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository, anotherPackageRepository));
    try {
        xmlWriter.write(cruiseConfig, output, false);
        fail("should not have allowed two repositories with same id");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), anyOf(is("Duplicate unique value [id] declared for identity constraint of element \"repositories\"."), is("Duplicate unique value [id] declared for identity constraint \"uniqueRepositoryId\" of element \"repositories\".")));
    }
}
Also used : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) 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.jupiter.api.Test)

Example 12 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories 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"));
    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)));
    cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository, anotherPackageRepository));
    try {
        xmlWriter.write(cruiseConfig, output, false);
        fail("should not have allowed two package repositories with same id");
    } catch (XsdValidationException e) {
        assertThat(e.getMessage(), anyOf(is("Duplicate unique value [id] declared for identity constraint of element \"cruise\"."), is("Duplicate unique value [id] declared for identity constraint \"uniquePackageId\" of element \"cruise\".")));
    }
}
Also used : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) 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.jupiter.api.Test)

Example 13 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories 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"));
    PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id wth space", "name", 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 (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 : XsdValidationException(com.thoughtworks.go.util.XsdValidationException) 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.jupiter.api.Test)

Example 14 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories 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"));
    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)));
    cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository, anotherPackageRepository));
    try {
        xmlWriter.write(cruiseConfig, 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.jupiter.api.Test)

Example 15 with PackageRepositories

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

the class MagicalGoConfigXmlWriterTest method shouldNotAllowMultiplePackagesWithSameNameWithinARepo.

@Test
public void shouldNotAllowMultiplePackagesWithSameNameWithinARepo() throws Exception {
    Configuration packageConfiguration1 = new Configuration(getConfigurationProperty("name", false, "go-agent"));
    Configuration packageConfiguration2 = new Configuration(getConfigurationProperty("name2", false, "go-server"));
    Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
    PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name", repositoryConfiguration, new Packages(new PackageDefinition("id1", "name", packageConfiguration1), new PackageDefinition("id2", "name", packageConfiguration2)));
    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("You have defined multiple packages called 'name'. Package names are case-insensitive and must be unique within a repository."));
    }
}
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.jupiter.api.Test)

Aggregations

PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)52 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)40 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)29 Test (org.junit.jupiter.api.Test)29 Packages (com.thoughtworks.go.domain.packagerepository.Packages)14 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 Test (org.junit.Test)8 Username (com.thoughtworks.go.server.domain.Username)7 BeforeEach (org.junit.jupiter.api.BeforeEach)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 XsdValidationException (com.thoughtworks.go.util.XsdValidationException)4 ArrayList (java.util.ArrayList)4 Arrays.asList (java.util.Arrays.asList)4 List (java.util.List)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 GoCipher (com.thoughtworks.go.security.GoCipher)2