@@ -0,0 +1,3241 @@
+/*%0A * Licensed to Jasig under one or more contributor license%0A * agreements. See the NOTICE file distributed with this work%0A * for additional information regarding copyright ownership.%0A * Jasig licenses this file to you under the Apache License,%0A * Version 2.0 (the %22License%22); you may not use this file%0A * except in compliance with the License.  You may obtain a%0A * copy of the License at the following location:%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0Apackage org.jasig.cas.adaptors.ldap.lppe.ad;%0A%0Aimport javax.security.auth.login.AccountLockedException;%0Aimport javax.security.auth.login.LoginException;%0A%0Aimport org.jasig.cas.authentication.AccountDisabledException;%0Aimport org.jasig.cas.authentication.AccountPasswordMustChangeException;%0Aimport org.jasig.cas.authentication.InvalidLoginLocationException;%0Aimport org.jasig.cas.authentication.InvalidLoginTimeException;%0Aimport org.junit.Test;%0A%0A/**%0A * Unit test for %7B@link org.jasig.cas.adaptors.ldap.lppe.ad.ActiveDirectoryAccountState%7D.%0A *%0A * @author Misagh Moayyed%0A * @since 4.0%0A */%0Apublic class ActiveDirectoryAccountStateTests %7B%0A%0A    @Test(expected=InvalidLoginTimeException.class)%0A    public void testAccountStateLoginTime() throws LoginException %7B%0A        final ActiveDirectoryAccountState state = new ActiveDirectoryAccountState(%0A                org.ldaptive.auth.ext.ActiveDirectoryAccountState.Error.INVALID_LOGON_HOURS);%0A        state.getError().throwSecurityException();%0A    %7D%0A    %0A    @Test(expected=AccountDisabledException.class)%0A    public void testAccountStateDisabled() throws LoginException %7B%0A        final ActiveDirectoryAccountState state = new ActiveDirectoryAccountState(%0A                org.ldaptive.auth.ext.ActiveDirectoryAccountState.Error.ACCOUNT_DISABLED);%0A        state.getError().throwSecurityException();%0A    %7D%0A    %0A    @Test(expected=InvalidLoginLocationException.class)%0A    public void testAccountStateInvalidLocation() throws LoginException %7B%0A        final ActiveDirectoryAccountState state = new ActiveDirectoryAccountState(%0A                org.ldaptive.auth.ext.ActiveDirectoryAccountState.Error.INVALID_WORKSTATION);%0A        state.getError().throwSecurityException();%0A    %7D%0A    %0A    @Test(expected=AccountPasswordMustChangeException.class)%0A    public void testAccountStatePswMustChange() throws LoginException %7B%0A        final ActiveDirectoryAccountState state = new ActiveDirectoryAccountState(%0A                org.ldaptive.auth.ext.ActiveDirectoryAccountState.Error.PASSWORD_MUST_CHANGE);%0A        state.getError().throwSecurityException();%0A    %7D%0A    %0A    @Test(expected=AccountLockedException.class)%0A    public void testAccountStateNormalException() throws LoginException %7B%0A        final ActiveDirectoryAccountState state = new ActiveDirectoryAccountState(%0A                org.ldaptive.auth.ext.ActiveDirectoryAccountState.Error.ACCOUNT_LOCKED_OUT);%0A        state.getError().throwSecurityException();%0A    %7D%0A%7D%0A

Test case for account state detection in AD