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 */
016package edu.sampleu;
017
018import org.junit.Test;
019import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021import org.kuali.rice.testtools.selenium.WebDriverUtils;
022
023/**
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026public 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
045    public void testAdStarUserNameBookmark() throws InterruptedException {
046        try {
047            System.setProperty(WebDriverUtils.REMOTE_AUTOLOGIN_PROPERTY, "true");
048            login(driver, "ad*", this);
049            fail("Expected Invalid Login exception with user " + AutomatedFunctionalTestUtils.DTS_TWO);
050        } catch (AssertionError e) {
051            waitForElementVisibleById("Rice-LoginButton", "ad* should not be a valid login");
052            passed();
053        }
054    }
055
056    /**
057     * Invalid user name test
058     * @throws InterruptedException
059     */
060    @Test
061    public void testInvalidUserNameBookmark() throws InterruptedException {
062        try {
063            System.setProperty(WebDriverUtils.REMOTE_AUTOLOGIN_PROPERTY, "true");
064            login(driver, AutomatedFunctionalTestUtils.DTS_TWO, this);
065            fail("Expected Invalid Login exception with user " + AutomatedFunctionalTestUtils.DTS_TWO);
066        } catch (AssertionError e) {
067            assertTrue(e.getMessage().contains("Invalid"));
068            passed();
069        }
070    }
071}