mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Prohibit uninstallation of core plugins
This commit is contained in:
@@ -188,6 +188,7 @@ public class DefaultPluginManager implements PluginManager {
|
|||||||
PluginPermissions.manage().check();
|
PluginPermissions.manage().check();
|
||||||
InstalledPlugin installed = getInstalled(name)
|
InstalledPlugin installed = getInstalled(name)
|
||||||
.orElseThrow(() -> NotFoundException.notFound(entity(InstalledPlugin.class, name)));
|
.orElseThrow(() -> NotFoundException.notFound(entity(InstalledPlugin.class, name)));
|
||||||
|
doThrow().violation("plugin is a core plugin and cannot be uninstalled").when(installed.isCore());
|
||||||
|
|
||||||
dependencyTracker.removeInstalled(installed.getDescriptor());
|
dependencyTracker.removeInstalled(installed.getDescriptor());
|
||||||
|
|
||||||
|
|||||||
@@ -344,6 +344,19 @@ class DefaultPluginManagerTest {
|
|||||||
|
|
||||||
assertThat(temp.resolve("uninstall")).exists();
|
assertThat(temp.resolve("uninstall")).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldThrowExceptionWhenUninstallingCorePlugin(@TempDirectory.TempDir Path temp) {
|
||||||
|
InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin");
|
||||||
|
when(mailPlugin.getDirectory()).thenReturn(temp);
|
||||||
|
when(mailPlugin.isCore()).thenReturn(true);
|
||||||
|
|
||||||
|
when(loader.getInstalledPlugins()).thenReturn(singletonList(mailPlugin));
|
||||||
|
|
||||||
|
assertThrows(ScmConstraintViolationException.class, () -> manager.uninstall("scm-mail-plugin", false));
|
||||||
|
|
||||||
|
assertThat(temp.resolve("uninstall")).doesNotExist();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
Reference in New Issue
Block a user