Search in sources :

Example 1 with Capabilities

use of com.thoughtworks.go.plugin.domain.authorization.Capabilities in project gocd by gocd.

the class AuthorizationPluginInfoBuilderTest method shouldBuildPluginInfoWithCapablities.

@Test
public void shouldBuildPluginInfoWithCapablities() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    Capabilities capabilities = new Capabilities(SupportedAuthType.Password, true, true, false);
    when(extension.getCapabilities(descriptor.id())).thenReturn(capabilities);
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertThat(pluginInfo.getCapabilities(), is(capabilities));
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.jupiter.api.Test)

Example 2 with Capabilities

use of com.thoughtworks.go.plugin.domain.authorization.Capabilities in project gocd by gocd.

the class AuthorizationPluginInfoBuilderTest method shouldNotHaveRoleSettingsInPluginInfoIfPluginCannotAuthorize.

@Test
public void shouldNotHaveRoleSettingsInPluginInfoIfPluginCannotAuthorize() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    Capabilities capabilities = new Capabilities(SupportedAuthType.Password, true, false, false);
    when(extension.getCapabilities(descriptor.id())).thenReturn(capabilities);
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertNull(pluginInfo.getRoleSettings());
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with Capabilities

use of com.thoughtworks.go.plugin.domain.authorization.Capabilities in project gocd by gocd.

the class PluginInfoMother method createAuthorizationPluginInfoWithoutAbout.

public static AuthorizationPluginInfo createAuthorizationPluginInfoWithoutAbout() {
    Capabilities capabilities = new Capabilities(SupportedAuthType.Password, true, true, true);
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin_id").version("1").pluginJarFileLocation("/home/pluginjar/").isBundledPlugin(true).build();
    return new AuthorizationPluginInfo(descriptor, getPluggableSettings(), null, new Image("content_type", "data", "hash"), capabilities);
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)

Example 4 with Capabilities

use of com.thoughtworks.go.plugin.domain.authorization.Capabilities 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;
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)

Example 5 with Capabilities

use of com.thoughtworks.go.plugin.domain.authorization.Capabilities in project gocd by gocd.

the class SecurityAuthConfigServiceTest method pluginInfo.

private AuthorizationPluginInfo pluginInfo(String githubPluginId, String name, SupportedAuthType supportedAuthType) {
    GoPluginDescriptor.About about = GoPluginDescriptor.About.builder().name(name).build();
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id(githubPluginId).about(about).build();
    return new AuthorizationPluginInfo(descriptor, null, null, new Image("svg", "data", "hash"), new Capabilities(supportedAuthType, true, true, false));
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Image(com.thoughtworks.go.plugin.domain.common.Image)

Aggregations

Capabilities (com.thoughtworks.go.plugin.domain.authorization.Capabilities)11 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)10 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)6 Image (com.thoughtworks.go.plugin.domain.common.Image)3 Test (org.junit.jupiter.api.Test)3 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)2 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1