[MRM-1145] RSS tests do not correctly check responses

This commit is contained in:
Olivier Lamy 2014-10-14 15:02:22 +11:00
parent 951b9f8ef1
commit 84d5a61c80
2 changed files with 10 additions and 3 deletions

View File

@ -115,11 +115,14 @@ public void init( ServletConfig servletConfig )
public void doGet( HttpServletRequest req, HttpServletResponse res ) public void doGet( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException throws ServletException, IOException
{ {
String repoId = null; String repoId = null;
String groupId = null; String groupId = null;
String artifactId = null; String artifactId = null;
String url = StringUtils.removeEnd( req.getRequestURL().toString(), "/" ); String url = StringUtils.removeEnd( req.getRequestURL().toString(), "/" );
if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) > 0 ) if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) > 0 )
{ {
artifactId = StringUtils.substringAfterLast( url, "/" ); artifactId = StringUtils.substringAfterLast( url, "/" );
@ -128,6 +131,12 @@ public void doGet( HttpServletRequest req, HttpServletResponse res )
} }
else if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) == 0 ) 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, "/" ); repoId = StringUtils.substringAfterLast( url, "/" );
} }
else else

View File

@ -430,12 +430,10 @@ public void testRequestNewVersionsOfArtifact()
mockHttpServletResponse.getStatus() ); mockHttpServletResponse.getStatus() );
} }
@Ignore @Test
public void testInvalidRequest() public void testInvalidRequest()
throws Exception throws Exception
{ {
//RssFeedServlet servlet =
// (RssFeedServlet) client.newInvocation( "http://localhost/feeds?invalid_param=xxx" ).getServlet();
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI( "/feeds?invalid_param=xxx" ); request.setRequestURI( "/feeds?invalid_param=xxx" );
request.addHeader( "User-Agent", "Apache Archiva unit test" ); request.addHeader( "User-Agent", "Apache Archiva unit test" );