use of com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo 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);
}
use of com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo in project gocd by gocd.
the class AuthorizationPluginInfoBuilderTest method pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound.
@Test
public void pluginInfoFor_ShouldReturnNullWhenPluginIsNotFound() throws Exception {
AuthorizationPluginConfigMetadataStore store = mock(AuthorizationPluginConfigMetadataStore.class);
when(store.find("docker-plugin")).thenReturn(null);
AuthorizationPluginInfoBuilder builder = new AuthorizationPluginInfoBuilder(store);
AuthorizationPluginInfo pluginInfo = builder.pluginInfoFor("docker-plugin");
assertEquals(null, pluginInfo);
}
use of com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo 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);
}
use of com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo 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