use of com.google.gerrit.extensions.api.plugins.InstallPluginInput in project gerrit by GerritCodeReview.
the class PluginsImpl method convertInput.
@SuppressWarnings("deprecation")
private InstallPluginInput convertInput(com.google.gerrit.extensions.common.InstallPluginInput input) {
InstallPluginInput result = new InstallPluginInput();
result.url = input.url;
result.raw = input.raw;
return result;
}
use of com.google.gerrit.extensions.api.plugins.InstallPluginInput in project gerrit by GerritCodeReview.
the class PluginIT method pluginManagement.
@Test
@GerritConfig(name = "plugins.allowRemoteAdmin", value = "true")
public void pluginManagement() throws Exception {
// No plugins are loaded
assertThat(list().get()).isEmpty();
assertThat(list().all().get()).isEmpty();
PluginApi api;
// Install all the plugins
InstallPluginInput input = new InstallPluginInput();
for (String plugin : PLUGINS) {
input.raw = pluginContent(plugin);
api = gApi.plugins().install(plugin, input);
assertThat(api).isNotNull();
PluginInfo info = api.get();
String name = pluginName(plugin);
assertThat(info.id).isEqualTo(name);
assertThat(info.version).isEqualTo(pluginVersion(plugin));
assertThat(info.apiVersion).isEqualTo(pluginApiVersion(plugin));
assertThat(info.indexUrl).isEqualTo(String.format("plugins/%s/", name));
assertThat(info.filename).isEqualTo(plugin);
assertThat(info.disabled).isNull();
}
assertPlugins(list().get(), PLUGINS);
// With pagination
assertPlugins(list().start(1).limit(2).get(), PLUGINS.subList(1, 3));
// With prefix
assertPlugins(list().prefix("plugin-b").get(), ImmutableList.of("plugin-b.js"));
assertPlugins(list().prefix("PLUGIN-").get(), ImmutableList.of());
// With substring
assertPlugins(list().substring("lugin-").get(), PLUGINS.subList(0, PLUGINS.size() - 1));
assertPlugins(list().substring("lugin-").start(1).limit(2).get(), PLUGINS.subList(1, 3));
// With regex
assertPlugins(list().regex(".*in-b").get(), ImmutableList.of("plugin-b.js"));
assertPlugins(list().regex("plugin-.*").get(), PLUGINS.subList(0, PLUGINS.size() - 1));
assertPlugins(list().regex("plugin-.*").start(1).limit(2).get(), PLUGINS.subList(1, 3));
// Invalid match combinations
assertBadRequest(list().regex(".*in-b").substring("a"));
assertBadRequest(list().regex(".*in-b").prefix("a"));
assertBadRequest(list().substring(".*in-b").prefix("a"));
// Disable mandatory
mandatoryPluginsCollection.add("plugin_e");
assertThrows(MethodNotAllowedException.class, () -> gApi.plugins().name("plugin_e").disable());
api = gApi.plugins().name("plugin_e");
assertThat(api.get().disabled).isNull();
// Disable non-mandatory
api = gApi.plugins().name("plugin-a");
api.disable();
api = gApi.plugins().name("plugin-a");
assertThat(api.get().disabled).isTrue();
assertPlugins(list().get(), PLUGINS.subList(1, PLUGINS.size()));
assertPlugins(list().all().get(), PLUGINS);
// Enable
api.enable();
api = gApi.plugins().name("plugin-a");
assertThat(api.get().disabled).isNull();
assertPlugins(list().get(), PLUGINS);
// Using deprecated input
deprecatedInput();
// Non-admin cannot disable
requestScopeOperations.setApiUser(user.id());
assertThrows(AuthException.class, () -> gApi.plugins().name("plugin-a").disable());
}
use of com.google.gerrit.extensions.api.plugins.InstallPluginInput in project gerrit by GerritCodeReview.
the class PluginIT method installNotAllowed.
@Test
public void installNotAllowed() throws Exception {
MethodNotAllowedException thrown = assertThrows(MethodNotAllowedException.class, () -> gApi.plugins().install("test.js", new InstallPluginInput()));
assertThat(thrown).hasMessageThat().contains("remote plugin administration is disabled");
}
use of com.google.gerrit.extensions.api.plugins.InstallPluginInput in project gerrit by GerritCodeReview.
the class ServerInfoIT method serverConfigWithPlugin.
@Test
@GerritConfig(name = "plugins.allowRemoteAdmin", value = "true")
public void serverConfigWithPlugin() throws Exception {
ServerInfo i = gApi.config().server().getInfo();
assertThat(i.plugin.jsResourcePaths).isEmpty();
InstallPluginInput input = new InstallPluginInput();
input.raw = RawInputUtil.create(JS_PLUGIN_CONTENT);
gApi.plugins().install("js-plugin-1.js", input);
i = gApi.config().server().getInfo();
assertThat(i.plugin.jsResourcePaths).hasSize(1);
}
use of com.google.gerrit.extensions.api.plugins.InstallPluginInput in project gerrit by GerritCodeReview.
the class PluginsRemoteAdminRestApiBindingsIT method installPlugin.
private void installPlugin(String pluginName) throws Exception {
InstallPluginInput input = new InstallPluginInput();
input.raw = JS_PLUGIN_CONTENT;
gApi.plugins().install(pluginName + ".js", input);
}
Aggregations