mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
Detect core plugins and prevent installation
This commit is contained in:
@@ -16,6 +16,7 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.ScmConstraintViolationException;
|
||||
import sonia.scm.event.ScmEventBus;
|
||||
import sonia.scm.lifecycle.RestartEvent;
|
||||
|
||||
@@ -177,6 +178,31 @@ class DefaultPluginManagerTest {
|
||||
verify(eventBus, never()).post(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldUpdateNormalPlugin() {
|
||||
AvailablePlugin available = createAvailable("scm-git-plugin", "2");
|
||||
InstalledPlugin installed = createInstalled("scm-git-plugin", "1");
|
||||
when(installed.isCore()).thenReturn(false);
|
||||
lenient().when(center.getAvailable()).thenReturn(ImmutableSet.of(available));
|
||||
when(loader.getInstalledPlugins()).thenReturn(ImmutableSet.of(installed));
|
||||
|
||||
manager.install("scm-git-plugin", false);
|
||||
|
||||
verify(installer).install(available);
|
||||
verify(eventBus, never()).post(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotUpdateCorePlugin() {
|
||||
AvailablePlugin available = createAvailable("scm-git-plugin", "2");
|
||||
InstalledPlugin installed = createInstalled("scm-git-plugin", "1");
|
||||
when(installed.isCore()).thenReturn(true);
|
||||
lenient().when(center.getAvailable()).thenReturn(ImmutableSet.of(available));
|
||||
when(loader.getInstalledPlugins()).thenReturn(ImmutableSet.of(installed));
|
||||
|
||||
assertThrows(ScmConstraintViolationException.class, () -> manager.install("scm-git-plugin", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldInstallDependingPlugins() {
|
||||
AvailablePlugin review = createAvailable("scm-review-plugin", "1");
|
||||
|
||||
@@ -248,7 +248,7 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
private InstalledPlugin createPluginWrapper(Path directory)
|
||||
{
|
||||
return new InstalledPlugin(null, null, new PathWebResourceLoader(directory),
|
||||
directory);
|
||||
directory, false);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user