1   /*
2    * $Id: PlainTextFunctionalTestCase.java 10789 2008-02-12 20:04:43Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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();
29          MuleMessage m = client.send("http://localhost:4567/index.html", "", null);
30          assertNotNull(m);
31          int status = m.getIntProperty(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.getIntProperty(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.getIntProperty(HttpConnector.HTTP_STATUS_PROPERTY, -1);
50          assertEquals(HttpConstants.SC_OK, status);
51      }
52  
53  }