diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-08 15:01:53 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-08 15:01:53 +0000 |
commit | a51158f4665202f6b7603e9fad8caee05f6ae5d4 (patch) | |
tree | bafc15516b6f3708790490a0b32957a2289835aa | |
parent | 7ccbbfdbd03d7960d2fa3b62072b730b3968d9be (diff) | |
download | sonarqube-a51158f4665202f6b7603e9fad8caee05f6ae5d4.tar.gz sonarqube-a51158f4665202f6b7603e9fad8caee05f6ae5d4.zip |
SONAR-1897 the WS must be available to anonymous users + add IT
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb | 4 | ||||
-rw-r--r-- | tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java | 59 |
2 files changed, 60 insertions, 3 deletions
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<Plugin> 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<Plugin> plugins, String pluginKey) { + for (Plugin plugin : plugins) { + if (StringUtils.equals(pluginKey, plugin.getKey())) { + return plugin; + } + } + return null; + } + +} |