Search in sources :

Example 26 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertGitMaterial.

@Test
void shouldConvertGitMaterial() {
    CRGitMaterial crGitMaterial = new CRGitMaterial("name", "folder", true, false, null, filter, "url", "branch", true);
    GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) configConverter.toMaterialConfig(crGitMaterial, context, new SCMs());
    assertThat(gitMaterialConfig.getName().toLower()).isEqualTo("name");
    assertThat(gitMaterialConfig.getFolder()).isEqualTo("folder");
    assertThat(gitMaterialConfig.getAutoUpdate()).isTrue();
    assertThat(gitMaterialConfig.isInvertFilter()).isFalse();
    assertThat(gitMaterialConfig.getFilterAsString()).isEqualTo("filter");
    assertThat(gitMaterialConfig.getUrl()).isEqualTo("url");
    assertThat(gitMaterialConfig.getBranch()).isEqualTo("branch");
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 27 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertGitMaterialConfigToCRGitMaterialWhenPlainPassword.

@Test
void shouldConvertGitMaterialConfigToCRGitMaterialWhenPlainPassword() throws CryptoException {
    GitMaterialConfig gitMaterialConfig = git("url", "branch", true);
    gitMaterialConfig.setName(new CaseInsensitiveString("name"));
    gitMaterialConfig.setFolder("folder");
    gitMaterialConfig.setAutoUpdate(true);
    gitMaterialConfig.setInvertFilter(false);
    gitMaterialConfig.setFilter(Filter.create("filter"));
    gitMaterialConfig.setPassword("secret");
    CRGitMaterial crGitMaterial = (CRGitMaterial) configConverter.materialToCRMaterial(gitMaterialConfig);
    assertThat(crGitMaterial.getName()).isEqualTo("name");
    assertThat(crGitMaterial.getDestination()).isEqualTo("folder");
    assertThat(crGitMaterial.isAutoUpdate()).isTrue();
    assertThat(crGitMaterial.isWhitelist()).isFalse();
    assertThat(crGitMaterial.getFilterList()).contains("filter");
    assertThat(crGitMaterial.getUrl()).isEqualTo("url");
    assertThat(crGitMaterial.getBranch()).isEqualTo("branch");
    assertThat(crGitMaterial.isShallowClone()).isTrue();
    assertThat(crGitMaterial.getPassword()).isNull();
    assertThat(crGitMaterial.getEncryptedPassword()).isEqualTo(new GoCipher().encrypt("secret"));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 28 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertGitMaterialWhenWhitelist.

@Test
void shouldConvertGitMaterialWhenWhitelist() {
    CRGitMaterial crGitMaterial = new CRGitMaterial("name", "folder", true, true, null, filter, "url", "branch", true);
    GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) configConverter.toMaterialConfig(crGitMaterial, context, new SCMs());
    assertThat(gitMaterialConfig.getName().toLower()).isEqualTo("name");
    assertThat(gitMaterialConfig.getFolder()).isEqualTo("folder");
    assertThat(gitMaterialConfig.getAutoUpdate()).isTrue();
    assertThat(gitMaterialConfig.isInvertFilter()).isTrue();
    assertThat(gitMaterialConfig.getFilterAsString()).isEqualTo("filter");
    assertThat(gitMaterialConfig.getUrl()).isEqualTo("url");
    assertThat(gitMaterialConfig.getBranch()).isEqualTo("branch");
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 29 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertGitMaterialConfigToCRGitMaterialWhenEncryptedPassword.

@Test
void shouldConvertGitMaterialConfigToCRGitMaterialWhenEncryptedPassword() throws CryptoException {
    GitMaterialConfig gitMaterialConfig = git("url", "branch", true);
    gitMaterialConfig.setName(new CaseInsensitiveString("name"));
    gitMaterialConfig.setFolder("folder");
    gitMaterialConfig.setAutoUpdate(true);
    gitMaterialConfig.setInvertFilter(false);
    gitMaterialConfig.setFilter(Filter.create("filter"));
    gitMaterialConfig.setEncryptedPassword(new GoCipher().encrypt("secret"));
    CRGitMaterial crGitMaterial = (CRGitMaterial) configConverter.materialToCRMaterial(gitMaterialConfig);
    assertThat(crGitMaterial.getName()).isEqualTo("name");
    assertThat(crGitMaterial.getDestination()).isEqualTo("folder");
    assertThat(crGitMaterial.isAutoUpdate()).isTrue();
    assertThat(crGitMaterial.isWhitelist()).isFalse();
    assertThat(crGitMaterial.getFilterList()).contains("filter");
    assertThat(crGitMaterial.getUrl()).isEqualTo("url");
    assertThat(crGitMaterial.getBranch()).isEqualTo("branch");
    assertThat(crGitMaterial.isShallowClone()).isTrue();
    assertThat(crGitMaterial.getEncryptedPassword()).isEqualTo(new GoCipher().encrypt("secret"));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 30 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertGitMaterialWhenEncryptedPassword.

@Test
void shouldConvertGitMaterialWhenEncryptedPassword() throws CryptoException {
    CRGitMaterial crGitMaterial = new CRGitMaterial("name", "folder", true, false, null, filter, "url", "branch", true);
    crGitMaterial.setEncryptedPassword(new GoCipher().encrypt("secret"));
    GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) configConverter.toMaterialConfig(crGitMaterial, context, new SCMs());
    assertThat(gitMaterialConfig.getName().toLower()).isEqualTo("name");
    assertThat(gitMaterialConfig.getFolder()).isEqualTo("folder");
    assertThat(gitMaterialConfig.getAutoUpdate()).isTrue();
    assertThat(gitMaterialConfig.isInvertFilter()).isFalse();
    assertThat(gitMaterialConfig.getFilterAsString()).isEqualTo("filter");
    assertThat(gitMaterialConfig.getUrl()).isEqualTo("url");
    assertThat(gitMaterialConfig.getBranch()).isEqualTo("branch");
    assertThat(gitMaterialConfig.getPassword()).isEqualTo("secret");
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) GoCipher(com.thoughtworks.go.security.GoCipher) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7