use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method shouldValidateWhetherTheEncryptedPasswordIsCorrect.
@Test
public void shouldValidateWhetherTheEncryptedPasswordIsCorrect() {
TfsMaterialConfig materialConfig = new TfsMaterialConfig(new UrlArgument("foo/bar"), "", "encryptedPassword", new GoCipher());
materialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(materialConfig.errors().on("encryptedPassword"), is("Encrypted password value for TFS material with url 'foo/bar' is invalid. This usually happens when the cipher text is modified to have an invalid value."));
}
use of com.thoughtworks.go.util.command.UrlArgument 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.util.command.UrlArgument 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.util.command.UrlArgument 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)));
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class TfsMaterialTest method shouldEncryptTfsPasswordAndMarkPasswordAsNull.
@Test
public void shouldEncryptTfsPasswordAndMarkPasswordAsNull() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
TfsMaterial tfsMaterial = new TfsMaterial(mockGoCipher, new UrlArgument("/foo"), "username", DOMAIN, "password", "");
tfsMaterial.ensureEncrypted();
assertThat(tfsMaterial.getPassword(), is(nullValue()));
assertThat(tfsMaterial.getEncryptedPassword(), is("encrypted"));
}
Aggregations