]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1897 the WS must be available to anonymous users + add IT
authorsimonbrandhof <simon.brandhof@gmail.com>
Mon, 8 Nov 2010 15:01:53 +0000 (15:01 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Mon, 8 Nov 2010 15:01:53 +0000 (15:01 +0000)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/updatecenter_controller.rb
tests/integration/tests/src/it/java/org/sonar/tests/integration/UpdateCenterTest.java [new file with mode: 0644]

index dbbaa13598fd1da95d6e39d0f19c82893ff57c7b..03f9e53daa7803c78f61c535d451bb126eab2f5f 100644 (file)
@@ -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 (file)
index 0000000..f49ad61
--- /dev/null
@@ -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;
+  }
+
+}