Detect core plugins and prevent installation

This commit is contained in:
Rene Pfeuffer
2019-09-11 16:46:27 +02:00
parent a7cb1d3116
commit 0fdd1cea17
7 changed files with 56 additions and 6 deletions

View File

@@ -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");

View File

@@ -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 ---------------------------------------------------------------