]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1145] RSS tests do not correctly check responses
authorOlivier Lamy <olamy@apache.org>
Tue, 14 Oct 2014 04:02:22 +0000 (15:02 +1100)
committerOlivier Lamy <olamy@apache.org>
Tue, 14 Oct 2014 04:59:00 +0000 (15:59 +1100)
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java
archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java

index 958ad28e746de2d5ad7cc43b16730b6c3f84b7e8..a0994cd25b48172361bb4a8d699cb6f418eff094 100644 (file)
@@ -115,11 +115,14 @@ public class RssFeedServlet
     public void doGet( HttpServletRequest req, HttpServletResponse res )
         throws ServletException, IOException
     {
+
+
         String repoId = null;
         String groupId = null;
         String artifactId = null;
 
         String url = StringUtils.removeEnd( req.getRequestURL().toString(), "/" );
+
         if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) > 0 )
         {
             artifactId = StringUtils.substringAfterLast( url, "/" );
@@ -128,6 +131,12 @@ public class RssFeedServlet
         }
         else if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) == 0 )
         {
+            // we receive feeds?babla=ded which is not correct
+            if ( StringUtils.countMatches( url, "feeds?" ) > 0 )
+            {
+                res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Invalid request url." );
+                return;
+            }
             repoId = StringUtils.substringAfterLast( url, "/" );
         }
         else
index 54dab14ae12520440d8c052051853041e63df5c4..582a532257d61eab3155f0498c45bfdc80ca4e31 100644 (file)
@@ -430,12 +430,10 @@ public class RssFeedServletTest
                       mockHttpServletResponse.getStatus() );
     }
 
-    @Ignore
+    @Test
     public void testInvalidRequest()
         throws Exception
     {
-        //RssFeedServlet servlet =
-        //    (RssFeedServlet) client.newInvocation( "http://localhost/feeds?invalid_param=xxx" ).getServlet();
         MockHttpServletRequest request = new MockHttpServletRequest();
         request.setRequestURI( "/feeds?invalid_param=xxx" );
         request.addHeader( "User-Agent", "Apache Archiva unit test" );