1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.security;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15 import static org.junit.Assert.assertNull;
16
17 import org.mule.api.MuleMessage;
18 import org.mule.client.DefaultLocalMuleClient;
19 import org.mule.tck.junit4.FunctionalTestCase;
20
21 import java.util.HashMap;
22
23 import org.junit.Test;
24 import org.springframework.security.authentication.BadCredentialsException;
25
26
27
28
29 public class CustomSecurityFilterTestCase extends FunctionalTestCase
30 {
31 @Override
32 protected String getConfigResources()
33 {
34 return "org/mule/test/integration/security/custom-security-filter-test.xml";
35 }
36
37 @Test
38 public void testOutboundAutenticationSend() throws Exception
39 {
40 DefaultLocalMuleClient client = new DefaultLocalMuleClient(muleContext);
41
42 HashMap<String, Object> props = new HashMap<String, Object>();
43 props.put("username", "ross");
44 props.put("pass", "ross");
45 MuleMessage result = client.send("vm://test", "hi", props);
46 assertNull(result.getExceptionPayload());
47
48 props.put("pass", "badpass");
49
50 MuleMessage resultMessage = client.send("vm://test", "hi", props);
51 assertNotNull(resultMessage);
52 assertNotNull(resultMessage.getExceptionPayload());
53 assertEquals(BadCredentialsException.class, resultMessage.getExceptionPayload()
54 .getRootException()
55 .getClass());
56 }
57 }