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 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()));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class GoConfigMigrationIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
File file = temporaryFolder.newFolder();
configFile = new File(file, "cruise-config.xml");
new SystemEnvironment().setProperty(SystemEnvironment.CONFIG_FILE_PROPERTY, configFile.getAbsolutePath());
GoConfigFileHelper.clearConfigVersions();
configRepository = new ConfigRepository(systemEnvironment);
configRepository.initialize();
serverHealthService.removeAllLogs();
currentGoServerVersion = serverVersion.version();
loader = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins());
password = UUID.randomUUID().toString();
encryptedPassword = new GoCipher().encrypt(password);
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class PluggableTaskTest method testConfigAsMap.
@Test
public void testConfigAsMap() throws Exception {
PluginConfiguration pluginConfiguration = new PluginConfiguration("test-plugin-id", "13.4");
GoCipher cipher = new GoCipher();
List<String> keys = Arrays.asList("Avengers 1", "Avengers 2", "Avengers 3", "Avengers 4");
List<String> values = Arrays.asList("Iron man", "Hulk", "Thor", "Captain America");
Configuration configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey(keys.get(0)), new ConfigurationValue(values.get(0))), new ConfigurationProperty(new ConfigurationKey(keys.get(1)), new ConfigurationValue(values.get(1))), new ConfigurationProperty(new ConfigurationKey(keys.get(2)), new ConfigurationValue(values.get(2))), new ConfigurationProperty(new ConfigurationKey(keys.get(3)), null, new EncryptedConfigurationValue(cipher.encrypt(values.get(3))), cipher));
PluggableTask task = new PluggableTask(pluginConfiguration, configuration);
Map<String, Map<String, String>> configMap = task.configAsMap();
assertThat(configMap.keySet().size(), is(keys.size()));
assertThat(configMap.values().size(), is(values.size()));
assertThat(configMap.keySet().containsAll(keys), is(true));
for (int i = 0; i < keys.size(); i++) {
assertThat(configMap.get(keys.get(i)).get(PluggableTask.VALUE_KEY), is(values.get(i)));
}
}
Aggregations