Update Auth E2E tests

This commit is contained in:
Bubka 2022-08-07 19:36:23 +02:00
parent 5800308e93
commit 18f70ec843
13 changed files with 301 additions and 54 deletions

View File

@ -5,8 +5,8 @@ Library SeleniumLibrary
Resource ../common.resource
*** Variables ***
&{ACCOUNTS_PAGE} url=http://${SERVER}/accounts title=Accounts
${ACCOUNTS PAGE URL} http://${SERVER}/accounts
*** Keywords ***
Accounts Page Should Be Open
Page Should Be Open ${ACCOUNTS_PAGE}
Location Should Be ${ACCOUNTS PAGE URL}

View File

@ -5,7 +5,7 @@ Library SeleniumLibrary
Resource ../common.resource
*** Variables ***
&{LOGIN_PAGE} url=http://${SERVER}/login title=Login
${LOGIN PAGE URL} http://${SERVER}/login
${EMAIL FIELD} emlEmail
${EMAIL FIELD ERROR} valErrorEmail
${PASSWORD FIELD} pwdPassword
@ -17,19 +17,24 @@ ${SIGN IN WITH WEBAUTHN LINK} lnkSignWithWebauthn
${SIGN IN WITH LOGIN PASSWORD LINK} lnkSignWithLegacy
${RECOVER YOUR ACCOUNT LINK} lnkRecoverAccount
${RESET PASSWORD LINK} lnkResetPwd
${PUNCHLINE TEXT} punchline
*** Keywords ***
Open Browser To Legacy Login Page
Open Browser To Page ${LOGIN_PAGE}
Show Legacy Form
Go To Legacy Login Page
Go To Page ${LOGIN_PAGE}
Go To ${LOGIN PAGE URL}
Show Legacy Form
Go To Webauthn Login Page
Go To ${LOGIN PAGE URL}
Show Webauthn Form
Login Page Should Be Open
Location Should Be ${LOGIN PAGE URL}
Submit Credentials To Legacy Form Login
[Arguments] ${username} ${password}
Input Text ${EMAIL FIELD} ${username}
[Arguments] ${email} ${password}
Input Text ${EMAIL FIELD} ${email}
Input Text ${PASSWORD FIELD} ${password}
Click Button ${SIGN IN BUTTON}
@ -48,3 +53,6 @@ Show Webauthn Form
${is_not_visible}= Run Keyword And Return Status Element Should Be Visible ${SIGN IN WITH WEBAUTHN LINK}
Run Keyword If ${is_not_visible} Click Link ${SIGN IN WITH WEBAUTHN LINK}
Element Should Not Be Visible ${LEGACY FORM}
User Should Be Welcomed
Element Should Contain ${PUNCHLINE TEXT} ${USERNAME}

View File

@ -0,0 +1,46 @@
*** Settings ***
Documentation A page object to use in Registration tests.
...
Library SeleniumLibrary
Resource ../common.resource
*** Variables ***
${REGISTER PAGE URL} http://${SERVER}/register
${USERNAME FIELD} txtName
${USERNAME FIELD ERROR} valErrorName
${EMAIL FIELD} emlEmail
${EMAIL FIELD ERROR} valErrorEmail
${PASSWORD FIELD} pwdPassword
${PASSWORD FIELD ERROR} valErrorPassword
${PASSWORD CONFIRMATION FIELD} pwdPassword_confirmation
${REGISTER BUTTON} btnRegister
${REGISTER NEW DEVICE BUTTON} btnRegisterNewDevice
${MAYBE LATER BUTTON} btnMaybeLater
${SIGN IN LINK} lnkSignIn
*** Keywords ***
Go To Register Page
Go To ${REGISTER PAGE URL}
Register Page Should Be Open
Location Should Be ${REGISTER PAGE URL}
Submit Account Data To Registration Form
[Arguments] ${username} ${email} ${password} ${password confirmation}
Input Text ${USERNAME FIELD} ${username}
Input Text ${EMAIL FIELD} ${email}
Input Text ${PASSWORD FIELD} ${password}
Input Text ${PASSWORD CONFIRMATION FIELD} ${password confirmation}
Click Button ${REGISTER BUTTON}
Username Field Should Show An Error
Field Should Show An Error ${USERNAME FIELD ERROR}
Email Field Should Show An Error
Field Should Show An Error ${EMAIL FIELD ERROR}
Password Field Should Show An Error
Field Should Show An Error ${PASSWORD FIELD ERROR}
Postpone Webauthn Registration
Click Element ${MAYBE LATER BUTTON}

