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");
}
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"));
}
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");
}
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"));
}
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");
}
Aggregations