01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.providers.cas.proxy;
17:
18: import junit.framework.TestCase;
19:
20: import org.acegisecurity.providers.cas.ProxyUntrustedException;
21:
22: import java.util.List;
23: import java.util.Vector;
24:
25: /**
26: * Tests {@link RejectProxyTickets}.
27: *
28: * @author Ben Alex
29: * @version $Id: RejectProxyTicketsTests.java 1496 2006-05-23 13:38:33Z benalex $
30: */
31: public class RejectProxyTicketsTests extends TestCase {
32: //~ Constructors ===================================================================================================
33:
34: public RejectProxyTicketsTests() {
35: super ();
36: }
37:
38: public RejectProxyTicketsTests(String arg0) {
39: super (arg0);
40: }
41:
42: //~ Methods ========================================================================================================
43:
44: public static void main(String[] args) {
45: junit.textui.TestRunner.run(RejectProxyTicketsTests.class);
46: }
47:
48: public final void setUp() throws Exception {
49: super .setUp();
50: }
51:
52: public void testAcceptsIfNoProxiesInTicket() {
53: RejectProxyTickets proxyDecider = new RejectProxyTickets();
54: List proxyList = new Vector(); // no proxies in list
55:
56: proxyDecider.confirmProxyListTrusted(proxyList);
57: assertTrue(true);
58: }
59:
60: public void testDoesNotAcceptNull() {
61: RejectProxyTickets proxyDecider = new RejectProxyTickets();
62:
63: try {
64: proxyDecider.confirmProxyListTrusted(null);
65: fail("Should have thrown IllegalArgumentException");
66: } catch (IllegalArgumentException expected) {
67: assertEquals("proxyList cannot be null", expected
68: .getMessage());
69: }
70: }
71:
72: public void testRejectsIfAnyProxyInList() {
73: RejectProxyTickets proxyDecider = new RejectProxyTickets();
74: List proxyList = new Vector();
75: proxyList
76: .add("https://localhost/webApp/j_acegi_cas_security_check");
77:
78: try {
79: proxyDecider.confirmProxyListTrusted(proxyList);
80: fail("Should have thrown ProxyUntrustedException");
81: } catch (ProxyUntrustedException expected) {
82: assertTrue(true);
83: }
84: }
85: }
|