use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldReturnUrlForCommandLine_asLocation_IfSet.
@Test
public void shouldReturnUrlForCommandLine_asLocation_IfSet() {
TfsMaterial tfsMaterial = new TfsMaterial(new GoCipher(), new UrlArgument("http://foo:bar@my-url.com"), "loser", DOMAIN, "foo_bar_baz", "/dev/null");
assertThat(tfsMaterial.getLocation(), is("http://foo:******@my-url.com"));
tfsMaterial = new TfsMaterial(new GoCipher(), null, "loser", DOMAIN, "foo_bar_baz", "/dev/null");
assertThat(tfsMaterial.getLocation(), is(nullValue()));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method setUp.
@Before
public void setUp() {
GoCipher goCipher = mock(GoCipher.class);
tfsMaterialFirstCollectionFirstProject = new TfsMaterial(goCipher, new UrlArgument(TFS_FIRST_COLLECTION_URL), USERNAME, DOMAIN, PASSWORD, TFS_FIRST_PROJECT);
tfsMaterialFirstCollectionSecondProject = new TfsMaterial(goCipher, new UrlArgument(TFS_FIRST_COLLECTION_URL), USERNAME, DOMAIN, PASSWORD, TFS_SECOND_PROJECT);
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldNotDecryptPasswordIfPasswordIsNotNull.
@Test
public void shouldNotDecryptPasswordIfPasswordIsNotNull() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
when(mockGoCipher.decrypt("encrypted")).thenReturn("password");
TfsMaterial material = new TfsMaterial(mockGoCipher, new UrlArgument("/foo"), "username", DOMAIN, "password", "");
material.ensureEncrypted();
when(mockGoCipher.encrypt("new_password")).thenReturn("new_encrypted");
material.setPassword("new_password");
when(mockGoCipher.decrypt("new_encrypted")).thenReturn("new_password");
assertThat(material.getPassword(), is("new_password"));
}
use of com.thoughtworks.go.security.GoCipher 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"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class P4MaterialTest method shouldEncryptP4Password.
@Test
public void shouldEncryptP4Password() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
P4Material p4Material = new P4Material("example.com:1818", "view", mockGoCipher);
p4Material.setPassword("password");
p4Material.ensureEncrypted();
assertThat(p4Material.getEncryptedPassword(), is("encrypted"));
assertThat(p4Material.getPassword(), is(nullValue()));
}
Aggregations