Search in sources :

Example 6 with PluggableInstanceSettings

use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings 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 7 with PluggableInstanceSettings

use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings in project gocd by gocd.

the class AuthorizationPluginInfoBuilderTest 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);
    PluginProfileMetadataKeys securityAuthConfigMetadata = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("password", new PluginProfileMetadata(true, true))));
    PluginProfileMetadataKeys roleConfigMetadata = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("memberOf", new PluginProfileMetadata(true, false))));
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    String securityAuthConfigView = "some html view";
    String roleConfigView = "another html view";
    AuthorizationPluginConfigMetadataStore store = mock(AuthorizationPluginConfigMetadataStore.class);
    when(store.getPlugins()).thenReturn(Arrays.asList(plugin));
    when(store.find("docker-plugin")).thenReturn(plugin);
    when(store.getProfileMetadata(plugin)).thenReturn(securityAuthConfigMetadata);
    when(store.getRoleMetadata(plugin)).thenReturn(roleConfigMetadata);
    when(store.getIcon(plugin)).thenReturn(image);
    when(store.getProfileView(plugin)).thenReturn(securityAuthConfigView);
    when(store.getRoleView(plugin)).thenReturn(roleConfigView);
    AuthorizationPluginInfoBuilder builder = new AuthorizationPluginInfoBuilder(store);
    Collection<AuthorizationPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableInstanceSettings authConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(securityAuthConfigMetadata), new PluginView(securityAuthConfigView));
    PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(roleConfigMetadata), new PluginView(roleConfigView));
    assertEquals(Arrays.asList(new AuthorizationPluginInfo(plugin, authConfigSettings, roleConfigSettings, image)), pluginInfos);
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) AuthorizationPluginInfo(com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image) AuthorizationPluginConfigMetadataStore(com.thoughtworks.go.plugin.access.authorization.AuthorizationPluginConfigMetadataStore) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Example 8 with PluggableInstanceSettings

use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings in project gocd by gocd.

the class ElasticAgentPluginInfoBuilderTest 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);
    PluginProfileMetadataKeys metadataKeys = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("password", new PluginProfileMetadata(true, true))));
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    ;
    String view = "some html view";
    ElasticPluginConfigMetadataStore store = mock(ElasticPluginConfigMetadataStore.class);
    when(store.getPlugins()).thenReturn(Arrays.asList(plugin));
    when(store.find("docker-plugin")).thenReturn(plugin);
    when(store.getProfileMetadata(plugin)).thenReturn(metadataKeys);
    when(store.getIcon(plugin)).thenReturn(image);
    when(store.getProfileView(plugin)).thenReturn(view);
    ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(store);
    Collection<ElasticPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableInstanceSettings settings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(metadataKeys), new PluginView(view));
    assertEquals(Arrays.asList(new ElasticPluginInfo(plugin, settings, image)), pluginInfos);
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) ElasticPluginInfo(com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image) ElasticPluginConfigMetadataStore(com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Example 9 with PluggableInstanceSettings

use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings in project gocd by gocd.

the class AuthorizationPluginInfoBuilder method pluginInfoFor.

@Override
public AuthorizationPluginInfo pluginInfoFor(String pluginId) {
    PluginDescriptor descriptor = store.find(pluginId);
    if (descriptor == null) {
        return null;
    }
    Image icon = store.getIcon(descriptor);
    ArrayList<PluginConfiguration> pluginConfigurations = PluginConfiguration.getPluginConfigurations(store.getProfileMetadata(descriptor));
    PluginView profileView = new PluginView(store.getProfileView(descriptor));
    PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(pluginConfigurations, profileView);
    ArrayList<PluginConfiguration> roleConfigurations = PluginConfiguration.getPluginConfigurations(store.getRoleMetadata(descriptor));
    PluginView roleView = new PluginView(store.getRoleView(descriptor));
    PluggableInstanceSettings roleSettings = new PluggableInstanceSettings(roleConfigurations, roleView);
    return new AuthorizationPluginInfo(descriptor, profileSettings, roleSettings, icon);
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) AuthorizationPluginInfo(com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) Image(com.thoughtworks.go.plugin.access.common.models.Image)

Example 10 with PluggableInstanceSettings

use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings in project gocd by gocd.

the class AuthorizationViewModelBuilder method pluginInfoFor.

@Override
public PluginInfo pluginInfoFor(String pluginId) {
    PluginDescriptor descriptor = metadataStore.find(pluginId);
    if (descriptor == null) {
        return null;
    }
    Image icon = metadataStore.getIcon(descriptor);
    ArrayList<PluginConfiguration> pluginConfigurations = PluginConfiguration.getPluginConfigurations(metadataStore.getProfileMetadata(descriptor));
    PluginView profileView = new PluginView(metadataStore.getProfileView(descriptor));
    PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(pluginConfigurations, profileView);
    ArrayList<PluginConfiguration> roleConfigurations = PluginConfiguration.getPluginConfigurations(metadataStore.getRoleMetadata(descriptor));
    PluginView roleView = new PluginView(metadataStore.getRoleView(descriptor));
    PluggableInstanceSettings roleSettings = new PluggableInstanceSettings(roleConfigurations, roleView);
    return new PluginInfo(descriptor, AuthorizationPluginConstants.EXTENSION_NAME, null, profileSettings, roleSettings, icon);
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image)

Aggregations

PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)18 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)15 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)14 Test (org.junit.Test)10 Image (com.thoughtworks.go.plugin.access.common.models.Image)8 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)8 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)6 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)5 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)4 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)4 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)4 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)4 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)4 AuthorizationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo)3 ElasticPluginInfo (com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo)3 PluggableTaskPluginInfo (com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo)3 AuthorizationPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.authorization.AuthorizationPluginConfigMetadataStore)2 ElasticPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore)2 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)2 PackageMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore)2