use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings in project gocd by gocd.
the class AuthorizationPluginInfoBuilderTest 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);
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.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);
AuthorizationPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
PluggableInstanceSettings authConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(securityAuthConfigMetadata), new PluginView(securityAuthConfigView));
PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(roleConfigMetadata), new PluginView(roleConfigView));
assertEquals(new AuthorizationPluginInfo(plugin, authConfigSettings, roleConfigSettings, image), pluginInfo);
}
use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings in project gocd by gocd.
the class ElasticAgentPluginInfoBuilderTest method pluginInfoFor_ShouldProvideEPluginInfoForAPlugin.
@Test
public void pluginInfoFor_ShouldProvideEPluginInfoForAPlugin() 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.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);
ElasticPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
PluggableInstanceSettings settings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(metadataKeys), new PluginView(view));
assertEquals(new ElasticPluginInfo(plugin, settings, image), pluginInfo);
}
use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings 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);
}
Aggregations