Test password strength (#203)

This commit is contained in:
Valentina1133 2023-10-25 13:43:06 +02:00 committed by GitHub
parent 7c02011373
commit 2da105f727
5 changed files with 117 additions and 0 deletions

View File

@ -47,3 +47,8 @@ boundaries = {
[25, 255, 255]
]
}
class ColorCodes(Enum):
GREEN = '#4ebc60'

View File

@ -1,3 +1,4 @@
from collections import namedtuple
from enum import Enum
@ -7,3 +8,17 @@ class OnboardingMessages(Enum):
WRONG_PASSWORD = 'Password must be at least 10 characters long'
PASSWORDS_DONT_MATCH = "Passwords don't match"
PASSWORD_INCORRECT = 'Password incorrect'
password_strength_elements = namedtuple('Password_Strength_Elements',
['strength_indicator', 'strength_color', 'strength_messages'])
very_weak_lower_elements = password_strength_elements('Very weak', '#ff2d55', ['• Lower case'])
very_weak_upper_elements = password_strength_elements('Very weak', '#ff2d55', ['• Upper case'])
very_weak_numbers_elements = password_strength_elements('Very weak', '#ff2d55', ['• Numbers'])
very_weak_symbols_elements = password_strength_elements('Very weak', '#ff2d55', ['• Symbols'])
weak_elements = password_strength_elements('Weak', '#fe8f59', ['• Numbers', '• Symbols'])
so_so_elements = password_strength_elements('So-so', '#ffca0f', ['• Lower case', '• Numbers', '• Symbols'])
good_elements = password_strength_elements('Good', '#9ea85d',
['• Lower case', '• Upper case', '• Numbers', '• Symbols'])
great_elements = password_strength_elements('Great', '#4ebc60',
['• Lower case', '• Upper case', '• Numbers', '• Symbols'])

View File

