Search in sources :

Example 1 with RepositoryMetadataStore

use of com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore in project gocd by gocd.

the class PackageRepositoryPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() 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);
    Collection<PackageRepositoryPluginInfo> pluginInfos = builder.allPluginInfos();
    PackageRepositoryPluginInfo expectedPluginInfo = new PackageRepositoryPluginInfo(plugin, new PluggableInstanceSettings(configurations(packageConfigurations)), new PluggableInstanceSettings(configurations(repoConfigurations)));
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
Also used : RepositoryMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PackageMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore) PackageRepositoryPluginInfo(com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 2 with RepositoryMetadataStore

use of com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore in project gocd by gocd.

the class PackageRepositoryPluginInfoBuilderTest method pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound.

@Test
public void pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound() throws Exception {
    PluginManager pluginManager = mock(PluginManager.class);
    PackageMetadataStore packageMetadataStore = mock(PackageMetadataStore.class);
    RepositoryMetadataStore repositoryMetadataStore = mock(RepositoryMetadataStore.class);
    PackageRepositoryPluginInfoBuilder builder = new PackageRepositoryPluginInfoBuilder(pluginManager, packageMetadataStore, repositoryMetadataStore);
    PackageRepositoryPluginInfo pluginInfo = builder.pluginInfoFor("docker-plugin");
    assertEquals(null, pluginInfo);
}
Also used : PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PackageMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore) PackageRepositoryPluginInfo(com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo) RepositoryMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore) Test(org.junit.Test)

Example 3 with RepositoryMetadataStore

use of com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore in project gocd by gocd.

the class PackageRepository method getSecureKeyInfoProvider.

private SecureKeyInfoProvider getSecureKeyInfoProvider() {
    final RepositoryMetadataStore repositoryMetadataStore = RepositoryMetadataStore.getInstance();
    final PackageConfigurations metadata = repositoryMetadataStore.getMetadata(pluginConfiguration.getId());
    if (metadata == null) {
        return null;
    }
    return new SecureKeyInfoProvider() {

        @Override
        public boolean isSecure(String key) {
            PackageConfiguration packageConfiguration = metadata.get(key);
            return packageConfiguration.getOption(PackageConfiguration.SECURE);
        }
    };
}
Also used : SecureKeyInfoProvider(com.thoughtworks.go.domain.config.SecureKeyInfoProvider) RepositoryMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)

Example 4 with RepositoryMetadataStore

use of com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore in project gocd by gocd.

the class PackageRepository method applyPackagePluginMetadata.

@PostConstruct
public void applyPackagePluginMetadata() {
    String pluginId = pluginConfiguration.getId();
    for (ConfigurationProperty configurationProperty : configuration) {
        RepositoryMetadataStore repositoryMetadataStore = RepositoryMetadataStore.getInstance();
        if (repositoryMetadataStore.getMetadata(pluginId) != null) {
            boolean isSecureProperty = repositoryMetadataStore.hasOption(pluginId, configurationProperty.getConfigurationKey().getName(), PackageConfiguration.SECURE);
            configurationProperty.handleSecureValueConfiguration(isSecureProperty);
        }
    }
    for (PackageDefinition packageDefinition : packages) {
        packageDefinition.applyPackagePluginMetadata(pluginId);
    }
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) RepositoryMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore) PostConstruct(javax.annotation.PostConstruct)

Example 5 with RepositoryMetadataStore

use of com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore 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);
}
Also used : RepositoryMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PackageMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore) PackageRepositoryPluginInfo(com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Aggregations

RepositoryMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore)5 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)3 PackageMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore)3 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)3 PackageRepositoryPluginInfo (com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo)3 Test (org.junit.Test)3 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)1 SecureKeyInfoProvider (com.thoughtworks.go.domain.config.SecureKeyInfoProvider)1 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)1 PostConstruct (javax.annotation.PostConstruct)1