@@ -32,32 +32,31 @@ import sample.pages.LoginPage;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Pool Dolorier
|
||||
*/
|
||||
public class SecurityTests {
|
||||
class SecurityTests {
|
||||
|
||||
private WebDriver driver;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
this.driver = new HtmlUnitDriver();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
this.driver.quit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unauthenticatedUserSentToLogInPage() {
|
||||
void unauthenticatedUserSentToLogInPage() {
|
||||
HomePage homePage = HomePage.go(this.driver);
|
||||
LoginPage loginPage = homePage.unauthenticated();
|
||||
loginPage.assertAt();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void logInViewsHomePage() {
|
||||
void logInViewsHomePage() {
|
||||
LoginPage loginPage = LoginPage.go(this.driver);
|
||||
HomePage homePage = loginPage.login("user", "password");
|
||||
homePage.assertAt();
|
||||
@@ -69,7 +68,7 @@ public class SecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void logOutSuccess() {
|
||||
void logOutSuccess() {
|
||||
LoginPage loginPage = LoginPage.go(this.driver);
|
||||
HomePage homePage = loginPage.login("user", "password");
|
||||
LoginPage successLogoutPage = homePage.logout();
|
||||
@@ -77,7 +76,7 @@ public class SecurityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loggedOutUserSentToLoginPage() {
|
||||
void loggedOutUserSentToLoginPage() {
|
||||
LoginPage loginPage = LoginPage.go(this.driver);
|
||||
HomePage homePage = loginPage.login("user", "password");
|
||||
homePage.logout();
|
||||
@@ -85,4 +84,5 @@ public class SecurityTests {
|
||||
LoginPage backLoginPage = backHomePage.unauthenticated();
|
||||
backLoginPage.assertAt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,6 @@ package sample.pages;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Pool Dolorier
|
||||
*/
|
||||
public abstract class BasePage {
|
||||
@@ -38,4 +37,5 @@ public abstract class BasePage {
|
||||
String baseUrl = "http://localhost:" + System.getProperty("app.port");
|
||||
driver.get(baseUrl + get);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,7 @@ public class HomePage extends BasePage {
|
||||
}
|
||||
|
||||
public LoginPage unauthenticated() {
|
||||
return LoginPage.go(getDriver());
|
||||
return LoginPage.go(getDriver());
|
||||
}
|
||||
|
||||
public void assertAt() {
|
||||
@@ -52,4 +52,5 @@ public class HomePage extends BasePage {
|
||||
this.button.click();
|
||||
return LoginPage.go(getDriver());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,6 +54,7 @@ public class LoginPage extends BasePage {
|
||||
this.username.sendKeys(user);
|
||||
this.password.sendKeys(password);
|
||||
this.button.click();
|
||||
return HomePage.go(getDriver());
|
||||
return HomePage.go(getDriver());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user