use of com.thoughtworks.go.server.ui.plugins.PluginView in project gocd by gocd.
the class SCMViewModelBuilder method pluginInfoFor.
public PluginInfo pluginInfoFor(String pluginId) {
if (!SCMMetadataStore.getInstance().hasPreferenceFor(pluginId)) {
return null;
}
GoPluginDescriptor descriptor = pluginManager.getPluginDescriptorFor(pluginId);
SCMPreference scmPreference = SCMMetadataStore.getInstance().preferenceFor(pluginId);
List<PluginConfiguration> pluginConfigurations = configurations(scmPreference.getScmConfigurations());
PluginView pluginView = new PluginView(scmPreference.getScmView().template());
return new PluginInfo(descriptor, SCMExtension.EXTENSION_NAME, scmPreference.getScmView().displayValue(), new PluggableInstanceSettings(pluginConfigurations, pluginView));
}
use of com.thoughtworks.go.server.ui.plugins.PluginView in project gocd by gocd.
the class PluggableTaskPluginInfoBuilderTest 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);
PluggableTaskConfigStore packageMetadataStore = mock(PluggableTaskConfigStore.class);
when(packageMetadataStore.pluginIds()).thenReturn(Collections.singleton(plugin.id()));
when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
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";
}
};
TaskConfig taskConfig = new TaskConfig();
taskConfig.add(new TaskConfigProperty("key1", null));
taskConfig.add(new TaskConfigProperty("key2", null));
when(jsonBasedPluggableTask.config()).thenReturn(taskConfig);
when(jsonBasedPluggableTask.view()).thenReturn(taskView);
TaskPreference taskPreference = new TaskPreference(jsonBasedPluggableTask);
when(packageMetadataStore.preferenceFor(plugin.id())).thenReturn(taskPreference);
PluggableTaskPluginInfoBuilder builder = new PluggableTaskPluginInfoBuilder(pluginManager, packageMetadataStore);
PluggableTaskPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
PluggableTaskPluginInfo expectedPluginInfo = new PluggableTaskPluginInfo(plugin, taskView.displayValue(), new PluggableInstanceSettings(configurations(taskConfig), new PluginView(taskView.template())));
assertEquals(expectedPluginInfo, pluginInfo);
}
use of com.thoughtworks.go.server.ui.plugins.PluginView in project gocd by gocd.
the class PluggableTaskViewModelBuilderTest method shouldBeAbleToFetchAPluginInfoForAGivenIdWithView.
@Test
public void shouldBeAbleToFetchAPluginInfoForAGivenIdWithView() {
when(manager.getPluginDescriptorFor("xunit.convertor")).thenReturn(xunitConvertor);
PluginInfo pluginInfo = builder.pluginInfoFor("xunit.convertor");
PluginView view = pluginInfo.getPluggableInstanceSettings().getView();
assertThat(view.getTemplate(), is("pluggable task view template"));
}
use of com.thoughtworks.go.server.ui.plugins.PluginView in project gocd by gocd.
the class SCMPluginInfoBuilderTest 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);
SCMMetadataStore scmMetadataStore = mock(SCMMetadataStore.class);
when(scmMetadataStore.getPlugins()).thenReturn(Collections.singletonList(plugin.id()));
when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
SCMConfigurations configurations = new SCMConfigurations();
configurations.add(new SCMConfiguration("key1"));
configurations.add(new SCMConfiguration("key2"));
SCMView view = new SCMView() {
@Override
public String displayValue() {
return "SCM Display Value";
}
@Override
public String template() {
return "scm view template";
}
};
SCMPreference scmPreference = new SCMPreference(configurations, view);
when(scmMetadataStore.preferenceFor(plugin.id())).thenReturn(scmPreference);
SCMPluginInfoBuilder builder = new SCMPluginInfoBuilder(pluginManager, scmMetadataStore);
SCMPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
SCMPluginInfo expectedPluginInfo = new SCMPluginInfo(plugin, view.displayValue(), new PluggableInstanceSettings(configurations(configurations), new PluginView(view.template())));
assertEquals(expectedPluginInfo, pluginInfo);
}
use of com.thoughtworks.go.server.ui.plugins.PluginView 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);
}
Aggregations