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 XfireWsSecurityOnOutboundTestCase extends FunctionalTestCase
22 {
23 public void testGoodUserNameTokenAuthentication () throws Exception
24 {
25 MuleClient client = new MuleClient();
26 Properties props = new Properties();
27
28
29 props.setProperty(WSHandlerConstants.USER, "gooduser");
30
31 UMOMessage m = client.send("vm://testin", "Test", props);
32 assertNotNull(m);
33 assertTrue(m.getPayload() instanceof String);
34 assertTrue(m.getPayload().equals("Test"));
35 }
36
37 public void testBadUserNameTokenAuthentication () throws Exception
38 {
39 MuleClient client = new MuleClient();
40 Properties props = new Properties();
41
42
43 props.setProperty(WSHandlerConstants.USER, "baduser");
44
45 UMOMessage m = null;
46 try
47 {
48 m = client.send("vm://testin", "Test", props);
49 }
50 catch (Exception e)
51 {
52 assertNotNull(e);
53 }
54 assertNull(m);
55 }
56
57 public void testGoodUserNameEncrypted () throws Exception
58 {
59 MuleClient client = new MuleClient();
60 Properties props = new Properties();
61
62
63 props.setProperty(WSHandlerConstants.USER, "mulealias");
64
65 UMOMessage m = client.send("vm://testin2", "Test", props);
66 assertNotNull(m);
67 assertTrue(m.getPayload() instanceof String);
68 assertTrue(m.getPayload().equals("Test"));
69 }
70
71 public void testBadUserNameEncrypted () throws Exception
72 {
73 MuleClient client = new MuleClient();
74 Properties props = new Properties();
75
76
77 props.setProperty(WSHandlerConstants.USER, "myBadAlias");
78
79 UMOMessage m = null;
80 try
81 {
82 m = client.send("vm://testin2", "Test", props);
83 }
84 catch (Exception e)
85 {
86 assertNotNull(e);
87 }
88 assertNull(m);
89 }
90
91 public void testSignedSoapMessage () throws Exception
92 {
93 MuleClient client = new MuleClient();
94 Properties props = new Properties();
95
96
97 props.setProperty(WSHandlerConstants.USER, "mulealias");
98
99 UMOMessage m = client.send("vm://testin3", "Test", props);
100 assertNotNull(m);
101 assertTrue(m.getPayload() instanceof String);
102 assertTrue(m.getPayload().equals("Test"));
103 }
104
105 protected String getConfigResources ()
106 {
107 return "wssecurity-mule-config-for-outbound.xml";
108 }
109 }