use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class PluginRoleConfigTest method shouldNotEncryptSecurePluginProperties_WhenPluginInfosIsAbsent.
@Test
public void shouldNotEncryptSecurePluginProperties_WhenPluginInfosIsAbsent() throws CryptoException {
String authConfigId = "auth_config_id";
String pluginId = "cd.go.github";
BasicCruiseConfig basicCruiseConfig = new BasicCruiseConfig();
basicCruiseConfig.server().security().securityAuthConfigs().add(new SecurityAuthConfig(authConfigId, pluginId));
PluginRoleConfig role = new PluginRoleConfig("admin", authConfigId);
role.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("pub_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("pub_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("pub_v3"))));
assertThat(role.getProperty("k1").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k1").getConfigValue(), is("pub_v1"));
assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
assertThat(role.getProperty("k3").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k3").getConfigValue(), is("pub_v3"));
assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
role.encryptSecureProperties(basicCruiseConfig);
assertThat(role.getProperty("k1").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k1").getConfigValue(), is("pub_v1"));
assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
assertThat(role.getProperty("k3").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k3").getConfigValue(), is("pub_v3"));
assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class PluginRoleConfigTest method shouldNotEncryptSecurePluginProperties_WhenReferencedAuthConfigDoesNotExists.
@Test
public void shouldNotEncryptSecurePluginProperties_WhenReferencedAuthConfigDoesNotExists() throws CryptoException {
setAuthorizationPluginInfo();
String authConfigId = "auth_config_id";
BasicCruiseConfig basicCruiseConfig = new BasicCruiseConfig();
PluginRoleConfig role = new PluginRoleConfig("admin", authConfigId);
role.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("pub_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("pub_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("pub_v3"))));
assertThat(role.getProperty("k1").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k1").getConfigValue(), is("pub_v1"));
assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
assertThat(role.getProperty("k3").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k3").getConfigValue(), is("pub_v3"));
assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
role.encryptSecureProperties(basicCruiseConfig);
assertThat(role.getProperty("k1").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k1").getConfigValue(), is("pub_v1"));
assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
assertThat(role.getProperty("k3").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k3").getConfigValue(), is("pub_v3"));
assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ElasticProfileTest method postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined.
@Test
public void postConstruct_shouldIgnoreEncryptionIfPluginInfoIsNotDefined() {
ElasticProfile profile = new ElasticProfile("id", "prod-cluster", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
// profile.encryptSecureConfigurations();
assertThat(profile.size(), is(1));
assertFalse(profile.first().isSecure());
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ElasticProfileTest method shouldEncryptSecureConfigurations.
@Test
public void shouldEncryptSecureConfigurations() {
PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true))));
ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor(pluginId), profileSettings, profileSettings, null, null, null);
store.setPluginInfo(pluginInfo);
ElasticProfile profile = new ElasticProfile("id", clusterProfileId, new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
profile.encryptSecureProperties(config);
assertThat(profile.size(), is(1));
assertTrue(profile.first().isSecure());
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ElasticProfileTest method addConfigurations_shouldAddConfigurationsWithValue.
@Test
public void addConfigurations_shouldAddConfigurationsWithValue() throws Exception {
ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("some_name"));
ElasticProfile profile = new ElasticProfile("id", "prod-cluster");
profile.addConfigurations(Arrays.asList(property));
assertThat(profile.size(), is(1));
assertThat(profile, contains(new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("some_name"))));
}
Aggregations