View File

@ -0,0 +1,24 @@
*** Settings ***
Documentation A page object to use in Account settings tests.
...
Library SeleniumLibrary
Resource ../common.resource
Resource login_page.robot
*** Variables ***
${ACCOUNT SETTINGS PAGE URL} http://${SERVER}/settings/account
${PASSWORD FIELD FOR DELETE} css:form#frmDeleteAccount >> css:input#pwdPassword
${DELETE YOUR ACCOUNT BUTTON} btnDeleteAccount
*** Keywords ***
Account Settings Page Should Be Open
Location Should Be ${ACCOUNT SETTINGS PAGE URL}
Go To Account Settings Page
Go Authenticated To ${ACCOUNT SETTINGS PAGE URL}
Delete User Account
Input Text ${PASSWORD FIELD FOR DELETE} ${PASSWORD}
Click Button ${DELETE YOUR ACCOUNT BUTTON}
Handle Alert

View File

@ -1,9 +1,14 @@
*** Settings ***
Documentation A resource file for authentication tests.
...
Library SeleniumLibrary
Resource ../../common.resource
*** Variables ***
${VALID USER} testing@2fauth.app
${VALID PASSWORD} password
${VALID EMAIL CASED} TESTING@2fauth.app
${VALID PASSWORD CONFIRMATION} password
${INVALID USERNAME TOO LONG} veryLongUsernameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
${INVALID EMAIL MALFORMED} emailWithNoAt
${INVALID EMAIL DOES NOT EXIST} missing.user@example.com
${INVALID EMAIL TOO LONG} veryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddressveryLongEmailAddress@verylongdomain.com
${INVALID PASSWORD} notTheGoodPassword
${INVALID PASSWORD TOO SHORT} pwd

View File

@ -1,20 +1,25 @@
*** Settings ***
Documentation A test suite containing tests related to the login page links.
Suite Setup Open Browser To Legacy Login Page
Documentation A test suite to check available links on the login page.
Suite Setup Suite Setup
Suite Teardown Close Browser
Resource ../../Pages/login_page.robot
*** Test Cases ***
Reset Link
Reset Link Is Visible
Element Should Be Visible ${RESET PASSWORD LINK}
Webauthn login Link
Webauthn login Link Is Visible
Element Should Be Visible ${SIGN IN WITH WEBAUTHN LINK}
Legacy login Link
Legacy login Link Is Visible
Show Webauthn Form
Element Should Be Visible ${SIGN IN WITH LOGIN PASSWORD LINK}
Recover Account Link
Recover Account Link Is Visible
Show Webauthn Form
Element Should Be Visible ${RECOVER YOUR ACCOUNT LINK}
Element Should Be Visible ${RECOVER YOUR ACCOUNT LINK}
*** Keywords ***
Suite Setup
Open Blank Browser
Go To Legacy Login Page

View File

@ -1,31 +1,36 @@
*** Settings ***
Documentation A test suite containing tests related to invalid login.
Suite Setup Open Browser To Legacy Login Page
Suite Setup Open Blank Browser
Suite Teardown Close Browser
Test Setup Go To Legacy Login Page
Test Setup Run keywords
... Go To Legacy Login Page
... AND Location Should Be ${LOGIN PAGE URL}
Resource ../../Pages/login_page.robot
Resource authentication.resource
*** Test Cases ***
Invalid Email
[Template] Login With Invalid Email Should Fail
${EMPTY} ${VALID PASSWORD}
invalid ${VALID PASSWORD}
email@donot.exist ${VALID PASSWORD}
${EMPTY} ${PASSWORD}
${INVALID EMAIL MALFORMED} ${PASSWORD}
${INVALID EMAIL DOES NOT EXIST} ${PASSWORD}
Missing Password
Submit Credentials To Legacy Form Login ${VALID USER} ${EMPTY}
Location Should Be ${LOGIN_PAGE.url}
Password Field Should Show An Error
Submit Credentials To Legacy Form Login ${EMAIL} ${EMPTY}
Page Should Remain Login Page
login_page.Password Field Should Show An Error
Invalid Password
Submit Credentials To Legacy Form Login ${VALID USER} invalid
Location Should Be ${LOGIN_PAGE.url}
An Error should be notified
Submit Credentials To Legacy Form Login ${EMAIL} ${INVALID PASSWORD}
Page Should Remain Login Page
An Error Notification Should Appear
*** Keywords ***
Login With Invalid Email Should Fail
[Arguments] ${username} ${password}
Submit Credentials To Legacy Form Login ${username} ${password}
Location Should Be ${LOGIN_PAGE.url}
Email Field Should Show An Error
[Arguments] ${email} ${password}
Submit Credentials To Legacy Form Login ${email} ${password}
Location Should Be ${LOGIN PAGE URL}
login_page.Email Field Should Show An Error
Page Should Remain Login Page
Location Should Be ${LOGIN PAGE URL}

