001    /**
002     * Copyright 2005-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package edu.sampleu;
017    
018    import org.junit.Test;
019    import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020    import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021    import org.kuali.rice.testtools.selenium.WebDriverUtils;
022    
023    /**
024     * @author Kuali Rice Team (rice.collab@kuali.org)
025     */
026    public class LoginInvalidUserAft extends WebDriverLegacyITBase {
027    
028        @Override
029        protected String getBookmarkUrl() {
030            return AutomatedFunctionalTestUtils.PORTAL;
031        }
032    
033        @Override
034        protected void navigate() throws Exception {
035            // no-op should not need to navigate for invalid login test
036        }
037    
038        @Override
039        public void testSetUp()  {
040            System.setProperty(WebDriverUtils.REMOTE_AUTOLOGIN_PROPERTY, "false"); // turn off auto login so we can test invalid login
041            super.testSetUp();
042        }
043    
044        @Test(expected = AssertionError.class)
045        public void testAdStarUserNameBookmark() throws InterruptedException {
046            System.setProperty(WebDriverUtils.REMOTE_AUTOLOGIN_PROPERTY, "true");
047            loginKradOrKns(driver, "ad*", this);
048            waitForElementVisibleById("Rice-LoginButton", "ad* should not be a valid login");
049            passed();
050        }
051    
052        /**
053         * Invalid user name test
054         * @throws InterruptedException
055         */
056        @Test
057        public void testInvalidUserNameBookmark() throws InterruptedException {
058            try {
059                System.setProperty(WebDriverUtils.REMOTE_AUTOLOGIN_PROPERTY, "true");
060                loginKradOrKns(driver, AutomatedFunctionalTestUtils.DTS_TWO, this);
061                fail("Expected Invalid Login exception with user " + AutomatedFunctionalTestUtils.DTS_TWO);
062            } catch (AssertionError e) {
063                assertTrue(e.getMessage().contains("Invalid"));
064                passed();
065            }
066        }
067    }