From 43d7922732f58f3318c50c9a5f33d19e0d23b3e2 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:34:28 +0200 Subject: [PATCH] Complete e2e tests for search and account creation --- .../EndToEnd/Pages/account_create_page.robot | 95 +++++++++++++++- tests/EndToEnd/Pages/account_edit_page.robot | 4 +- .../Pages/account_show_qrcode_page.robot | 4 +- tests/EndToEnd/Pages/accounts_page.robot | 25 ++++- .../Tests/TwoFAccounts/display_options.robot | 4 +- .../EndToEnd/Tests/TwoFAccounts/search.robot | 102 ++++++++++++++++++ tests/EndToEnd/common.resource | 7 +- tests/EndToEnd/workflows.resource | 2 +- 8 files changed, 227 insertions(+), 16 deletions(-) create mode 100644 tests/EndToEnd/Tests/TwoFAccounts/search.robot diff --git a/tests/EndToEnd/Pages/account_create_page.robot b/tests/EndToEnd/Pages/account_create_page.robot index 3882f5f0..d12b85e9 100644 --- a/tests/EndToEnd/Pages/account_create_page.robot +++ b/tests/EndToEnd/Pages/account_create_page.robot @@ -7,9 +7,100 @@ Resource ../common.resource *** Variables *** ${CREATE ACCOUNT PAGE URL} ${ROOT URL}/account/create +${SERVICE FIELD} txtService +${ACCOUNT FIELD} txtAccount +${SECRET FIELD} txtSecret +${PERIOD FIELD} txtPeriod +${COUNTER FIELD} txtCounter +${TOTP TOGGLE BUTTON} btnOtp_typetotp +${HOTP TOGGLE BUTTON} btnOtp_typehotp +${STEAM TOGGLE BUTTON} btnOtp_typesteamtotp +${DIGITS BUTTON PREFIX} btnDigits +${6 DIGITS BUTTON} btnDigits6 +${7 DIGITS BUTTON} btnDigits7 +${8 DIGITS BUTTON} btnDigits8 +${9 DIGITS BUTTON} btnDigits9 +${10 DIGITS BUTTON} btnDigits10 +${ALGORITHM BUTTON PREFIX} btnAlgorithm +${SHA1} sha1 +${SHA256} sha256 +${SHA512} sha512 +${SMD5} md5 +${CREATE BUTTON} btnCreate +${PREVIEW BUTTON} btnPreview + *** Keywords *** -Create Account Page Should Be Open +Create TwoFAccount Page Should Be Open Location Should Be ${CREATE ACCOUNT PAGE URL} -Go To Create Account Page +Go To Create TwoFAccount Page Go Authenticated To ${CREATE ACCOUNT PAGE URL} + Set Footer As Static + +Create TOTP TwoFAccount + [Arguments] ${service} ${account} ${secret}=XXXXXXXX ${digits}=6 ${algorithm}=${SHA1} ${period}=30 + Go To Create TwoFAccount Page + Select TOTP Type + Fill Period Field ${period} + Create OTP TwoFAccount ${service} ${account} ${secret} ${digits} ${algorithm} + &{otp data} = Create Dictionary type=TOTP service=${service} account=${account} secret=${secret} digits=${digits} algorithm=${algorithm} period=${period} + RETURN &{otp data} + +Create HOTP TwoFAccount + [Arguments] ${service} ${account} ${secret}=XXXXXXXX ${digits}=6 ${algorithm}=${SHA1} ${counter}=1 + Go To Create TwoFAccount Page + Select HOTP Type + Fill Counter Field ${counter} + Create OTP TwoFAccount ${service} ${account} ${secret} ${digits} ${algorithm} + &{otp data} = Create Dictionary type=HOTP service=${service} account=${account} secret=${secret} digits=${digits} algorithm=${algorithm} period=${counter} + RETURN &{otp data} + +Create OTP TwoFAccount + [Arguments] ${service} ${account} ${secret}=XXXXXXXX ${digits}=6 ${algorithm}=${SHA1} + Fill Service Field ${service} + Fill Account Field ${account} + Fill Secret Field ${secret} + Set Digits To ${digits} + Set Algorithm To ${algorithm} + Click Element ${CREATE BUTTON} + Wait Until Location Is ${ACCOUNTS PAGE URL} 10s + +*** Keywords *** +Fill Service Field + [Arguments] ${service} + Input Text ${SERVICE FIELD} ${service} + +Fill Account Field + [Arguments] ${account} + Input Text ${ACCOUNT FIELD} ${account} + +Select TOTP Type + Click Element ${TOTP TOGGLE BUTTON} + +Select HOTP Type + Click Element ${HOTP TOGGLE BUTTON} + +Select STEAM Type + Click Element ${STEAM TOGGLE BUTTON} + +Fill Secret Field + [Arguments] ${secret} + Input Text ${SECRET FIELD} ${secret} + +Fill Period Field + Wait Until Page Contains Element ${PERIOD FIELD} + [Arguments] ${period}=30 + Input Text ${PERIOD FIELD} ${period} + +Fill Counter Field + Wait Until Page Contains Element ${COUNTER FIELD} + [Arguments] ${counter}=1 + Input Text ${COUNTER FIELD} ${counter} + +Set Digits To + [Arguments] ${digits} + Click Element ${DIGITS BUTTON PREFIX}${digits} + +Set Algorithm To + [Arguments] ${algorithm} + Click Element ${ALGORITHM BUTTON PREFIX}${algorithm} \ No newline at end of file diff --git a/tests/EndToEnd/Pages/account_edit_page.robot b/tests/EndToEnd/Pages/account_edit_page.robot index 998e4a00..fdc5e1a5 100644 --- a/tests/EndToEnd/Pages/account_edit_page.robot +++ b/tests/EndToEnd/Pages/account_edit_page.robot @@ -8,10 +8,10 @@ Resource ../common.resource ${EDIT ACCOUNT PAGE URL} ${ROOT URL}/account/1/edit *** Keywords *** -Edit Page Should Be Open For Account +Edit Page Should Be Open For TwoFAccount [Arguments] ${account id} Location Should Be ${ROOT URL}/account/${account id}/edit -Go To Edit Page For Account +Go To Edit Page For TwoFAccount [Arguments] ${account id} Go Authenticated To ${ROOT URL}/account/${account id}/edit diff --git a/tests/EndToEnd/Pages/account_show_qrcode_page.robot b/tests/EndToEnd/Pages/account_show_qrcode_page.robot index 666208fc..35249c69 100644 --- a/tests/EndToEnd/Pages/account_show_qrcode_page.robot +++ b/tests/EndToEnd/Pages/account_show_qrcode_page.robot @@ -8,8 +8,8 @@ Resource ../common.resource ${SHOW ACCOUNT QRCODE PAGE URL} ${ROOT URL}/account/1/qrcode *** Keywords *** -Show Account Qrcode Page Should Be Open +Show TwoFAccount Qrcode Page Should Be Open Location Should Be ${SHOW ACCOUNT QRCODE PAGE URL} -Go To Show Account Qrcode Page +Go To Show TwoFAccount Qrcode Page Go Authenticated To ${SHOW ACCOUNT QRCODE PAGE URL} \ No newline at end of file diff --git a/tests/EndToEnd/Pages/accounts_page.robot b/tests/EndToEnd/Pages/accounts_page.robot index cce3e822..8162033e 100644 --- a/tests/EndToEnd/Pages/accounts_page.robot +++ b/tests/EndToEnd/Pages/accounts_page.robot @@ -2,7 +2,8 @@ Documentation A page object to use in Accounts tests. ... Library SeleniumLibrary -Library Collections +Library Collections +Resource start_page.robot Resource ../common.resource *** Variables *** @@ -12,12 +13,18 @@ ${GROUP SWITCH} groupSwitch ${SEARCH FIELD} txtSearch ${GRID CLASS} tfa-grid ${LIST CLASS} tfa-list -${ACCOUNTS CONTAINER} .accounts > span +${ACCOUNTS CONTAINER} css:.accounts > span ${2FA ACCOUNT} class:tfa-cell ${MODAL OTP} class:modal-otp ${ALWAYS ON OTP} class:always-on-otp ${SHOW GROUP SWITCH BUTTON} btnShowGroupSwitch ${HIDE GROUP SWITCH BUTTON} btnHideGroupSwitch +${MANAGE BUTTON} btnManage +${SELECT ALL BUTTON} btnSelectAll +${UNSELECT ALL BUTTON} btnUnselectAll +${MOVE BUTTON} btnMove +${DELETE BUTTON} btnDelete +${EXPORT BUTTON} btnExport *** Keywords *** Go To Accounts Page @@ -32,9 +39,10 @@ Show An Otp In Modal Click Element ${account} Wait Until Element Is Visible ${OTP} -Get TwoFAccounts Elements +Get Visible TwoFAccounts Elements + Wait Until Page Contains Element ${ACCOUNTS CONTAINER} @{twofaccounts} = Get WebElements ${ACCOUNTS CONTAINER} > div - [return] ${twofaccounts} + [return] @{twofaccounts} Get OTP Value Shown In Modal ${string}= Get Text ${OTP} @@ -97,3 +105,12 @@ Close Modal Otp Run Keyword If ${modal is open} Click Element ${CLOSE BUTTON} Wait Until Element Is Not Visible ${MODAL OTP} +Delete All TwoFAccounts + Wait Until Page Contains Element ${MANAGE BUTTON} + Click Element ${MANAGE BUTTON} + Wait Until Page Contains Element ${SELECT ALL BUTTON} + Click Element ${SELECT ALL BUTTON} + Wait Until Element Is Enabled ${DELETE BUTTON} + Click Element ${DELETE BUTTON} + Handle Alert + Wait Until Location Is ${START PAGE URL} \ No newline at end of file diff --git a/tests/EndToEnd/Tests/TwoFAccounts/display_options.robot b/tests/EndToEnd/Tests/TwoFAccounts/display_options.robot index 5e4a72d4..ed1aa0a1 100644 --- a/tests/EndToEnd/Tests/TwoFAccounts/display_options.robot +++ b/tests/EndToEnd/Tests/TwoFAccounts/display_options.robot @@ -13,14 +13,14 @@ Resource ../../common.resource *** Test Cases *** Grid Mode Should Display TwoFAccounts In Grid Run Set Option Keyword And Come Back Set Option Display Mode To Grid - @{twofaccounts} = Get TwoFAccounts Elements + @{twofaccounts} = Get Visible TwoFAccounts Elements FOR ${twofaccount} IN @{twofaccounts} Element Should Have Class ${twofaccount} ${GRID CLASS} END List Mode Should Display TwoFAccounts In List Run Set Option Keyword And Come Back Set Option Display Mode To Grid - @{twofaccounts} = Get TwoFAccounts Elements + @{twofaccounts} = Get Visible TwoFAccounts Elements FOR ${twofaccount} IN @{twofaccounts} Element Should Have Class ${twofaccount} ${LIST CLASS} END diff --git a/tests/EndToEnd/Tests/TwoFAccounts/search.robot b/tests/EndToEnd/Tests/TwoFAccounts/search.robot new file mode 100644 index 00000000..045ef602 --- /dev/null +++ b/tests/EndToEnd/Tests/TwoFAccounts/search.robot @@ -0,0 +1,102 @@ +*** Settings *** +Documentation A test suite containing tests related to 2FAccounts search. +Suite Setup Run Keywords +... Open Custom Browser +... AND Play Admin Sign In Workflow +Suite Teardown Close All Browsers +Test Setup Set Up For Search +Resource ../../Pages/account_create_page.robot +Resource ../../Pages/accounts_page.robot +Resource ../../common.resource +Library String + +*** Variables *** +${CLEAR SEARCH BUTTON} btnClearSearch + +*** Test Cases *** + +Search Field Should Be Empty By Default + Search Field Should Be Empty + +Search Field Should Show Close Button When Filled + Input Text ${SEARCH FIELD} lorem ipsum + Wait Until Page Contains Element ${CLEAR SEARCH BUTTON} + +Clear Search Button Should Clear Search + Input Text ${SEARCH FIELD} lorem ipsum + Wait Until Page Contains Element ${CLEAR SEARCH BUTTON} + Click Element ${CLEAR SEARCH BUTTON} + Search Field Should Be Empty + +Clearing Search Field Should Hide Clear Search Button + Input Text ${SEARCH FIELD} lorem ipsum + Wait Until Page Contains Element ${CLEAR SEARCH BUTTON} + Press Keys ${SEARCH FIELD} CTRL+a + Press Keys None DELETE + Page Should Not Contain Element ${CLEAR SEARCH BUTTON} + +Search Should Show Exact Match On Service + ${service} = Generate Random String 10 [LETTERS] + ${account} = Generate Random String 10 [LETTERS] + &{TOTP} = Create TOTP TwoFAccount ${service} ${account} + Search Should Show Matching Results ${TOTP.service} 1 True + Search Should Show Matching Results ${TOTP.service} 1 False + +Search Should Show Exact Match On Account + ${service} = Generate Random String 10 [LETTERS] + ${account} = Generate Random String 10 [LETTERS] + &{TOTP} = Create TOTP TwoFAccount ${service} ${account} + Search Should Show Matching Results ${TOTP.account} 1 True + Search Should Show Matching Results ${TOTP.account} 1 False + +Search Should Show Partial Match On Service + ${partial_service} = Generate Random String 10 [LETTERS] + ${partial_account} = Generate Random String 10 [LETTERS] + ${service a} = Set Variable xx_${partial_service}__xx + ${account a} = Set Variable xxx_${partial_account}__xxx + &{TOTP} = Create TOTP TwoFAccount ${service a} ${account a} + ${service b} = Set Variable yy_${partial_service}__yyy + ${account b} = Set Variable yyy_${partial_account}__yyy + &{TOTP} = Create TOTP TwoFAccount ${service b} ${account b} + Search Should Show Matching Results ${partial_service} 2 True + Search Should Show Matching Results ${partial_service} 2 False + +Search Should Show Partial Match On Account + ${partial_service} = Generate Random String 10 [LETTERS] + ${partial_account} = Generate Random String 10 [LETTERS] + ${service a} = Set Variable xx_${partial_service}__xx + ${account a} = Set Variable xxx_${partial_account}__xxx + &{TOTP} = Create TOTP TwoFAccount ${service a} ${account a} + ${service b} = Set Variable yy_${partial_service}__yyy + ${account b} = Set Variable yyy_${partial_account}__yyy + &{TOTP} = Create TOTP TwoFAccount ${service b} ${account b} + Search Should Show Matching Results ${partial_account} 2 True + Search Should Show Matching Results ${partial_account} 2 False + +*** Keywords *** +Search Field Should Be Empty + ${search} = Get Value ${SEARCH FIELD} + Should Be Empty ${search} + +Search Should Show Matching Results + [Arguments] ${searched value} ${expected results number}=1 ${ignore_case}=False + Wait Until Page Contains Element ${SEARCH FIELD} + Input Text ${SEARCH FIELD} ${searched value} + Search Results Number Should Equal ${expected results number} + @{twofaccounts} = Get Visible TwoFAccounts Elements + FOR ${twofaccount} IN @{twofaccounts} + Element Should Contain ${twofaccount} ${searched value} None ${ignore_case} + END + +Search Results Number Should Equal + [Arguments] ${expected results number} + ${result count} = Get Element Count ${2FA ACCOUNT} + Should Be Equal As Integers ${result count} ${expected results number} + +Set Up For Search + Go To Accounts Page + ${twofaccount number} = Get Element Count ${2FA ACCOUNT} + IF ${twofaccount number} == 0 + Create TOTP TwoFAccount lorem ipsum + END + Wait Until Page Contains Element ${SEARCH FIELD} \ No newline at end of file diff --git a/tests/EndToEnd/common.resource b/tests/EndToEnd/common.resource index 4a28b455..13063ba9 100644 --- a/tests/EndToEnd/common.resource +++ b/tests/EndToEnd/common.resource @@ -43,12 +43,13 @@ Open Custom Browser Go Authenticated To [Arguments] ${url} Go To ${url} - ${is_authenticated}= Run Keyword And Return Status Location Should Be ${url} - IF ${is_authenticated} == False + Wait Until Page Contains Element tag:footer + ${is anonymous}= Run Keyword And Return Status Location Should Be ${LOGIN PAGE URL} + IF ${is anonymous} == True Play Admin Sign In Workflow Go To ${url} + Wait Until Page Contains Element tag:footer END - Wait Until Location Is ${url} A Success Notification Should Appear Wait Until Element Is Visible ${SUCCESS NOTIFICATION} diff --git a/tests/EndToEnd/workflows.resource b/tests/EndToEnd/workflows.resource index bb5a91bb..97d44826 100644 --- a/tests/EndToEnd/workflows.resource +++ b/tests/EndToEnd/workflows.resource @@ -24,7 +24,7 @@ Play Admin Sign In Workflow Delete All Cookies Go To Legacy Login Page Submit Credentials To Legacy Form Login ${ADMIN EMAIL} ${PASSWORD} - Wait Until Location Is ${ACCOUNTS PAGE URL} + Wait Until Location Is Not ${LOGIN PAGE URL} Play User Sign In Workflow Play Logout Workflow