/*
 * Created on 15-Feb-2005
 */
package org.bodington.servlet.facilities;

import org.bodington.server.BuildingServer;
import org.bodington.server.BuildingServerException;
import org.bodington.server.BuildingServerTest;

/**
 * @author buckett
 */
public class UtilsTest extends BuildingServerTest
{

    public void testCheckWebAuthUserGood() throws BuildingServerException
    {
        assertTrue(Utils.checkWebAuthUser("buckett"));
    }
    
    public void testCheckWebAuthUserBad() throws BuildingServerException
    {
        assertFalse(Utils.checkWebAuthUser("noSuchUserHere"));
    }
    
    public void testCheckWebAuthUserHostNotFound() 
    {
        BuildingServer.getInstance().getProperties().setProperty("bodington.webauth.url", "http://nosuchhost/webauth");
        try
        {
            Utils.checkWebAuthUser("noSuchUserHere");
            fail("This should have been a bad URL");
        }
        catch (BuildingServerException e)
        {
          assertTrue(true);
        }
    }
    
    public void testCheckWebAuthUserBadURL()
    {
    BuildingServer.getInstance().getProperties().setProperty("bodington.webauth.url", "this aint going to work");
    try
    {
        Utils.checkWebAuthUser("noSuchUserHere");
        fail("This should have been a bad URL");
    }
    catch (BuildingServerException e)
    {
      assertTrue(true);
    }
}

}