View File

@ -0,0 +1,66 @@
*** Settings ***
Documentation A test suite containing tests related to invalid registration.
Suite Setup Suite Setup
Suite Teardown Suite Teardown
Resource ../../Pages/register_page.robot
Resource ../../Pages/accounts_page.robot
Resource authentication.resource
*** Test Cases ***
Invalid Email
[Template] Registering With Invalid Email Should Fail
${EMPTY}
${INVALID EMAIL MALFORMED}
${INVALID EMAIL TOO LONG}
Invalid Username
[Template] Registering With Invalid Username Should Fail
${EMPTY}
${INVALID USERNAME TOO LONG}
Invalid Password
[Template] Registering With Invalid Passwords Should Fail
${EMPTY} ${EMPTY}
${PASSWORD} ${EMPTY}
${PASSWORD} ${INVALID PASSWORD}
${INVALID PASSWORD TOO SHORT} ${INVALID PASSWORD TOO SHORT}
A User Already Exists
Submit Account Data To Registration Form ${USERNAME} ${EMAIL} ${PASSWORD} ${PASSWORD}
An Error Notification Should Appear
*** Keywords ***
Registering With Invalid Username Should Fail
[Arguments] ${bad username}
Submit Account Data To Registration Form ${bad username} ${EMAIL} ${PASSWORD} ${PASSWORD}
Page Should Remain Register Page
Username Field Should Show An Error
Registering With Invalid Email Should Fail
[Arguments] ${bad email}
Submit Account Data To Registration Form ${USERNAME} ${bad email} ${PASSWORD} ${PASSWORD}
Page Should Remain Register Page
register_page.Email Field Should Show An Error
Registering With Invalid Passwords Should Fail
[Arguments] ${bad password} ${bad password confirmation}
Submit Account Data To Registration Form ${USERNAME} ${EMAIL} ${bad password} ${bad password confirmation}
Page Should Remain Register Page
register_page.Password Field Should Show An Error
User should be asked To Register A Webauthn Device
Page Should Contain Element ${REGISTER NEW DEVICE BUTTON}
Page Should Contain Element ${MAYBE LATER BUTTON}
Page Should Remain Register Page
Location Should Be ${REGISTER PAGE URL}
Suite Setup
Open Blank Browser
Play Delete User Account Workflow
Go To Register Page
Location Should Be ${REGISTER PAGE URL}
Suite Teardown
Close Browser
Play Register New User Workflow

View File

@ -1,12 +1,17 @@
*** Settings ***
Documentation A test suite containing tests related to valid login.
Suite Setup Open Browser To Legacy Login Page
Suite Setup Open Blank Browser
Suite Teardown Close Browser
Resource ../../Pages/login_page.robot
Resource ../../Pages/accounts_page.robot
Resource authentication.resource
Resource invalid_registration.robot
*** Test Cases ***
Valid Login
Submit Credentials To Legacy Form Login ${VALID USER} ${VALID PASSWORD}
Accounts Page Should Be Open
Delete All Cookies
Go To Legacy Login Page
Login Page Should Be Open
User Should Be Welcomed
Submit Credentials To Legacy Form Login ${EMAIL} ${PASSWORD}

View File

