Search in sources :

Example 61 with GoCipher

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()));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Example 62 with GoCipher

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);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Before(org.junit.Before)

Example 63 with GoCipher

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"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Example 64 with GoCipher

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"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Example 65 with GoCipher

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()));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Aggregations

GoCipher (com.thoughtworks.go.security.GoCipher)149 Test (org.junit.Test)128 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)36 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)16 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)15 HashMap (java.util.HashMap)15 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)11 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)10 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)10 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)10 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)10 Configuration (com.thoughtworks.go.domain.config.Configuration)9 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)8 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)7 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)7 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)7 Map (java.util.Map)7 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)6 File (java.io.File)6