b04571242c61b48753210d3719d965c9adc329afMark de Reeper * Copyright 2013 ForgeRock AS.
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * The contents of this file are subject to the terms of the Common Development and
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * Distribution License (the License). You may not use this file except in compliance with the
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * specific language governing permission and limitations under the License.
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * When distributing Covered Software, include this CDDL Header Notice in each file and include
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * Header, with the fields enclosed by brackets [] replaced by your own identifying
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * information: "Portions copyright [year] [name of copyright owner]".
b04571242c61b48753210d3719d965c9adc329afMark de Reeperimport com.sun.identity.policy.ConditionDecision;
b04571242c61b48753210d3719d965c9adc329afMark de Reeper * @author mark.dereeper@forgerock.com
b04571242c61b48753210d3719d965c9adc329afMark de Reeperpublic class AuthenticateToRealmConditionTest {
b04571242c61b48753210d3719d965c9adc329afMark de Reeper public void testValidRealm() throws Exception {
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> properties = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper properties.put(AuthenticateToRealmCondition.AUTHENTICATE_TO_REALM, realm);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper AuthenticateToRealmCondition condition = new AuthenticateToRealmCondition();
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Set<String> passedRealm = new HashSet<String>(3);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> env = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper env.put(AuthenticateToRealmCondition.REQUEST_AUTHENTICATED_TO_REALMS, passedRealm);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper ConditionDecision conditionDecision = condition.getConditionDecision(null, env);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper public void testValidMixedCaseRealm() throws Exception {
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> properties = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper properties.put(AuthenticateToRealmCondition.AUTHENTICATE_TO_REALM, realm);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper AuthenticateToRealmCondition condition = new AuthenticateToRealmCondition();
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Set<String> passedRealm = new HashSet<String>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> env = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper env.put(AuthenticateToRealmCondition.REQUEST_AUTHENTICATED_TO_REALMS, passedRealm);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper ConditionDecision conditionDecision = condition.getConditionDecision(null, env);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper public void testValidLowerCaseRealm() throws Exception {
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> properties = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper properties.put(AuthenticateToRealmCondition.AUTHENTICATE_TO_REALM, realm);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper AuthenticateToRealmCondition condition = new AuthenticateToRealmCondition();
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Set<String> passedRealm = new HashSet<String>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> env = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper env.put(AuthenticateToRealmCondition.REQUEST_AUTHENTICATED_TO_REALMS, passedRealm);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper ConditionDecision conditionDecision = condition.getConditionDecision(null, env);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper public void testInValidRealm() throws Exception {
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> properties = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper properties.put(AuthenticateToRealmCondition.AUTHENTICATE_TO_REALM, realm);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper AuthenticateToRealmCondition condition = new AuthenticateToRealmCondition();
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Set<String> passedRealm = new HashSet<String>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper Map<String, Set<String>> env = new HashMap<String, Set<String>>(1);
b04571242c61b48753210d3719d965c9adc329afMark de Reeper env.put(AuthenticateToRealmCondition.REQUEST_AUTHENTICATED_TO_REALMS, passedRealm);