From: simonbrandhof Date: Mon, 8 Nov 2010 15:01:53 +0000 (+0000) Subject: SONAR-1897 the WS must be available to anonymous users + add IT X-Git-Tag: 2.6~623 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a51158f4665202f6b7603e9fad8caee05f6ae5d4;p=sonarqube.git SONAR-1897 the WS must be available to anonymous users + add IT --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb index dbbaa13598f..03f9e53daa7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb @@ -22,11 +22,9 @@ require 'json' class Api::UpdatecenterController < Api::ApiController - before_filter :admin_required - # # GET /api/updatecenter/installed_plugins - # curl http://localhost:9000/api/updatecenter/installed_plugins -v -u admin:admin + # curl http://localhost:9000/api/updatecenter/installed_plugins -v # def installed_plugins respond_to do |format| diff --git a/tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java b/tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java new file mode 100644 index 00000000000..f49ad613b52 --- /dev/null +++ b/tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java @@ -0,0 +1,59 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.tests.integration; + +import org.apache.commons.lang.StringUtils; +import org.junit.Test; +import org.sonar.wsclient.Sonar; +import org.sonar.wsclient.services.Plugin; +import org.sonar.wsclient.services.UpdateCenterQuery; + +import java.util.List; + +import static junit.framework.Assert.assertNotNull; +import static org.hamcrest.Matchers.startsWith; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.junit.Assert.assertThat; + +public class UpdateCenterTest { + + @Test + public void shouldGetInstalledPlugins() { + Sonar sonar = Sonar.create("http://localhost:9000"); + List plugins = sonar.findAll(UpdateCenterQuery.createForInstalledPlugins()); + assertThat(plugins.size(), greaterThan(0)); + + Plugin referencePlugin = findReferencePlugin(plugins, "itreference"); + assertNotNull(referencePlugin); + assertThat(referencePlugin.getName(), is("Sonar :: Integration Tests :: Reference Plugin")); + assertThat(referencePlugin.getVersion(), startsWith("2.")); + } + + private Plugin findReferencePlugin(List plugins, String pluginKey) { + for (Plugin plugin : plugins) { + if (StringUtils.equals(pluginKey, plugin.getKey())) { + return plugin; + } + } + return null; + } + +}