View Javadoc

1   /*
2    * $Id: ServletHttpFilterFunctionalTestCase.java 22370 2011-07-11 08:31:38Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.test.integration.security;
12  
13  import org.mule.module.spring.security.HttpFilterFunctionalTestCase;
14  import org.mule.transport.servlet.MuleReceiverServlet;
15  import org.mule.transport.servlet.jetty.util.EmbeddedJettyServer;
16  
17  import java.util.Arrays;
18  import java.util.Collection;
19  
20  import org.junit.runners.Parameterized.Parameters;
21  
22  public class ServletHttpFilterFunctionalTestCase extends HttpFilterFunctionalTestCase
23  {
24  
25      public static final int HTTP_PORT = 4567;
26  
27      private EmbeddedJettyServer httpServer;
28  
29      public ServletHttpFilterFunctionalTestCase(ConfigVariant variant, String configResources)
30      {
31          super(variant, configResources);
32  
33      }
34  
35      @Parameters
36      public static Collection<Object[]> parameters()
37      {
38          return Arrays.asList(new Object[][]{
39              {ConfigVariant.SERVICE, "org/mule/test/integration/security/servlet-http-filter-test-service.xml"},
40              {ConfigVariant.FLOW, "org/mule/test/integration/security/servlet-http-filter-test-flow.xml"}});
41      }
42  
43      @Override
44      protected String getUrl()
45      {
46          return "http://localhost:" + HTTP_PORT + "/test/index.html";
47      }
48  
49      @Override
50      protected void doSetUp() throws Exception
51      {
52          super.doSetUp();
53  
54          httpServer = new EmbeddedJettyServer(HTTP_PORT, "/", "/*", new MuleReceiverServlet(), muleContext);
55          httpServer.start();
56      }
57  
58      @Override
59      protected void doTearDown() throws Exception
60      {
61          if (httpServer != null && httpServer.isStarted())
62          {
63              httpServer.stop();
64          }
65  
66          super.doTearDown();
67      }
68  
69      protected String getNoContextErrorResponse()
70      {
71          return "Registered authentication is set to org.mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter "
72                 + "but there was no security context on the session. Authentication denied on endpoint "
73                 + "servlet://test. Message payload is of type: String";
74      }
75  
76  }