View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.security;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.client.DefaultLocalMuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import java.util.HashMap;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertNotNull;
18  import static org.junit.Assert.assertNull;
19  
20  /**
21   * See MULE-4916: spring beans inside a security filter
22   */
23  public class CustomSecurityFilterTestCase extends FunctionalTestCase
24  {
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/test/integration/security/custom-security-filter-test.xml";
30      }
31  
32      @Test
33      public void testOutboundAutenticationSend() throws Exception
34      {
35          DefaultLocalMuleClient client = new DefaultLocalMuleClient(muleContext);
36          
37          HashMap<String, Object> props = new HashMap<String,Object>();
38          props.put("username", "ross");
39          props.put("pass", "ross");
40          MuleMessage result = client.send("vm://test", "hi", props);
41          assertNull(result.getExceptionPayload());
42          
43          props.put("pass", "badpass");
44          result = client.send("vm://test", "hi", props);
45          assertNotNull(result.getExceptionPayload());
46      }
47  }