use of com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys in project gocd by gocd.
the class AuthorizationPluginConfigMetadataStore method add.
@Override
public void add(PluginDescriptor plugin, AuthorizationPluginRegistry extension) {
try {
Image icon = extension.getIcon(plugin.id());
Capabilities capabilities = extension.getCapabilities(plugin.id());
PluginProfileMetadataKeys authConfigMetadata = extension.getPluginConfigurationMetadata(plugin.id());
String authConfigView = extension.getPluginConfigurationView(plugin.id());
cacheRoleMetadataAndView(plugin, extension);
this.icons.put(plugin, icon);
this.authConfigMetadata.put(plugin, authConfigMetadata);
this.authConfigView.put(plugin, authConfigView);
this.capabilities.put(plugin, capabilities);
} catch (Exception e) {
LOGGER.error("Failed to load plugin {}", plugin.id(), e);
throw e;
}
}
use of com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys 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.plugin.access.common.models.PluginProfileMetadataKeys 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);
}
use of com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys in project gocd by gocd.
the class ElasticPluginConfigMetadataStore method add.
@Override
public void add(PluginDescriptor plugin, ElasticAgentPluginRegistry extension) {
try {
Image icon = extension.getIcon(plugin.id());
PluginProfileMetadataKeys profileMetadata = extension.getProfileMetadata(plugin.id());
String profileView = extension.getProfileView(plugin.id());
this.icons.put(plugin, icon);
this.profileMetadata.put(plugin, profileMetadata);
this.profileView.put(plugin, profileView);
} catch (Exception e) {
LOGGER.error("Failed to load plugin {}", plugin.id(), e);
throw e;
}
}
use of com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys in project gocd by gocd.
the class AuthorizationPluginConfigMetadataStore method cacheRoleMetadataAndView.
private void cacheRoleMetadataAndView(PluginDescriptor plugin, AuthorizationPluginRegistry extension) {
try {
PluginProfileMetadataKeys roleMetadata = extension.getRoleConfigurationMetadata(plugin.id());
this.roleMetadata.put(plugin, roleMetadata);
} catch (Exception e) {
LOGGER.error("Failed to load role metadata for plugin {}", plugin.id(), e);
}
try {
String roleConfigurationView = extension.getRoleConfigurationView(plugin.id());
this.roleViews.put(plugin, roleConfigurationView);
} catch (Exception e) {
LOGGER.error("Failed to load role view for plugin {}", plugin.id(), e);
}
}
Aggregations