@ -0,0 +1,21 @@
*** Settings ***
Documentation A test suite containing tests related to valid registration.
Suite Setup Open Blank Browser
Suite Teardown Close Browser
Resource ../../Pages/register_page.robot
Resource ../../Pages/accounts_page.robot
Resource authentication.resource
*** Test Cases ***
Valid Registration Without Webauthn Device
Play Delete User Account Workflow
Go To Register Page
Register Page Should Be Open
Submit Account Data To Registration Form ${USERNAME} ${EMAIL} ${PASSWORD} ${PASSWORD}
User Should Be Asked To Register A Webauthn Device Or Postpone
Postpone Webauthn Registration
*** Keywords ***
User Should Be Asked To Register A Webauthn Device Or Postpone
Page Should Contain Element ${REGISTER NEW DEVICE BUTTON}
Page Should Contain Element ${MAYBE LATER BUTTON}

View File

@ -1,34 +1,46 @@
*** Settings ***
Documentation A resource file with reusable keywords and variables.
Library SeleniumLibrary
# Library RequestsLibrary
Resource workflows.resource
*** Variables ***
${SERVER} localhost
${BROWSER} chrome
${DELAY} 0.1
${USERNAME} Tester
${EMAIL} testing@2fauth.app
${PASSWORD} password
${HOME PAGE URL} http://${SERVER}/
${LOGOUT LINK} lnkSignOut
*** Keywords ***
Open Browser To Page
[Arguments] ${page}
Open Blank Browser
Set Selenium Speed ${DELAY}
Open Browser ${page.url} ${BROWSER}
Page Should Be Open ${page}
# ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
# Call Method ${options} add_argument --lang\=en,en-us
# Call Method ${options} add_argument --disable-dev-shm-usage # See https://stackoverflow.com/questions/50642308/org-openqa-selenium-webdriverexception-unknown-error-devtoolsactiveport-file-d
# ${prefs}= Create Dictionary intl.accept_languages=en,en-us
# Call Method ${options} add_experimental_option prefs ${prefs}
# Create Webdriver Chrome chrome_options=${options}
# Go To ${HOME PAGE URL}
Open Browser ${HOME PAGE URL} Chrome
An Error should be notified
Element Should Be Visible id:vueNotification >> class:is-danger
Go Authenticated To
[Arguments] ${url}
Go To ${url}
${is_authenticated}= Run Keyword And Return Status Location Should Be ${url}
IF ${is_authenticated} == False
Play sign In Workflow
Go To ${url}
END
Go To Page
[Arguments] ${page}
Go To ${page.url}
Page Should Be Open ${page}
Page Should Be Open
[Arguments] ${page}
Location Should Be ${page.url}
Title Should Be ${page.title}
An Error Notification Should Appear
Element Should Be Visible css:#vueNotification >> css:.is-danger
Field Should Show An Error
[Arguments] ${field error}
Element Should Be Visible ${field error}
Should Not Be Empty ${field error}
Should Not Be Empty ${field error}

13
tests/EndToEnd/temp.robot Normal file
View File

@ -0,0 +1,13 @@
*** Settings ***
Documentation A test suite to check available links on the login page.
Suite Setup Open Blank Browser
# Suite Teardown Close Browser
Resource Pages/login_page.robot
Resource workflows.resource
*** Variables ***
${HOME PAGE URL} http://${SERVER}/
*** Test Cases ***
My Test
Play Delete User Account Workflow

View File

@ -0,0 +1,37 @@
*** Settings ***
Documentation Workflows execute recurrent tasks.
... They don't assert anything.
... They must be triggered while a browser is already opened.
... They must not close the browser
Library SeleniumLibrary
Resource common.resource
Resource Pages/login_page.robot
Resource Pages/register_page.robot
Resource Pages/accounts_page.robot
Resource Pages/settings_account_page.robot
*** Variables ***
*** Keywords ***
Play Delete User Account Workflow
Go To Account Settings Page
Delete User Account
Play sign In Workflow
Delete All Cookies
Go To Legacy Login Page
Login Page Should Be Open
Submit Credentials To Legacy Form Login ${EMAIL} ${PASSWORD}
Play Register New User Workflow
Go To Register Page
Submit Account Data To Registration Form ${USERNAME} ${EMAIL} ${PASSWORD} ${PASSWORD}
Play Logout Workflow
Go To http://${SERVER}/accounts
${is_authenticated}= Run Keyword And Return Status Page Should Contain Element ${LOGOUT LINK}
IF ${is_authenticated} == True
Click Element ${LOGOUT LINK}
Handle Alert
END