@ -84,6 +84,8 @@ mainWindow_passwordViewNewPassword = {"container": mainWindow_CreatePasswordView
mainWindow_passwordViewNewPasswordConfirm = {"container": mainWindow_CreatePasswordView, "echoMode": 2, "objectName": "passwordViewNewPasswordConfirm", "type": "StatusPasswordInput", "visible": True}
mainWindow_Create_password_StatusButton = {"checkable": False, "container": mainWindow_CreatePasswordView, "objectName": "onboardingCreatePasswordButton", "type": "StatusButton", "visible": True}
mainWindow_view_PasswordView = {"container": statusDesktop_mainWindow, "id": "view", "type": "PasswordView", "unnamed": 1, "visible": True}
mainWindow_RowLayout = {"container": mainWindow_StatusWindow, "type": "RowLayout", "unnamed": 1, "visible": True}
mainWindow_strengthInditactor_StatusPasswordStrengthIndicator = {"container": mainWindow_StatusWindow, "id": "strengthInditactor", "type": "StatusPasswordStrengthIndicator", "unnamed": 1, "visible": True}
# Confirm Password View
mainWindow_ConfirmPasswordView = {"container": statusDesktop_mainWindow, "type": "ConfirmPasswordView", "unnamed": 1,"visible": True}

View File

@ -8,6 +8,7 @@ import allure
import configs
import constants.tesseract
import driver
from constants import ColorCodes
from driver.objects_access import walk_children
from gui.components.os.open_file_dialogs import OpenFileDialog
from gui.components.picture_edit_popup import PictureEditPopup
@ -376,6 +377,8 @@ class CreatePasswordView(OnboardingView):
self._confirm_password_text_field = TextEdit('mainWindow_passwordViewNewPasswordConfirm')
self._create_button = Button('mainWindow_Create_password_StatusButton')
self._password_view_object = QObject('mainWindow_view_PasswordView')
self._strength_indicator = QObject('mainWindow_strengthInditactor_StatusPasswordStrengthIndicator')
self._indicator_panel_object = QObject('mainWindow_RowLayout')
@property
@allure.step('Verify: Create password button enabled')
@ -383,6 +386,32 @@ class CreatePasswordView(OnboardingView):
return driver.waitForObjectExists(self._create_button.real_name,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC).enabled
@property
@allure.step('Get strength indicator color')
def strength_indicator_color(self) -> str:
return self._strength_indicator.object.fillColor['name']
@property
@allure.step('Get strength indicator text')
def strength_indicator_text(self) -> str:
return self._strength_indicator.object.text
@property
@allure.step('Get indicator panel green messages')
def green_indicator_messages(self) -> typing.List[str]:
messages = []
color = ColorCodes.GREEN.value
for child in walk_children(self._indicator_panel_object.object):
if getattr(child, 'id', '') == 'lowerCaseTxt' and child.color['name'] == color:
messages.append(str(child.text))
elif getattr(child, 'id', '') == 'upperCaseTxt' and child.color['name'] == color:
messages.append(str(child.text))
elif getattr(child, 'id', '') == 'numbersTxt' and child.color['name'] == color:
messages.append(str(child.text))
elif getattr(child, 'id', '') == 'symbolsTxt' and child.color['name'] == color:
messages.append(str(child.text))
return messages
@property
@allure.step('Get password error message')
def password_error_message(self) -> str:

View File

@ -0,0 +1,66 @@
import allure
import pytest
from allure_commons._allure import step
import configs.system
import constants
from constants.onboarding import very_weak_lower_elements, very_weak_upper_elements, \
very_weak_numbers_elements, very_weak_symbols_elements, weak_elements, so_so_elements, good_elements, great_elements
from gui.components.onboarding.before_started_popup import BeforeStartedPopUp
from gui.components.onboarding.beta_consent_popup import BetaConsentPopup
from gui.components.splash_screen import SplashScreen
from gui.screens.onboarding import AllowNotificationsView, WelcomeToStatusView, KeysView, BiometricsView
@pytest.fixture
def keys_screen(main_window) -> KeysView:
with step('Open Generate new keys view'):
if configs.system.IS_MAC:
AllowNotificationsView().wait_until_appears().allow()
BeforeStartedPopUp().get_started()
wellcome_screen = WelcomeToStatusView().wait_until_appears()
return wellcome_screen.get_keys()
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/702989',
'Strength of the password')
@pytest.mark.case(702989)
@pytest.mark.parametrize('user_account', [constants.user.user_account_one])
@pytest.mark.parametrize('password, password_strength_elements', [
pytest.param('abcdefghij', very_weak_lower_elements),
pytest.param('ABCDEFGHIJ', very_weak_upper_elements),
pytest.param('1234567890', very_weak_numbers_elements),
pytest.param('+_!!!!!!!!', very_weak_symbols_elements),
pytest.param('+1_3!48888', weak_elements),
pytest.param('+1_3!48a11', so_so_elements),
pytest.param('+1_3!48aT1', good_elements),
pytest.param('+1_3!48aTq', great_elements)
])
def test_check_password_strength_and_login(keys_screen, main_window, user_account, password: str, password_strength_elements):
with step('Input correct user name'):
profile_view = keys_screen.generate_new_keys()
profile_view.set_display_name(user_account.name)
with step('Input password'):
details_view = profile_view.next()
create_password_view = details_view.next()
create_password_view.set_password_in_first_field(password)
with step('Verify that correct strength indicator color, text and green messages appear'):
assert create_password_view.strength_indicator_color == password_strength_elements[1]
assert create_password_view.strength_indicator_text == password_strength_elements[0]
assert sorted(create_password_view.green_indicator_messages) == sorted(password_strength_elements[2])
with step('Verify that user can login afterwards'):
confirm_password_view = create_password_view.create_password(password)
confirm_password_view.confirm_password(password)
if configs.system.IS_MAC:
BiometricsView().wait_until_appears().prefer_password()
SplashScreen().wait_until_appears().wait_until_hidden()
if not configs.DEV_BUILD:
BetaConsentPopup().confirm()
with step('Verify that the user logged in correctly'):
user_canvas = main_window.left_panel.open_user_canvas()
profile_popup = user_canvas.open_profile_popup()
assert profile_popup.user_name == user_account.name