$.SecurityFT.java Source code

Java tutorial

Introduction

Here is the source code for $.SecurityFT.java

Source

    #set($symbol_pound='#')#set($symbol_dollar='$')#set($symbol_escape='\')
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package ${package}.functional.gui;

    import static org.assertj.core.api.Assertions.*;

    import org.junit.Test;
    import org.openqa.selenium.By;
import ${package}.functional.BaseSeleniumTestCase;

    /**
     * , ?.
     * 
     * @author calvin
     */
    public class SecurityFT extends BaseSeleniumTestCase {

        /**
         * ??.
         */
        @Test
        public void anonymousUserAccessSystem() {
            // ?,?
            s.open("/logout");
            s.waitForTitleContains("");

            // ???
            s.open("/task");
            s.waitForTitleContains("");
        }

        /**
         * ??
         */
        @Test
        public void userTryToManageUsers() {
            loginAsUserIfNecessary();
            s.open("/admin/user");
            assertThat(s.getTitle()).isEqualTo("Error 401 Unauthorized");
        }

        /**
         * ???.
         */
        @Test
        public void loginWithWrongPassword() {
            s.open("/logout");
            s.type(By.name("username"), "wrongUser");
            s.type(By.name("password"), "WrongPassword");
            s.check(By.name("rememberMe"));
            s.click(By.id("submit_btn"));

            s.waitForTitleContains("");
            assertThat(s.isTextPresent("?.")).isTrue();
        }
    }