use of org.sonar.server.plugins.ServerPlugin in project sonarqube by SonarSource.
the class RegisterPluginsTest method addPlugin.
private ServerPlugin addPlugin(String key, PluginType type, @Nullable String basePlugin) throws IOException {
File file = createPluginFile(key);
PluginFilesAndMd5.FileAndMd5 jar = new PluginFilesAndMd5.FileAndMd5(file);
PluginInfo info = new PluginInfo(key).setBasePlugin(basePlugin).setJarFile(file);
ServerPlugin serverPlugin = new ServerPlugin(info, type, null, jar, null, null);
serverPluginRepository.addPlugin(serverPlugin);
return serverPlugin;
}
use of org.sonar.server.plugins.ServerPlugin in project sonarqube by SonarSource.
the class InstalledActionTest method return_compression_fields_if_available.
@Test
public void return_compression_fields_if_available() throws Exception {
ServerPlugin plugin = newInstalledPluginWithCompression(new PluginInfo("foo").setName("plugName").setDescription("desc_it").setVersion(Version.create("1.0")).setLicense("license_hey").setOrganizationName("org_name").setOrganizationUrl("org_url").setHomepageUrl("homepage_url").setIssueTrackerUrl("issueTracker_url").setImplementationBuild("sou_rev_sha1").setDocumentationPath("static/documentation.md").setSonarLintSupported(true));
when(serverPluginRepository.getPlugins()).thenReturn(singletonList(plugin));
db.pluginDbTester().insertPlugin(p -> p.setKee(plugin.getPluginInfo().getKey()), p -> p.setType(Type.EXTERNAL), p -> p.setUpdatedAt(100L));
String response = tester.newRequest().execute().getInput();
verifyZeroInteractions(updateCenterMatrixFactory);
assertJson(response).isSimilarTo("{" + " \"plugins\":" + " [" + " {" + " \"key\": \"foo\"," + " \"name\": \"plugName\"," + " \"description\": \"desc_it\"," + " \"version\": \"1.0\"," + " \"license\": \"license_hey\"," + " \"organizationName\": \"org_name\"," + " \"organizationUrl\": \"org_url\",\n" + " \"editionBundled\": false," + " \"homepageUrl\": \"homepage_url\"," + " \"issueTrackerUrl\": \"issueTracker_url\"," + " \"implementationBuild\": \"sou_rev_sha1\"," + " \"sonarLintSupported\": true," + " \"documentationPath\": \"static/documentation.md\"," + " \"filename\": \"" + plugin.getJar().getFile().getName() + "\"," + " \"hash\": \"" + plugin.getJar().getMd5() + "\"," + " \"updatedAt\": 100" + " }" + " ]" + "}");
}
use of org.sonar.server.plugins.ServerPlugin in project sonarqube by SonarSource.
the class InstalledActionTest method newInstalledPluginWithCompression.
private ServerPlugin newInstalledPluginWithCompression(PluginInfo plugin) throws IOException {
FileAndMd5 jar = new FileAndMd5(temp.newFile());
FileAndMd5 compressedJar = new FileAndMd5(temp.newFile());
return new ServerPlugin(plugin, PluginType.BUNDLED, null, jar, compressedJar, null);
}
use of org.sonar.server.plugins.ServerPlugin in project sonarqube by SonarSource.
the class InstalledActionTest method commercial_plugins_from_SonarSource_has_flag_editionBundled_true_based_on_jar_info.
@Test
@UseDataProvider("editionBundledLicenseValues")
public void commercial_plugins_from_SonarSource_has_flag_editionBundled_true_based_on_jar_info(String license) throws Exception {
String jarFilename = getClass().getSimpleName() + "/" + "some.jar";
Random random = new Random();
String organization = random.nextBoolean() ? "SonarSource" : "SONARSOURCE";
String pluginKey = "plugKey";
File jar = new File(getClass().getResource(jarFilename).toURI());
when(serverPluginRepository.getPlugins()).thenReturn(asList(new ServerPlugin(new PluginInfo(pluginKey).setName("plugName").setVersion(Version.create("1.0")).setLicense(license).setOrganizationName(organization).setImplementationBuild("sou_rev_sha1"), PluginType.BUNDLED, null, new FileAndMd5(jar), new FileAndMd5(jar), null)));
db.pluginDbTester().insertPlugin(p -> p.setKee(pluginKey), p -> p.setType(Type.BUNDLED), p -> p.setFileHash("abcdplugKey"), p -> p.setUpdatedAt(111111L));
// ensure flag editionBundled is computed from jar info by enabling datacenter with other organization and license values
UpdateCenter updateCenter = mock(UpdateCenter.class);
when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
when(updateCenter.findAllCompatiblePlugins()).thenReturn(singletonList(Plugin.factory(pluginKey).setOrganization("foo").setLicense("bar").setCategory("cat_1")));
String response = tester.newRequest().execute().getInput();
verifyZeroInteractions(updateCenterMatrixFactory);
assertJson(response).isSimilarTo("{" + " \"plugins\":" + " [" + " {" + " \"key\": \"plugKey\"," + " \"name\": \"plugName\"," + " \"license\": \"" + license + "\"," + " \"organizationName\": \"" + organization + "\"," + " \"editionBundled\": true" + " }" + " ]" + "}");
}
use of org.sonar.server.plugins.ServerPlugin in project sonarqube by SonarSource.
the class DownloadActionTest method return_jar_if_plugin_exists.
@Test
public void return_jar_if_plugin_exists() throws Exception {
ServerPlugin plugin = newPlugin();
when(serverPluginRepository.findPlugin(plugin.getPluginInfo().getKey())).thenReturn(Optional.of(plugin));
TestResponse response = tester.newRequest().setParam("plugin", plugin.getPluginInfo().getKey()).execute();
assertThat(response.getHeader("Sonar-MD5")).isEqualTo(plugin.getJar().getMd5());
assertThat(response.getHeader("Sonar-Compression")).isNull();
assertThat(response.getMediaType()).isEqualTo("application/java-archive");
verifySameContent(response, plugin.getJar().getFile());
}
Aggregations