From a95d118959ba98113f5785b36ab1386d1dfbc18f Mon Sep 17 00:00:00 2001 From: Anton Danchenko Date: Thu, 9 Nov 2017 12:58:11 +0200 Subject: [PATCH] added verification of user data absence in logcat --- test/appium/tests/__init__.py | 6 +++--- test/appium/tests/test_sanity.py | 30 +++++++++++++++++++------- test/appium/views/base_view.py | 37 ++++++++++++++++++++++++++++++-- test/appium/views/home.py | 9 -------- 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/test/appium/tests/__init__.py b/test/appium/tests/__init__.py index ea4d1d66e7..535c907555 100644 --- a/test/appium/tests/__init__.py +++ b/test/appium/tests/__init__.py @@ -18,9 +18,9 @@ class TestData(object): self.name = None -basic_user = {'password': "qwerty", - 'passphrase': "level acquire claim tide company believe duck embody consider dune century mountain", - 'username': "Silky Heavenly Zethusspinipes"} +basic_user = {'password': "newuniquepassword12", + 'passphrase': "tree weekend ceiling awkward universe pyramid glimpse raven pair lounge grant grief", + 'username': "Splendid Useless Racerunner"} transaction_users = { 'A_USER': {'password': "qwerty", diff --git a/test/appium/tests/test_sanity.py b/test/appium/tests/test_sanity.py index c975c68307..f485168ba6 100644 --- a/test/appium/tests/test_sanity.py +++ b/test/appium/tests/test_sanity.py @@ -40,6 +40,7 @@ class TestAccess(SingleDeviceTestCase): for text in new_status + ' ', new_username: chats.find_full_text(text, 5) + @pytest.mark.recover def test_recover_access(self): home = HomeView(self.driver) set_password_as_new_user(home) @@ -56,7 +57,10 @@ class TestAccess(SingleDeviceTestCase): login.password_input.send_keys(basic_user['password']) login.sign_in_button.click() home.find_full_text('Chats', 60) + if basic_user['password'] in str(home.logcat): + pytest.fail('Password in logcat!!!', pytrace=False) + @pytest.mark.sign_in @pytest.mark.parametrize("verification", ["invalid", "valid"]) def test_sign_in(self, verification): @@ -76,20 +80,30 @@ class TestAccess(SingleDeviceTestCase): login.password_input.send_keys(verifications[verification]['input']) login.sign_in_button.click() home.find_full_text(verifications[verification]["outcome"], 60) + if verifications[verification]["input"] in str(home.logcat): + pytest.fail('Password in logcat!!!', pytrace=False) - @pytest.mark.parametrize("verification", ["short", "mismatch"]) + @pytest.mark.password + @pytest.mark.parametrize("verification", ["logcat", "mismatch", "short"]) def test_password(self, verification): - verifications = {"short": - {"input": "qwe1", - "outcome": "Password should be not less then 6 symbols."}, - "mismatch": - {"input": "mismatch1234", - "outcome": "Password confirmation doesn\'t match password."}} + verifications = { + "short": {"input": "qwe1", + "outcome": "Password should be not less then 6 symbols."}, + + "mismatch": {"input": "mismatch1234", + "outcome": "Password confirmation doesn\'t match password."}, + + "logcat": {"input": "new_unique_password", + "outcome": "Here is your signing phrase. " + "You will use it to verify your transactions. " + "Write it down and keep it safe!"}} home = HomeView(self.driver) home.request_password_icon.click() home.chat_request_input.send_keys(verifications[verification]["input"]) home.confirm() if 'short' not in verification: - home.chat_request_input.send_keys("qwerty1234") + home.chat_request_input.send_keys("new_unique_password") home.confirm() home.find_full_text(verifications[verification]["outcome"]) + if verifications[verification]["input"] in str(home.logcat): + pytest.fail('Password in logcat!!!', pytrace=False) diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 7d7c36dd59..4f14b1c071 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -110,6 +110,27 @@ class SaveButton(BaseButton): "//android.widget.TextView[@text='SAVE']") +class ChatRequestInput(BaseEditBox): + + def __init__(self, driver): + super(ChatRequestInput, self).__init__(driver) + self.locator = \ + self.Locator.xpath_selector("//android.widget.EditText[@content-desc!='chat-message-input']") + + +class AppsButton(BaseButton): + def __init__(self, driver): + super(AppsButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id("Apps") + + +class StatusAppIcon(BaseButton): + def __init__(self, driver): + super(StatusAppIcon, self).__init__(driver) + self.locator = self.Locator.xpath_selector( + "//*[@text='Status']") + + class BaseViewObject(object): def __init__(self, driver): self.driver = driver @@ -118,8 +139,10 @@ class BaseViewObject(object): self.no_button = NoButton(self.driver) self.back_button = BackButton(self.driver) self.deny_button = DenyButton(self.driver) - self.continue_button_apk = ContinueButtonAPK(driver) - self.ok_button_apk = OkButtonAPK(driver) + self.continue_button_apk = ContinueButtonAPK(self.driver) + self.ok_button_apk = OkButtonAPK(self.driver) + self.apps_button = AppsButton(self.driver) + self.status_app_icon = StatusAppIcon(self.driver) self.contacts_button = ContactsButton(self.driver) self.wallet_button = WalletButton(self.driver) @@ -127,6 +150,12 @@ class BaseViewObject(object): self.save_button = SaveButton(self.driver) + self.chat_request_input = ChatRequestInput(self.driver) + + @property + def logcat(self): + return self.driver.get_log("logcat") + def confirm(self): logging.info("Tap 'Confirm' on native keyboard") self.driver.keyevent(66) @@ -168,6 +197,10 @@ class BaseViewObject(object): from views.chats import ChatsViewObject return ChatsViewObject(self.driver) + def get_login(self): + from views.login import LoginView + return LoginView(self.driver) + def get_balance(self, address): url = 'http://ropsten.etherscan.io/api?module=account&action=balance&address=0x%s&tag=latest' % address for i in range(5): diff --git a/test/appium/views/home.py b/test/appium/views/home.py index f5d5fbebb1..3f208ce70d 100644 --- a/test/appium/views/home.py +++ b/test/appium/views/home.py @@ -3,14 +3,6 @@ from views.base_element import * from tests import tests_data -class ChatRequestInput(BaseEditBox): - - def __init__(self, driver): - super(ChatRequestInput, self).__init__(driver) - self.locator = \ - self.Locator.xpath_selector("//android.widget.EditText[@content-desc!='chat-message-input']") - - class RequestPasswordIcon(BaseButton): def __init__(self, driver): @@ -44,6 +36,5 @@ class HomeView(BaseViewObject): i.click() except (NoSuchElementException, TimeoutException): pass - self.chat_request_input = ChatRequestInput(self.driver) self.request_password_icon = RequestPasswordIcon(self.driver) self.recover_button = RecoverButton(self.driver)