1
2
3
4
5
6
7
8
9
10
11 package org.mule.extras.wssecurity.testcases;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.umo.UMOMessage;
16
17 import java.util.Properties;
18
19 import org.apache.ws.security.handler.WSHandlerConstants;
20
21 public class AxisWsSecurityOnInboundTestCase extends FunctionalTestCase
22 {
23 public void testGoodUserNameEncrypted () throws Exception
24 {
25 MuleClient client = new MuleClient();
26 Properties props = new Properties();
27
28
29 props.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
30
31 props.setProperty(WSHandlerConstants.USER, "mulealias");
32
33 props.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, "org.mule.extras.wssecurity.callbackhandlers.MuleWsSecurityCallbackHandler");
34
35 props.setProperty(WSHandlerConstants.ENC_PROP_FILE, "out-encrypted-security.properties");
36
37 UMOMessage m = client.send("axis:http://localhost:8282/MySecuredUMO?method=echo", "Test", props);
38 assertNotNull(m);
39 assertTrue(m.getPayload() instanceof String);
40 assertTrue(m.getPayload().equals("Test"));
41 }
42
43 public void testBadUserNameEncrypted () throws Exception
44 {
45 MuleClient client = new MuleClient();
46 Properties props = new Properties();
47
48
49 props.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
50
51 props.setProperty(WSHandlerConstants.USER, "myBadAlias");
52
53 props.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, "org.mule.extras.wssecurity.callbackhandlers.MuleWsSecurityCallbackHandler");
54
55 props.setProperty(WSHandlerConstants.ENC_PROP_FILE, "out-encrypted-security.properties");
56
57 UMOMessage m = null;
58 try
59 {
60 m = client.send("axis:http://localhost:8282/MySecuredUMO?method=echo", "Test", props);
61 }
62 catch (Exception e)
63 {
64 assertNotNull(e);
65 }
66 assertNull(m);
67 }
68
69 protected String getConfigResources ()
70 {
71 return "axis-wssecurity-mule-config.xml";
72 }
73 }