ServerInfoIT: Use API to install plugin
Use the API to install the plugin instead of manually writing the plugin file into the $site/plugins folder and then reloading via an ssh call. Change-Id: I9c4a0b3ae611149a83595751d392c64b7024ecb4
This commit is contained in:
		@@ -20,22 +20,20 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 | 
			
		||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
 | 
			
		||||
import com.google.gerrit.acceptance.GerritConfig;
 | 
			
		||||
import com.google.gerrit.acceptance.NoHttpd;
 | 
			
		||||
import com.google.gerrit.acceptance.UseSsh;
 | 
			
		||||
import com.google.gerrit.common.RawInputUtil;
 | 
			
		||||
import com.google.gerrit.extensions.client.AccountFieldName;
 | 
			
		||||
import com.google.gerrit.extensions.client.AuthType;
 | 
			
		||||
import com.google.gerrit.extensions.common.InstallPluginInput;
 | 
			
		||||
import com.google.gerrit.extensions.common.ServerInfo;
 | 
			
		||||
import com.google.gerrit.server.config.AllProjectsNameProvider;
 | 
			
		||||
import com.google.gerrit.server.config.AllUsersNameProvider;
 | 
			
		||||
import com.google.gerrit.server.config.AnonymousCowardNameProvider;
 | 
			
		||||
import com.google.gerrit.server.config.SitePaths;
 | 
			
		||||
import com.google.inject.Inject;
 | 
			
		||||
import java.nio.file.Files;
 | 
			
		||||
import java.nio.file.Path;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
@NoHttpd
 | 
			
		||||
public class ServerInfoIT extends AbstractDaemonTest {
 | 
			
		||||
  @Inject private SitePaths sitePaths;
 | 
			
		||||
  private static final byte[] JS_PLUGIN_CONTENT =
 | 
			
		||||
      "Gerrit.install(function(self){});\n".getBytes(UTF_8);
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  // auth
 | 
			
		||||
@@ -132,17 +130,16 @@ public class ServerInfoIT extends AbstractDaemonTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  @UseSsh
 | 
			
		||||
  @GerritConfig(name = "plugins.allowRemoteAdmin", value = "true")
 | 
			
		||||
  public void serverConfigWithPlugin() throws Exception {
 | 
			
		||||
    Path plugins = sitePaths.plugins_dir;
 | 
			
		||||
    Path jsplugin = plugins.resolve("js-plugin-1.js");
 | 
			
		||||
    Files.write(jsplugin, "Gerrit.install(function(self){});\n".getBytes(UTF_8));
 | 
			
		||||
    adminSshSession.exec("gerrit plugin reload");
 | 
			
		||||
 | 
			
		||||
    ServerInfo i = gApi.config().server().getInfo();
 | 
			
		||||
    assertThat(i.plugin.jsResourcePaths).isEmpty();
 | 
			
		||||
 | 
			
		||||
    // plugin
 | 
			
		||||
    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);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user