1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.acegi;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.tck.FunctionalTestCase;
16 import org.mule.transport.http.HttpConnector;
17 import org.mule.transport.http.HttpConstants;
18
19 public class PlainTextFunctionalTestCase extends FunctionalTestCase
20 {
21 protected String getConfigResources()
22 {
23 return "encryption-test.xml";
24 }
25
26 public void testAuthenticationFailureNoContext() throws Exception
27 {
28 MuleClient client = new MuleClient(muleContext);
29 MuleMessage m = client.send("http://localhost:4567/index.html", "", null);
30 assertNotNull(m);
31 int status = m.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, -1);
32 assertEquals(HttpConstants.SC_UNAUTHORIZED, status);
33 }
34
35 public void testAuthenticationFailureBadCredentials() throws Exception
36 {
37 MuleClient client = new MuleClient("anonX", "anonX");
38 MuleMessage m = client.send("http://localhost:4567/index.html", "", null);
39 assertNotNull(m);
40 int status = m.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, -1);
41 assertEquals(HttpConstants.SC_UNAUTHORIZED, status);
42 }
43
44 public void testAuthenticationAuthorised() throws Exception
45 {
46 MuleClient client = new MuleClient("anon", "anon");
47 MuleMessage m = client.send("http://localhost:4567/index.html", "", null);
48 assertNotNull(m);
49 int status = m.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, -1);
50 assertEquals(HttpConstants.SC_OK, status);
51 }
52
53 }