use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class CombinedPluginInfoTest method shouldFindFirstExtensionWithImageIfPluginImplementsAtleastOneExtensionWithImage.
@Test
public void shouldFindFirstExtensionWithImageIfPluginImplementsAtleastOneExtensionWithImage() throws Exception {
Image image1 = new Image("c1", "d1", "hash1");
Image image2 = new Image("c2", "d2", "hash2");
Image image3 = new Image("c3", "d3", "hash3");
ElasticAgentPluginInfo elasticAgentPluginInfo = new ElasticAgentPluginInfo(null, null, image1, null, null);
AuthorizationPluginInfo authorizationPluginInfo = new AuthorizationPluginInfo(null, null, null, image2, null);
AnalyticsPluginInfo analyticsPluginInfo = new AnalyticsPluginInfo(null, image3, null, null);
assertThat(new CombinedPluginInfo(elasticAgentPluginInfo).getImage(), is(image1));
assertThat(new CombinedPluginInfo(authorizationPluginInfo).getImage(), is(image2));
assertThat(new CombinedPluginInfo(analyticsPluginInfo).getImage(), is(image3));
assertThat(new CombinedPluginInfo(asList(elasticAgentPluginInfo, authorizationPluginInfo)).getImage(), anyOf(is(image1), is(image2)));
assertThat(new CombinedPluginInfo(asList(analyticsPluginInfo, authorizationPluginInfo)).getImage(), anyOf(is(image2), is(image3)));
}
use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class ConfigInfoProviderTest method pluginInfo.
private AuthorizationPluginInfo pluginInfo(String pluginId, String pluginName) {
final AuthorizationPluginInfo pluginInfo = mock(AuthorizationPluginInfo.class);
final PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
final PluginDescriptor.About about = mock(PluginDescriptor.About.class);
when(pluginDescriptor.id()).thenReturn(pluginId);
when(pluginDescriptor.about()).thenReturn(about);
when(about.name()).thenReturn(pluginName);
when(pluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
Capabilities capabilities = mock(Capabilities.class);
when(capabilities.getSupportedAuthType()).thenReturn(SupportedAuthType.Password);
when(pluginInfo.getCapabilities()).thenReturn(capabilities);
return pluginInfo;
}
use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class AuthorizationMetadataLoaderTest method onPluginLoaded_shouldAddPluginInfoToMetadataStore.
@Test
public void onPluginLoaded_shouldAddPluginInfoToMetadataStore() throws Exception {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
AuthorizationMetadataLoader metadataLoader = new AuthorizationMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(descriptor, null, null, null, null);
when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo);
metadataLoader.pluginLoaded(descriptor);
verify(metadataStore).setPluginInfo(pluginInfo);
}
use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class AuthorizationPluginInfoBuilderTest method shouldBuildPluginInfoWithImage.
@Test
public void shouldBuildPluginInfoWithImage() throws Exception {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
Image icon = new Image("content_type", "data", "hash");
when(extension.getIcon(descriptor.id())).thenReturn(icon);
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
assertThat(pluginInfo.getImage(), is(icon));
}
use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class AuthorizationPluginInfoBuilderTest method shouldNotHaveRoleSettingsInPluginInfoIfPluginCannotAuthorize.
@Test
public void shouldNotHaveRoleSettingsInPluginInfoIfPluginCannotAuthorize() throws Exception {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
Capabilities capabilities = new Capabilities(SupportedAuthType.Password, true, false);
when(extension.getCapabilities(descriptor.id())).thenReturn(capabilities);
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
assertNull(pluginInfo.getRoleSettings());
}
Aggregations