use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided.
@Test
public void shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided() {
TfsMaterialConfig materialConfig = new TfsMaterialConfig(new UrlArgument("foo/bar"), "password", "encryptedPassword", new GoCipher());
materialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(materialConfig.errors().on("password"), is("You may only specify `password` or `encrypted_password`, not both!"));
assertThat(materialConfig.errors().on("encryptedPassword"), is("You may only specify `password` or `encrypted_password`, not both!"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method shouldSetConfigAttributes.
@Test
public void shouldSetConfigAttributes() {
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "some_domain", "passwd", "walk_this_path");
Map<String, String> map = new HashMap<>();
map.put(ScmMaterialConfig.URL, "http://foo:8080/tfs/HelloWorld");
map.put(ScmMaterialConfig.USERNAME, "boozer");
map.put(ScmMaterialConfig.PASSWORD, "secret");
map.put(ScmMaterialConfig.FOLDER, "folder");
map.put(ScmMaterialConfig.AUTO_UPDATE, "0");
map.put(ScmMaterialConfig.FILTER, "/root,/**/*.help");
map.put(AbstractMaterialConfig.MATERIAL_NAME, "my-tfs-material-name");
map.put(TfsMaterialConfig.PROJECT_PATH, "/useless/project");
map.put(TfsMaterialConfig.DOMAIN, "CORPORATE");
tfsMaterialConfig.setConfigAttributes(map);
TfsMaterialConfig newTfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://foo:8080/tfs/HelloWorld"), "boozer", "CORPORATE", "secret", "/useless/project");
newTfsMaterialConfig.setName(new CaseInsensitiveString("my-tfs-material-name"));
newTfsMaterialConfig.setFolder("folder");
assertThat(tfsMaterialConfig, is(newTfsMaterialConfig));
assertThat(tfsMaterialConfig.getPassword(), is("passwd"));
assertThat(tfsMaterialConfig.isAutoUpdate(), is(false));
assertThat(tfsMaterialConfig.getDomain(), is("CORPORATE"));
assertThat(tfsMaterialConfig.getName(), is(new CaseInsensitiveString("my-tfs-material-name")));
assertThat(tfsMaterialConfig.filter(), is(new Filter(new IgnoredFiles("/root"), new IgnoredFiles("/**/*.help"))));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method validate_shouldEnsureDestFilePathIsValid.
@Test
public void validate_shouldEnsureDestFilePathIsValid() {
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "passwd", "walk_this_path");
tfsMaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "../a"));
tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.FOLDER), is("Dest folder '../a' is not valid. It must be a sub-directory of the working folder."));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method validate_shouldEnsureMandatoryFieldsAreNotBlank.
@Test
public void validate_shouldEnsureMandatoryFieldsAreNotBlank() {
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument(""), "", "CORPORATE", "", "");
tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.URL), is("URL cannot be blank"));
assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.USERNAME), is("Username cannot be blank"));
assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.PROJECT_PATH), is("Project Path cannot be blank"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldInjectAllRelevantAttributesInSqlCriteriaMap.
@Test
public void shouldInjectAllRelevantAttributesInSqlCriteriaMap() {
TfsMaterial tfsMaterial = new TfsMaterial(new GoCipher(), new UrlArgument("my-url"), "loser", DOMAIN, "foo_bar_baz", "/dev/null");
assertThat(tfsMaterial.getSqlCriteria(), Is.is(DataStructureUtils.m(AbstractMaterial.SQL_CRITERIA_TYPE, (Object) "TfsMaterial", "url", "my-url", "username", "loser", "projectPath", "/dev/null", "domain", DOMAIN)));
}
Aggregations