[java-identity-provider] 04/04: IDP-1595 Plugin Uninstall work
Rod Widdowson
rdw at steadingsoftware.com
Wed Oct 7 15:19:47 UTC 2020
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=295e92721eaab77aed24338f87a421f6cbe8ebc5
commit 295e92721eaab77aed24338f87a421f6cbe8ebc5
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Oct 7 16:12:06 2020 +0100
IDP-1595 Plugin Uninstall work
https://issues.shibboleth.net/jira/browse/IDP-1595
Uninstall from the installed list.
Turn off modules as required before uninstall.
---
.../idp/installer/plugin/impl/PluginInstaller.java | 83 +++++++++++--
.../plugin/impl/PluginInstallerArguments.java | 26 ++---
.../installer/plugin/impl/PluginInstallerCLI.java | 128 ++++++++++-----------
.../plugin/impl/PluginInstallerSupport.java | 50 +++++---
.../idp/installer/plugin/impl/PluginCLITest.java | 33 ++++--
.../installer/plugin/impl/PluginInstallerTest.java | 2 +-
6 files changed, 207 insertions(+), 115 deletions(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
index 412eaf4e4..cc6de0ffe 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
@@ -32,6 +32,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -56,6 +57,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.http.client.HttpClient;
import org.apache.tools.ant.BuildException;
+import org.opensaml.security.httpclient.HttpClientSecurityParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,6 +70,7 @@ import net.shibboleth.idp.installer.ProgressReportingOutputStream;
import net.shibboleth.idp.installer.plugin.impl.TrustStore.Signature;
import net.shibboleth.idp.module.IdPModule;
import net.shibboleth.idp.module.ModuleContext;
+import net.shibboleth.idp.module.ModuleException;
import net.shibboleth.idp.plugin.IdPPlugin;
import net.shibboleth.idp.plugin.PluginVersion;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
@@ -128,6 +131,12 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
/** The version from the contents file, or null if it isn't loaded. */
@Nullable private String installedVersionFromContents;
+ /** The Module Context. */
+ @NonnullAfterInit private ModuleContext moduleContext;
+
+ /** The securiotyParams for the module context. */
+ private HttpClientSecurityParameters securityParams;
+
/** Set IdP Home.
* @param home Where we are working from
*/
@@ -167,10 +176,18 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
/** Set the httpClient.
* @param what what to set.
*/
- public void setHttpClient(final HttpClient what) {
+ public void setHttpClient(@Nonnull final HttpClient what) {
httpClient = Constraint.isNotNull(what, "HttpClient should be non-null");
}
+ /** Set the Module Context security parameters.
+ * @param params what to set.
+ */
+ public void setModuleContextSecurityParams(@Nullable final HttpClientSecurityParameters params) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ securityParams = params;
+ }
+
/** Install the plugin from the provided URL. Involves downloading
* the file and then doing a {@link #installPlugin(Path, String)}.
* @param baseURL where we get the files from
@@ -229,13 +246,40 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
/** Remove the jars for this plugin and rebuild the war.
* @throws BuildException if badness occurs. */
- public void removeJars() throws BuildException {
- final Path myWebApp = idpHome.resolve("dist").resolve("edit-webapp-" + pluginId);
- if (!Files.exists(myWebApp)) {
- LOG.error("Plugin {} had no jars installed.", pluginId);
- return;
+ public void uninstall() throws BuildException {
+
+ String moduleId = null;
+ description = getInstalledPlugin(pluginId);
+ if (description == null) {
+ LOG.warn("Description for {} not found", pluginId);
+ } else {
+ try (final RollbackPluginInstall rollback = new RollbackPluginInstall(moduleContext)){
+ for (final IdPModule module: description.getDisableOnRemoval()) {
+ moduleId = module.getId();
+ module.disable(moduleContext, true);
+ rollback.getModulesDisabled().add(module);
+ }
+ rollback.completed();
+ } catch (final ModuleException e) {
+ LOG.error("Uninstalling {}. Could not disable {}", pluginId, moduleId, e);
+ LOG.error("Fix this and rerun");
+ throw new BuildException(e);
+ }
}
- uninstallOld(myWebApp);
+ for (final String content: getInstalledContents()) {
+ final Path p = Path.of(content);
+ if (!Files.exists(p)) {
+ continue;
+ }
+ try {
+ InstallerSupport.setReadOnly(p, false);
+ Files.deleteIfExists(p);
+ } catch (final IOException e) {
+ LOG.warn("Could not delete {}, deferring the delete", content, e);
+ p.toFile().deleteOnExit();
+ }
+ }
+
final BuildWar builder = new BuildWar(idpHome);
try {
builder.initialize();
@@ -311,7 +355,6 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
// OTOH if the update process is recoverable then a failed update
// should rollback the uninstall of the original...
- final ModuleContext moduleContext = new ModuleContext(idpHome);
final Set<String> requiredModules = new HashSet<>(description.getRequiredModules());
final Iterator<IdPModule> modules = ServiceLoader.load(IdPModule.class).iterator();
@@ -393,6 +436,7 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
final File inFile = parent.resolve(pluginId).toFile();
if (!inFile.exists()) {
LOG.error("Contents file for plugin {} ({}) does not exist", pluginId, inFile.getAbsolutePath());
+ installedContents = Collections.emptyList();
return;
}
try (final BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(inFile))) {
@@ -431,10 +475,12 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
/** Build the Http Client if it doesn't exist. */
private void buildHttpClient() {
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
if (httpClient == null) {
LOG.debug("No HttpClient built, creating default");
try {
httpClient = new HttpClientBuilder().buildClient();
+ moduleContext.setHttpClient(httpClient);
} catch (final Exception e) {
LOG.error("Could not create HttpClient", e);
throw new BuildException(e);
@@ -632,6 +678,9 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
LOG.error("Could not canonicalize idp home", e);
throw new ComponentInitializationException(e);
}
+ moduleContext = new ModuleContext(idpHome);
+ moduleContext.setHttpClientSecurityParameters(securityParams);
+ moduleContext.setHttpClient(httpClient);
}
/**
@@ -663,7 +712,22 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
throw new BuildException(e);
}
}
-
+
+ /** Find the {@link IdPPlugin} with the provided Id.
+ * @param name what to find
+ * @return the {@link IdPPlugin} or null if not found.
+ */
+ @Nullable public IdPPlugin getInstalledPlugin(@Nonnull final String name) {
+ Constraint.isNotNull(name, "Plugin Name must not be null");
+ final List<IdPPlugin> plugins = getInstalledPlugins();
+ for (final IdPPlugin plugin: plugins) {
+ if (name.equals(plugin.getPluginId())) {
+ return plugin;
+ }
+ }
+ return null;
+ }
+
/** {@inheritDoc} */
public void close() {
PluginInstallerSupport.deleteTree(downloadDirectory);
@@ -671,6 +735,7 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
for (final Path p : copiedFiles) {
try {
if (Files.exists(p)) {
+ InstallerSupport.setReadOnly(p, false);
Files.delete(p);
}
} catch (final IOException e) {
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
index 8cd1dd2bc..717c67fe5 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
@@ -80,8 +80,8 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
@Nullable private String forceUpdateVersion;
/** Id to remove. */
- @Parameter(names= {"-r", "--remove-jars"})
- @Nullable private String removeId;
+ @Parameter(names= {"-r", "--uninstall", "--remove"})
+ @Nullable private String uninstallId;
/** Contents to list. */
@Parameter(names= {"-cl", "--contents-list"})
@@ -109,8 +109,8 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
INSTALLDIR,
/** Install from the web. */
INSTALLREMOTE,
- /** Remove jars from dist - web-ing. */
- REMOVEJARS,
+ /** Uninstall plugin. */
+ UNINSTALL,
/** Print the license file to System.out. */
OUTPUTLICENSE,
/** List the contents for the plugin. */
@@ -236,22 +236,22 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
}
if (list || fullList) {
operation = OperationType.LIST;
- if (input != null || removeId != null) {
+ if (input != null || uninstallId != null) {
getLog().error("Cannot List and Install or Remove in the same operation.");
throw new IllegalArgumentException("Cannot List and Install or Remove in the same operation.");
}
- if (updatePluginId != null || removeId != null) {
+ if (updatePluginId != null || uninstallId != null) {
getLog().error("Cannot List and Update or Remove in the same operation.");
throw new IllegalArgumentException("Cannot List and Update or Remove in the same operation.");
}
} else if (input != null) {
- if (updatePluginId != null || removeId != null) {
+ if (updatePluginId != null || uninstallId != null) {
getLog().error("Cannot Install and Update or Remove in the same operation.");
throw new IllegalArgumentException("Cannot List and Update or Remove in the same operation.");
}
operation = decodeInput() ;
} else if (updatePluginId != null) {
- if (removeId != null) {
+ if (uninstallId != null) {
getLog().error("Cannot Update and Remove in the same operation.");
throw new IllegalArgumentException("Cannot Update and Remove in the same operation.");
}
@@ -260,9 +260,9 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
if (forceUpdateVersion != null) {
updateVersion = new PluginVersion(forceUpdateVersion);
}
- } else if (removeId != null) {
- pluginId = removeId;
- operation = OperationType.REMOVEJARS;
+ } else if (uninstallId != null) {
+ pluginId = uninstallId;
+ operation = OperationType.UNINSTALL;
} else if (license != null) {
pluginId = license;
operation = OperationType.OUTPUTLICENSE;
@@ -322,8 +322,8 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
out.println(String.format(" %-22s %s", "-u, --update <PluginId>", "update"));
out.println(String.format(" %-22s %s", "-fu, --force-update <version>",
"force version to update to (requires -u)"));
- out.println(String.format(" %-22s %s", "-r, --remove-jars <PluginId>",
- "remove any installed jars (and other resources) from the war file. \n" +
+ out.println(String.format(" %-22s %s", "-r, --remove, --uninstall <PluginId>",
+ "Uninstall plugin from the war file. \n" +
"\t\t\tDOES NOT UNDO any other installation"));
out.println(String.format(" %-22s %s", "--license <pluginid>",
"Output all licenses for this plugin"));
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
index 0c5f9bbf3..4e6d908fb 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
@@ -138,9 +138,9 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
doUpdate(args.getPluginId() , args.getUpdateVersion());
break;
- case REMOVEJARS:
+ case UNINSTALL:
installer.setPluginId(args.getPluginId());
- installer.removeJars();
+ installer.uninstall();
break;
case OUTPUTLICENSE:
@@ -184,6 +184,7 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
if (getHttpClient()!= null) {
inst.setHttpClient(getHttpClient());
}
+ inst.setModuleContextSecurityParams(getHttpClientSecurityParameters());
inst.initialize();
installer = inst;
}
@@ -237,33 +238,31 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
* @param pluginId what to list
*/
private void outputLicense(@Nonnull final String pluginId) {
- final List<IdPPlugin> plugins = installer.getInstalledPlugins();
- for (final IdPPlugin plugin: plugins) {
- if (pluginId.equals(plugin.getPluginId())) {
- final String location = plugin.getLicenseFileLocation();
- if (location == null) {
- log.error("Plugin {} has no license", pluginId);
- return;
- }
- final Resource loc = new ClassPathResource(location);
- if (!loc.exists()) {
- log.error("Plugin {} license could not be found at {}", pluginId, location);
- return;
- }
- outOrLog(String.format("License for %s", plugin));
- try (final BufferedReader reader = new BufferedReader(new InputStreamReader(loc.getInputStream()))) {
- String line = reader.readLine();
- while (line != null) {
- outOrLog(line);
- line = reader.readLine();
- }
- } catch (final IOException e) {
- log.error("Failed to output license", e);
- }
- return;
+ final IdPPlugin plugin = installer.getInstalledPlugin(pluginId);
+ if (plugin == null) {
+ log.error("Plugin {} not installed", pluginId);
+ return;
+ }
+ final String location = plugin.getLicenseFileLocation();
+ if (location == null) {
+ log.error("Plugin {} has no license", pluginId);
+ return;
+ }
+ final Resource loc = new ClassPathResource(location);
+ if (!loc.exists()) {
+ log.error("Plugin {} license could not be found at {}", pluginId, location);
+ return;
+ }
+ outOrLog(String.format("License for %s", plugin));
+ try (final BufferedReader reader = new BufferedReader(new InputStreamReader(loc.getInputStream()))) {
+ String line = reader.readLine();
+ while (line != null) {
+ outOrLog(line);
+ line = reader.readLine();
}
+ } catch (final IOException e) {
+ log.error("Failed to output license", e);
}
- log.error("Plugin {} not installed", pluginId);
}
/** List all installed plugins (or just one if provided).
@@ -297,14 +296,7 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
* @param pluginId the pluginId
*/
private void doContentList(@Nonnull final String pluginId) {
- final List<IdPPlugin> plugins = installer.getInstalledPlugins();
- IdPPlugin thePlugin = null;
- for (final IdPPlugin plugin: plugins) {
- if (pluginId.equals(plugin.getPluginId())) {
- thePlugin = plugin;
- break;
- }
- }
+ final IdPPlugin thePlugin = installer.getInstalledPlugin(pluginId);
final String fromContentsVersion = installer.getVersionFromContents();
final List<String> contents = installer.getInstalledContents();
@@ -387,41 +379,41 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
* @param pluginVersion (optionally) the version to update to.
*/
private void doUpdate(@Nonnull final String pluginId, @Nullable final PluginVersion pluginVersion) {
- final List<IdPPlugin> plugins = installer.getInstalledPlugins();
- for (final IdPPlugin plugin: plugins) {
- if (pluginId.equals(plugin.getPluginId())) {
- log.debug("Interrogating {} ", plugin.getPluginId());
- final PluginState state = new PluginState(plugin);
- if (getHttpClient() != null) {
- state.setHttpClient(getHttpClient());
- }
- try {
- state.initialize();
- } catch (final ComponentInitializationException e) {
- log.error("Could not interrogate plugin {}", plugin.getPluginId(), e);
- return;
- }
- final PluginVersion installVersion;
- if (pluginVersion == null) {
- installVersion = getBestVersion(plugin, state);
- if (installVersion == null) {
- log.info("No Suitable update version available");
- break;
- }
- } else {
- installVersion = pluginVersion;
- final Map<PluginVersion, VersionInfo> versions = state.getAvailableVersions();
- if (!versions.containsKey(installVersion)) {
- log.error("Specified version {} could not be found. Available versions {}",
- installVersion, versions.keySet());
- return;
- }
- }
- // just use the tgz version - its an update so it should be jar files only
- installer.installPlugin(state.getUpdateURL(installVersion),
- state.getUpdateBaseName(installVersion) + ".tar.gz");
+ final IdPPlugin plugin = installer.getInstalledPlugin(pluginId);
+ if (plugin == null) {
+ log.error("Plugin {} was not installed", pluginId);
+ return;
+ }
+ log.debug("Interrogating {} ", plugin.getPluginId());
+ final PluginState state = new PluginState(plugin);
+ if (getHttpClient() != null) {
+ state.setHttpClient(getHttpClient());
+ }
+ try {
+ state.initialize();
+ } catch (final ComponentInitializationException e) {
+ log.error("Could not interrogate plugin {}", plugin.getPluginId(), e);
+ return;
+ }
+ final PluginVersion installVersion;
+ if (pluginVersion == null) {
+ installVersion = getBestVersion(plugin, state);
+ if (installVersion == null) {
+ log.info("No Suitable update version available");
+ return;
+ }
+ } else {
+ installVersion = pluginVersion;
+ final Map<PluginVersion, VersionInfo> versions = state.getAvailableVersions();
+ if (!versions.containsKey(installVersion)) {
+ log.error("Specified version {} could not be found. Available versions {}",
+ installVersion, versions.keySet());
+ return;
}
}
+ // just use the tgz version - its an update so it should be jar files only
+ installer.installPlugin(state.getUpdateURL(installVersion),
+ state.getUpdateBaseName(installVersion) + ".tar.gz");
}
/** Shim for CLI entry point: Allows the code to be run from a test.
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerSupport.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerSupport.java
index fcbda89b0..2096e4c45 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerSupport.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerSupport.java
@@ -74,21 +74,7 @@ public final class PluginInstallerSupport {
}
LOG.debug("Deleting directory {}", directory);
try {
- Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
- @Override
- public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
- if (exc != null) {
- throw exc;
- }
- Files.delete(dir);
- return FileVisitResult.CONTINUE;
- }
- });
+ Files.walkFileTree(directory, new DeletingVisitor());
} catch (final IOException e) {
LOG.error("Couldn't delete {}", directory, e);
}
@@ -162,7 +148,7 @@ public final class PluginInstallerSupport {
to = toDir;
}
- @Override
+ @Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
final Path relFile = from.relativize(file);
final Path toFile = to.resolve(relFile);
@@ -215,7 +201,7 @@ public final class PluginInstallerSupport {
return FileVisitResult.CONTINUE;
};
- @Override
+ @Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
final Path relFile = from.relativize(file);
final Path toFile = to.resolve(relFile);
@@ -235,4 +221,34 @@ public final class PluginInstallerSupport {
}
}
+ /**
+ * A @{link {@link FileVisitor} which deletes files.
+ */
+ private static final class DeletingVisitor extends SimpleFileVisitor<Path> {
+ @Override
+ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+ try {
+ Files.delete(file);
+ } catch (final IOException e) {
+ LOG.error("Could not delete {}", file.toAbsolutePath(), e);
+ file.toFile().deleteOnExit();
+ // and carry on
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ @Override
+ public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+ if (exc != null) {
+ throw exc;
+ }
+ try {
+ Files.delete(dir);
+ } catch (final IOException e) {
+ LOG.error("Could not delete {}", dir.toAbsolutePath(), e);
+ dir.toFile().deleteOnExit();
+ // and carry on
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ }
}
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
index 2d39bb3bf..4473a4a66 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
@@ -51,7 +51,7 @@ public class PluginCLITest extends BasePluginTest {
assertEquals(PluginInstallerCLI.runMain(new String[] { "--license", "net.shibboleth.plugin.test"} ), AbstractCommandLine.RC_OK);
}
- @Test(enabled = false) public void testList() throws IOException {
+ @Test(enabled = true) public void testList() throws IOException {
assertEquals(PluginInstallerCLI.runMain(new String[] { "-fl", } ), AbstractCommandLine.RC_OK);
}
@@ -66,25 +66,44 @@ public class PluginCLITest extends BasePluginTest {
AbstractCommandLine.RC_OK);
}
- @Test(enabled = false, dependsOnMethods = {"testRhinoWeb"}) public void testUpdate() {
+ @Test(enabled = false, dependsOnMethods = {"testRhinoWeb"})
+ public void testUpdate() {
assertEquals(PluginInstallerCLI.runMain(new String[] {
"-u", "net.shibboleth.idp.plugin.rhino"}),
AbstractCommandLine.RC_OK);
}
- @Test(enabled = false, dependsOnMethods = {"testUpdate"}) public void testForceUpdate() {
+ @Test(enabled = false, dependsOnMethods = {"testUpdate"})
+ public void testForceUpdate() {
assertEquals(PluginInstallerCLI.runMain(new String[] {
"-u", "net.shibboleth.idp.plugin.rhino",
"-fu", "0.1.3" }),
AbstractCommandLine.RC_OK);
}
+ @Test(enabled = false, dependsOnMethods = {"testForceUpdate"})
+ public void testListContents() {
+ assertEquals(PluginInstallerCLI.runMain(new String[] {
+ "-cl", "net.shibboleth.idp.plugin.rhino",
+ }),
+ AbstractCommandLine.RC_OK);
+ }
+
+ @Test(enabled = true, dependsOnMethods = {"testListContents"}, ignoreMissingDependencies = true)
+ public void testUninstall() {
+ assertEquals(PluginInstallerCLI.runMain(new String[] {
+ "-r", "net.shibboleth.idp.plugin.rhino",
+ }),
+ AbstractCommandLine.RC_OK);
+ }
+
@Test(enabled = false) public void testRhinoLocal() throws Exception {
Path unpack = null;
try {
+ Resource from;
unpack = Files.createTempDirectory("rhinoLocal");
final HttpClient client = new HttpClientBuilder().buildClient();
- Resource from = new HTTPResource(client, RHINO_DISTRO);
+ from = new HTTPResource(client, RHINO_DISTRO);
try (final InputStream in = from.getInputStream();
final OutputStream out = new ProgressReportingOutputStream(new FileOutputStream(unpack.resolve("rhino.tar.gz").toFile()))) {
in.transferTo(out);
@@ -103,14 +122,14 @@ public class PluginCLITest extends BasePluginTest {
final Path trustStorePath = credentials.resolve("truststore.asc");
from = new ClassPathResource("credentials/truststore.asc");
try (final InputStream in = from.getInputStream();
- final OutputStream out = new ProgressReportingOutputStream(new FileOutputStream(trustStorePath.toFile(), true))) {
+ final OutputStream out = new ProgressReportingOutputStream(new FileOutputStream(trustStorePath.toFile(), true))) {
in.transferTo(out);
}
//
// try again
//
- assertEquals(PluginInstallerCLI.runMain(new String[] {
- "-i", unpack.resolve("rhino.tar.gz").toString(),
+ assertEquals(PluginInstallerCLI.runMain(new String[] {
+ "-i", unpack.resolve("rhino.tar.gz").toString(),
"-p", "net.shibboleth.idp.plugin.rhino"}),
AbstractCommandLine.RC_OK);
} finally {
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
index 7f55a7cc0..919de1ec6 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
@@ -83,7 +83,7 @@ public class PluginInstallerTest extends BasePluginTest {
inst.setIdpHome(getIdpHome());
inst.setPluginId("org.example.Plugin");
inst.initialize();
- inst.removeJars();
+ inst.uninstall();
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list