2022-08-13 13:00:23 +02:00
|
|
|
package com.commafeed.e2e;
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
|
|
2023-08-23 20:21:45 +02:00
|
|
|
import com.commafeed.CommaFeedDropwizardAppExtension;
|
2022-08-13 13:00:23 +02:00
|
|
|
import com.microsoft.playwright.Locator;
|
|
|
|
|
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
|
|
|
|
|
|
|
|
|
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
|
|
|
|
|
|
|
|
|
|
@ExtendWith(DropwizardExtensionsSupport.class)
|
|
|
|
|
class AuthentificationIT extends PlaywrightTestBase {
|
|
|
|
|
|
2023-08-23 20:21:45 +02:00
|
|
|
private static final CommaFeedDropwizardAppExtension EXT = new CommaFeedDropwizardAppExtension();
|
2022-08-13 13:00:23 +02:00
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void loginFail() {
|
2023-05-04 21:27:02 +02:00
|
|
|
page.navigate(getLoginPageUrl());
|
2022-08-13 13:00:23 +02:00
|
|
|
page.locator("[placeholder='User Name or E-mail']").fill("admin");
|
|
|
|
|
page.locator("[placeholder='Password']").fill("wrong_password");
|
|
|
|
|
page.locator("button:has-text('Log in')").click();
|
|
|
|
|
PlaywrightAssertions.assertThat(page.locator("div[role='alert']")).containsText("wrong username or password");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void loginSuccess() {
|
2023-05-04 21:27:02 +02:00
|
|
|
page.navigate(getLoginPageUrl());
|
2022-08-13 13:00:23 +02:00
|
|
|
PlaywrightTestUtils.login(page);
|
|
|
|
|
PlaywrightAssertions.assertThat(page).hasURL("http://localhost:" + EXT.getLocalPort() + "/#/app/category/all");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void registerFailPasswordTooSimple() {
|
2023-05-04 21:27:02 +02:00
|
|
|
page.navigate(getLoginPageUrl());
|
2022-08-13 13:00:23 +02:00
|
|
|
page.locator("text=Sign up!").click();
|
|
|
|
|
page.locator("[placeholder='User Name']").fill("user");
|
|
|
|
|
page.locator("[placeholder='E-mail address']").fill("user@domain.com");
|
|
|
|
|
page.locator("[placeholder='Password']").fill("pass");
|
|
|
|
|
page.locator("button:has-text('Sign up')").click();
|
|
|
|
|
|
|
|
|
|
Locator alert = page.locator("div[role='alert']");
|
|
|
|
|
PlaywrightAssertions.assertThat(alert).containsText("Password must be 8 or more characters in length.");
|
|
|
|
|
PlaywrightAssertions.assertThat(alert).containsText("Password must contain 1 or more uppercase characters.");
|
|
|
|
|
PlaywrightAssertions.assertThat(alert).containsText("Password must contain 1 or more digit characters.");
|
|
|
|
|
PlaywrightAssertions.assertThat(alert).containsText("Password must contain 1 or more special characters.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void registerSuccess() {
|
2023-05-04 21:27:02 +02:00
|
|
|
page.navigate(getLoginPageUrl());
|
2022-08-13 13:00:23 +02:00
|
|
|
page.locator("text=Sign up!").click();
|
|
|
|
|
page.locator("[placeholder='User Name']").fill("user");
|
|
|
|
|
page.locator("[placeholder='E-mail address']").fill("user@domain.com");
|
|
|
|
|
page.locator("[placeholder='Password']").fill("MyPassword1!");
|
|
|
|
|
page.locator("button:has-text('Sign up')").click();
|
|
|
|
|
PlaywrightAssertions.assertThat(page).hasURL("http://localhost:" + EXT.getLocalPort() + "/#/app/category/all");
|
|
|
|
|
}
|
2023-05-04 21:27:02 +02:00
|
|
|
|
|
|
|
|
private String getLoginPageUrl() {
|
|
|
|
|
return "http://localhost:" + EXT.getLocalPort() + "/#/login";
|
|
|
|
|
}
|
2022-08-13 13:00:23 +02:00
|
|
|
}
|