use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class AuthorizationPluginInfoBuilderTest method shouldBuildPluginInfoWithRoleSettings.
@Test
public void shouldBuildPluginInfoWithRoleSettings() throws Exception {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("group", new Metadata(true, false)), new PluginConfiguration("something_secure", new Metadata(true, true)));
when(extension.getRoleConfigurationMetadata(descriptor.id())).thenReturn(pluginConfigurations);
when(extension.getRoleConfigurationView(descriptor.id())).thenReturn("role_config");
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
assertThat(pluginInfo.getRoleSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("role_config"))));
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class AuthorizationPluginInfoBuilderTest method shouldBuildPluginInfoWithAuthSettings.
@Test
public void shouldBuildPluginInfoWithAuthSettings() throws Exception {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
when(extension.getAuthConfigMetadata(descriptor.id())).thenReturn(pluginConfigurations);
when(extension.getAuthConfigView(descriptor.id())).thenReturn("auth_config");
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
assertThat(pluginInfo.getAuthConfigSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("auth_config"))));
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class PluginSettingsMetadataLoaderTest method shouldNotFailWhenAPluginWithMultipleExtensionsHasMoreThanOneExtensionRespondingWithSettings_BUT_OnlyOneIsValid.
@Test
public void shouldNotFailWhenAPluginWithMultipleExtensionsHasMoreThanOneExtensionRespondingWithSettings_BUT_OnlyOneIsValid() throws Exception {
PluginSettingsConfiguration configuration = new PluginSettingsConfiguration();
configuration.add(new PluginSettingsProperty("k1").with(Property.REQUIRED, true).with(Property.SECURE, false));
String pluginID = "plugin-id";
GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(pluginID, "1.0", null, null, null, true);
setupSettingsResponses(notificationExtension, pluginID, configuration, null);
setupSettingsResponses(packageRepositoryExtension, pluginID, configuration, "view");
metadataLoader.fetchPluginSettingsMetaData(pluginDescriptor);
assertThat(PluginSettingsMetadataStore.getInstance().hasPlugin(pluginID), is(true));
assertThat(PluginSettingsMetadataStore.getInstance().configuration(pluginID), is(configuration));
assertThat(PluginSettingsMetadataStore.getInstance().template(pluginID), is("view"));
assertThat(PluginSettingsMetadataStore.getInstance().extensionWhichCanHandleSettings(pluginID), is(PluginConstants.PACKAGE_MATERIAL_EXTENSION));
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class PluginSettingsMetadataLoaderTest method shouldNotFailWhenAPluginWithMultipleExtensionsHasMoreThanOneExtensionRespondingWithSettings_BUT_OneIsValidAndOtherThrowsException.
@Test
public void shouldNotFailWhenAPluginWithMultipleExtensionsHasMoreThanOneExtensionRespondingWithSettings_BUT_OneIsValidAndOtherThrowsException() throws Exception {
PluginSettingsConfiguration configuration = new PluginSettingsConfiguration();
configuration.add(new PluginSettingsProperty("k1").with(Property.REQUIRED, true).with(Property.SECURE, false));
String pluginID = "plugin-id";
GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(pluginID, "1.0", null, null, null, true);
setupSettingsResponses(notificationExtension, pluginID, configuration, "view");
when(packageRepositoryExtension.canHandlePlugin(pluginID)).thenReturn(false);
when(scmExtension.canHandlePlugin(pluginID)).thenReturn(true);
when(scmExtension.getPluginSettingsConfiguration(pluginID)).thenThrow(new RuntimeException("Ouch!"));
when(scmExtension.getPluginSettingsView(pluginID)).thenReturn("view");
metadataLoader.fetchPluginSettingsMetaData(pluginDescriptor);
assertThat(PluginSettingsMetadataStore.getInstance().hasPlugin(pluginID), is(true));
verify(packageRepositoryExtension, never()).getPluginSettingsConfiguration(pluginID);
verify(packageRepositoryExtension, never()).getPluginSettingsView(pluginID);
}
use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.
the class PluginSettingsMetadataLoaderTest method shouldFailWhenAPluginWithMultipleExtensionsHasMoreThanOneExtensionRespondingWithSettings.
@Test
public void shouldFailWhenAPluginWithMultipleExtensionsHasMoreThanOneExtensionRespondingWithSettings() throws Exception {
PluginSettingsConfiguration configuration = new PluginSettingsConfiguration();
configuration.add(new PluginSettingsProperty("k1").with(Property.REQUIRED, true).with(Property.SECURE, false));
String pluginID = "plugin-id";
GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(pluginID, "1.0", null, null, null, true);
setupSettingsResponses(notificationExtension, pluginID, configuration, "view");
setupSettingsResponses(packageRepositoryExtension, pluginID, configuration, "view");
try {
metadataLoader.fetchPluginSettingsMetaData(pluginDescriptor);
fail("Should have failed since multiple extensions support plugin settings.");
} catch (Exception e) {
assertThat(e.getMessage(), containsString("Plugin with ID: plugin-id has more than one extension which supports plugin settings"));
assertThat(PluginSettingsMetadataStore.getInstance().hasPlugin(pluginDescriptor.id()), is(false));
}
}
Aggregations