use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class PluginInfoBuilderTest method setUp.
@Before
public void setUp() {
initMocks(this);
githubDescriptor = new GoPluginDescriptor("github.oauth", "version1", new GoPluginDescriptor.About("Github OAuth Plugin", "1.0", null, null, null, null), null, null, false);
emailNotifier = new GoPluginDescriptor("email.notifier", "version1", new GoPluginDescriptor.About("Email Notifier", "1.0", null, null, null, null), null, null, false);
yumPoller = new GoPluginDescriptor("yum.poller", "version1", new GoPluginDescriptor.About("Yum Poller", "1.0", null, null, null, null), null, null, false);
xunitConvertor = new GoPluginDescriptor("xunit.convertor", "version1", new GoPluginDescriptor.About("Xunit Convertor", "1.0", null, null, null, null), null, null, false);
githubPR = new GoPluginDescriptor("github.pr", "version1", new GoPluginDescriptor.About("Github PR", "1.0", null, null, null, null), null, null, false);
dockerElasticAgentPlugin = new GoPluginDescriptor("cd.go.elastic-agent.docker", "1.0", new GoPluginDescriptor.About("GoCD Docker Elastic Agent Plugin", "1.0", null, null, null, null), null, null, false);
ldapAuthPlugin = new GoPluginDescriptor("cd.go.authorization.ldap", "1.0", new GoPluginDescriptor.About("GoCD LDAP Plugin", "1.0", null, null, null, null), null, null, false);
JsonBasedPluggableTask jsonBasedPluggableTask = mock(JsonBasedPluggableTask.class);
TaskView taskView = new TaskView() {
@Override
public String displayValue() {
return "task display value";
}
@Override
public String template() {
return "pluggable task view template";
}
};
when(authenticationPluginRegistry.getAuthenticationPlugins()).thenReturn(new HashSet<>(Arrays.asList("github.oauth")));
when(notificationPluginRegistry.getNotificationPlugins()).thenReturn(new HashSet<>(Arrays.asList("email.notifier")));
when(elasticPluginConfigMetadataStore.getPlugins()).thenReturn(new ArrayList<>(Arrays.asList(dockerElasticAgentPlugin)));
when(authorizationPluginConfigMetadataStore.getPlugins()).thenReturn(new ArrayList<>(Arrays.asList(ldapAuthPlugin)));
when(jsonBasedPluggableTask.view()).thenReturn(taskView);
when(manager.getPluginDescriptorFor("github.oauth")).thenReturn(githubDescriptor);
when(manager.getPluginDescriptorFor("email.notifier")).thenReturn(emailNotifier);
when(manager.getPluginDescriptorFor("yum.poller")).thenReturn(yumPoller);
when(manager.getPluginDescriptorFor("xunit.convertor")).thenReturn(xunitConvertor);
when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
when(manager.getPluginDescriptorFor("cd.go.elastic-agent.docker")).thenReturn(dockerElasticAgentPlugin);
when(manager.getPluginDescriptorFor(ldapAuthPlugin.id())).thenReturn(ldapAuthPlugin);
MetadataStoreHelper.clear();
PackageMetadataStore.getInstance().addMetadataFor(yumPoller.id(), new PackageConfigurations());
PluggableTaskConfigStore.store().setPreferenceFor("xunit.convertor", new TaskPreference(jsonBasedPluggableTask));
SCMMetadataStore.getInstance().setPreferenceFor("github.pr", new SCMPreference(new SCMConfigurations(), mock(SCMView.class)));
pluginViewModelBuilder = new PluginInfoBuilder(authenticationPluginRegistry, notificationPluginRegistry, elasticPluginConfigMetadataStore, authorizationPluginConfigMetadataStore, manager);
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class PackageRepositoryPluginInfoBuilderTest method pluginInfoFor_ShouldProvidePluginInfoForAPlugin.
@Test
public void pluginInfoFor_ShouldProvidePluginInfoForAPlugin() throws Exception {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
PluginManager pluginManager = mock(PluginManager.class);
PackageMetadataStore packageMetadataStore = mock(PackageMetadataStore.class);
RepositoryMetadataStore repositoryMetadataStore = mock(RepositoryMetadataStore.class);
when(packageMetadataStore.getPlugins()).thenReturn(Collections.singletonList(plugin.id()));
when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
PackageConfigurations packageConfigurations = new PackageConfigurations();
packageConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key1"));
packageConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key2"));
PackageConfigurations repoConfigurations = new PackageConfigurations();
repoConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key1"));
repoConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key2"));
when(packageMetadataStore.getMetadata(plugin.id())).thenReturn(packageConfigurations);
when(repositoryMetadataStore.getMetadata(plugin.id())).thenReturn(repoConfigurations);
PackageRepositoryPluginInfoBuilder builder = new PackageRepositoryPluginInfoBuilder(pluginManager, packageMetadataStore, repositoryMetadataStore);
PackageRepositoryPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
PackageRepositoryPluginInfo expectedPluginInfo = new PackageRepositoryPluginInfo(plugin, new PluggableInstanceSettings(configurations(packageConfigurations)), new PluggableInstanceSettings(configurations(repoConfigurations)));
assertEquals(expectedPluginInfo, pluginInfo);
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class GoConfigMother method configWithPackageRepo.
public static CruiseConfig configWithPackageRepo(String... ids) throws Exception {
final CruiseConfig config = new BasicCruiseConfig();
PackageConfigurations configuration = new PackageConfigurations();
configuration.addConfiguration(new PackageConfiguration("key1"));
configuration.addConfiguration(new PackageConfiguration("key2").with(PackageConfiguration.SECURE, true));
RepositoryMetadataStore.getInstance().addMetadataFor("plugin-1", configuration);
for (String id : ids) {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setId(id);
packageRepository.setName("name" + id);
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-1", "1.0.0"));
packageRepository.setPackages(new Packages(PackageDefinitionMother.create(id + "-pkg-1", packageRepository), PackageDefinitionMother.create(id + "-pkg-2", packageRepository)));
GoCipher cipher = new GoCipher();
ConfigurationProperty p1 = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"));
ConfigurationProperty p2 = new ConfigurationProperty(new ConfigurationKey("key2"), null, new EncryptedConfigurationValue(cipher.encrypt("value2")), cipher);
packageRepository.setConfiguration(new Configuration(p1, p2));
config.setPackageRepositories(new PackageRepositories(packageRepository));
}
return config;
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class ConfigurationPropertyTest method shouldSetConfigAttributesForNonSecureProperty.
@Test
public void shouldSetConfigAttributesForNonSecureProperty() throws Exception {
ConfigurationProperty configurationProperty = new ConfigurationProperty();
HashMap attributes = new HashMap();
HashMap keyMap = new HashMap();
keyMap.put("name", "fooKey");
attributes.put(ConfigurationProperty.CONFIGURATION_KEY, keyMap);
HashMap valueMap = new HashMap();
valueMap.put("value", "fooValue");
attributes.put(ConfigurationProperty.CONFIGURATION_VALUE, valueMap);
PackageConfigurations metadata = new PackageConfigurations();
metadata.addConfiguration(new PackageConfiguration("fooKey", null));
attributes.put(Configuration.METADATA, metadata);
configurationProperty.setConfigAttributes(attributes, null);
assertThat(configurationProperty.getConfigurationKey().getName(), is("fooKey"));
assertThat(configurationProperty.getConfigurationValue().getValue(), is("fooValue"));
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class PackageDefinitionTest method shouldGetFingerprint.
@Test
public void shouldGetFingerprint() {
String pluginId = "pluginid";
PackageConfigurations repositoryConfigurations = new PackageConfigurations();
repositoryConfigurations.add(new PackageConfiguration("k1", "v1").with(PackageConfiguration.PART_OF_IDENTITY, true));
RepositoryMetadataStore.getInstance().addMetadataFor(pluginId, repositoryConfigurations);
PackageConfigurations packageConfigurations = new PackageConfigurations();
packageConfigurations.add(new PackageConfiguration("k2", "v2").with(PackageConfiguration.PART_OF_IDENTITY, true));
PackageMetadataStore.getInstance().addMetadataFor(pluginId, packageConfigurations);
PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", pluginId, "version", new Configuration(create("k1", false, "v1")));
PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("k2", false, "v2")), repository);
String fingerprint = packageDefinition.getFingerprint(AbstractMaterial.FINGERPRINT_DELIMITER);
assertThat(fingerprint, is(CachedDigestUtils.sha256Hex("plugin-id=pluginid<|>k2=v2<|>k1=v1")));
}
Aggregations