mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-03 06:18:43 +02:00
Include cloudogu plugins to plugin center (#1709)
Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import java.net.URI;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static sonia.scm.plugin.PluginInformation.PluginType.*;
|
||||
import static sonia.scm.plugin.PluginTestHelper.createAvailable;
|
||||
import static sonia.scm.plugin.PluginTestHelper.createInstalled;
|
||||
|
||||
@@ -85,9 +86,14 @@ class PluginDtoMapperTest {
|
||||
assertThat(dto.getAuthor()).isEqualTo("Sebastian Sdorra");
|
||||
assertThat(dto.getCategory()).isEqualTo("Authentication");
|
||||
assertThat(dto.getAvatarUrl()).isEqualTo("https://avatar.scm-manager.org/plugins/cas.png");
|
||||
assertThat(dto.getType()).isEqualTo(SCM);
|
||||
}
|
||||
|
||||
private PluginInformation createPluginInformation() {
|
||||
return createPluginInformation(SCM);
|
||||
}
|
||||
|
||||
private PluginInformation createPluginInformation(PluginInformation.PluginType type) {
|
||||
PluginInformation information = new PluginInformation();
|
||||
information.setName("scm-cas-plugin");
|
||||
information.setVersion("1.0.0");
|
||||
@@ -95,6 +101,7 @@ class PluginDtoMapperTest {
|
||||
information.setAuthor("Sebastian Sdorra");
|
||||
information.setCategory("Authentication");
|
||||
information.setAvatarUrl("https://avatar.scm-manager.org/plugins/cas.png");
|
||||
information.setType(type);
|
||||
return information;
|
||||
}
|
||||
|
||||
@@ -135,6 +142,18 @@ class PluginDtoMapperTest {
|
||||
.isEqualTo("https://hitchhiker.com/v2/plugins/available/scm-cas-plugin/install");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAppendCloudoguInstallLink() {
|
||||
when(subject.isPermitted("plugin:write")).thenReturn(true);
|
||||
AvailablePlugin plugin = createAvailable(createPluginInformation(CLOUDOGU));
|
||||
|
||||
PluginDto dto = mapper.mapAvailable(plugin);
|
||||
|
||||
assertThat(dto.getType()).isEqualTo(CLOUDOGU);
|
||||
assertThat(dto.getLinks().getLinkBy("cloudoguInstall").get().getHref())
|
||||
.isEqualTo("mycloudogu.com/install/my_plugin");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAppendInstallWithRestartLink() {
|
||||
when(restarter.isSupported()).thenReturn(true);
|
||||
|
||||
@@ -58,13 +58,14 @@ class PluginCenterDtoMapperTest {
|
||||
void shouldMapSinglePlugin() {
|
||||
Plugin plugin = new Plugin(
|
||||
"scm-hitchhiker-plugin",
|
||||
"2.0.0",
|
||||
"SCM Hitchhiker Plugin",
|
||||
"plugin for hitchhikers",
|
||||
"Travel",
|
||||
"2.0.0",
|
||||
"trillian",
|
||||
"http://avatar.url",
|
||||
"555000444",
|
||||
PluginInformation.PluginType.SCM,
|
||||
new Condition(Collections.singletonList("linux"), "amd64","2.0.0"),
|
||||
ImmutableSet.of("scm-review-plugin"),
|
||||
ImmutableSet.of(),
|
||||
@@ -93,13 +94,14 @@ class PluginCenterDtoMapperTest {
|
||||
void shouldMapMultiplePlugins() {
|
||||
Plugin plugin1 = new Plugin(
|
||||
"scm-review-plugin",
|
||||
"2.1.0",
|
||||
"SCM Hitchhiker Plugin",
|
||||
"plugin for hitchhikers",
|
||||
"Travel",
|
||||
"2.1.0",
|
||||
"trillian",
|
||||
"https://avatar.url",
|
||||
"12345678aa",
|
||||
PluginInformation.PluginType.SCM,
|
||||
new Condition(Collections.singletonList("linux"), "amd64","2.0.0"),
|
||||
ImmutableSet.of("scm-review-plugin"),
|
||||
ImmutableSet.of(),
|
||||
@@ -108,13 +110,14 @@ class PluginCenterDtoMapperTest {
|
||||
|
||||
Plugin plugin2 = new Plugin(
|
||||
"scm-hitchhiker-plugin",
|
||||
"2.0.0",
|
||||
"SCM Hitchhiker Plugin",
|
||||
"plugin for hitchhikers",
|
||||
"Travel",
|
||||
"2.0.0",
|
||||
"dent",
|
||||
"http://avatar.url",
|
||||
"555000444",
|
||||
PluginInformation.PluginType.CLOUDOGU,
|
||||
new Condition(Collections.singletonList("linux"), "amd64","2.0.0"),
|
||||
ImmutableSet.of("scm-review-plugin"),
|
||||
ImmutableSet.of(),
|
||||
@@ -132,6 +135,8 @@ class PluginCenterDtoMapperTest {
|
||||
assertThat(pluginInformation1.getVersion()).isEqualTo(plugin1.getVersion());
|
||||
assertThat(pluginInformation2.getAuthor()).isEqualTo(plugin2.getAuthor());
|
||||
assertThat(pluginInformation2.getVersion()).isEqualTo(plugin2.getVersion());
|
||||
assertThat(pluginInformation1.getType()).isEqualTo(PluginInformation.PluginType.SCM);
|
||||
assertThat(pluginInformation2.getType()).isEqualTo(PluginInformation.PluginType.CLOUDOGU);
|
||||
assertThat(resultSet.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ package sonia.scm.plugin;
|
||||
|
||||
import org.mockito.Answers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -62,6 +64,7 @@ public class PluginTestHelper {
|
||||
public static AvailablePlugin createAvailable(PluginInformation information) {
|
||||
AvailablePluginDescriptor descriptor = mock(AvailablePluginDescriptor.class);
|
||||
lenient().when(descriptor.getInformation()).thenReturn(information);
|
||||
lenient().when(descriptor.getInstallLink()).thenReturn(Optional.of("mycloudogu.com/install/my_plugin"));
|
||||
return new AvailablePlugin(descriptor);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user