~aleteoryx/muditaos

de84e4d1b952dfd56c4a11b98709cd9ea9ec8695 — Pawel Olejniczak 4 years ago 2edda4e
[CP-83] Update tests for unlocking phone and usb

Removed leftovers of old usb security tests implementation.
Added tests for unlocking via security endpoint.
M test/firmware_update_test/update.py => test/firmware_update_test/update.py +1 -1
@@ 80,7 80,7 @@ def update(harness, update_filepath: str):


def get_update_list(harness):
    harness.unlock_usb()
    harness.unlock_phone()
    ret = harness.endpoint_request("deviceInfo", "get", {})
    device_info = ret["body"]
    update_history = device_info["updateHistory"]

M test/harness => test/harness +1 -1
@@ 1,1 1,1 @@
Subproject commit 5e89897197e210f9fec418b0765d6234275d4069
Subproject commit 19179cdd311159ada5661f24247b2eaca4b6c4fc

M test/make_a_call.py => test/make_a_call.py +1 -1
@@ 46,7 46,7 @@ def main():
        port_name = sys.argv[1]

    harness = Harness(sys.argv[1])
    harness. unlock_usb()
    harness.unlock_phone()
    number = str(sys.argv[2])
    duration = int(sys.argv[3])
    count_before = get_calllog_count(harness)

M test/phone_modem_clear_sms_queue.py => test/phone_modem_clear_sms_queue.py +0 -1
@@ 8,7 8,6 @@ import sys


harness = Harness(sys.argv[1])
harness.unlock_usb()

harness.connection.send_at("at+cmgl=\"all\"", 10000)
harness.connection.send_at("at+cmgd=1,4", 10000)

M test/phone_off.py => test/phone_off.py +0 -1
@@ 28,7 28,6 @@ def main():
        port_name = sys.argv[1]

    harness = Harness(port_name)
    harness.unlock_usb()
    harness.unlock_phone()
    harness.turn_phone_off()


M test/phone_sim_check.py => test/phone_sim_check.py +0 -2
@@ 7,8 7,6 @@ from harness.harness import Harness
import sys

harness = Harness(sys.argv[1])
harness.unlock_usb()


results = harness.connection.send_at("AT+CPIN?", 10000)
for result in results:

M test/phone_sim_detection_on.py => test/phone_sim_detection_on.py +0 -1
@@ 6,7 6,6 @@ from harness.harness import Harness
import sys

harness = Harness(sys.argv[1])
harness.unlock_usb()

harness.connection.send_at("at+qsimdet=1,0", 10000)
harness.connection.send_at("AT+QSIMSTAT=1", 10000)

M test/phone_unlock.py => test/phone_unlock.py +2 -1
@@ 6,7 6,8 @@
from harness.harness import Harness

harness = Harness.from_detect()
harness. unlock_usb()


@harness.with_phone_unlocked
def done(connection):
    pass

M test/pytest/conftest.py => test/pytest/conftest.py +5 -8
@@ 131,21 131,18 @@ def harnesses():
@pytest.fixture(scope='session')
def phone_unlocked(harness):
    harness.unlock_phone()
    assert harness.is_phone_unlocked
    assert not harness.is_phone_locked()

@pytest.fixture(scope='session')
def usb_unlocked(harness):
    harness.unlock_usb()

@pytest.fixture(scope='session')
def usb_locked(harness):
    harness.lock_usb()
def phone_locked(harness):
    harness.lock_phone()
    assert harness.is_phone_locked()

@pytest.fixture(scope='session')
def phones_unlocked(harnesses):
    for harness in harnesses:
        harness.unlock_phone()
        assert harness.is_phone_unlocked
        assert not harness.is_phone_locked()


@pytest.fixture(scope='session')

M test/pytest/service-bluetooth/test_basic_control_dev_perspective.py => test/pytest/service-bluetooth/test_basic_control_dev_perspective.py +2 -2
@@ 10,7 10,7 @@ from bt_utils import *

@pytest.mark.rt1051
@pytest.mark.usefixtures("bt_state_off")
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_bt_turning_on_off(harness):
    state = bt_get_state(harness)
    assert state["power"] == "off"


@@ 30,7 30,7 @@ def test_bt_turning_on_off(harness):

@pytest.mark.rt1051
@pytest.mark.usefixtures("bt_state_on")
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_bt_visibility_on_off(harness):
    state = bt_get_state(harness)
    assert state["power"] == "on"

M test/pytest/service-bluetooth/test_pairing_dev_perspective.py => test/pytest/service-bluetooth/test_pairing_dev_perspective.py +2 -2
@@ 9,7 9,7 @@ from bt_utils import *

@pytest.mark.rt1051
@pytest.mark.usefixtures("bt_state_on")
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.skipif("not config.getvalue('--bt_device')", reason='--bt_device was not specified')
def test_bt_pairing_dev(harness, bt_device):
    time.sleep(1)


@@ 47,7 47,7 @@ def test_bt_pairing_dev(harness, bt_device):

@pytest.mark.rt1051
@pytest.mark.usefixtures("bt_state_on")
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.skipif("not config.getvalue('--bt_device')", reason='--bt_device was not specified')
def test_bt_connection_dev(harness, bt_device):
    time.sleep(1)

M test/pytest/service-bluetooth/test_pairing_hmi_perspective.py => test/pytest/service-bluetooth/test_pairing_hmi_perspective.py +0 -1
@@ 14,7 14,6 @@ from bt_fixtures import *
@pytest.mark.usefixtures("bt_main_window")
@pytest.mark.usefixtures("phone_in_desktop")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.skipif("not config.getvalue('--bt_device')", reason='--bt_device was not specified')
def test_bt_pairing_hmi(harness, bt_device):
    if not bt_device:

M test/pytest/service-desktop/test_backup.py => test/pytest/service-desktop/test_backup.py +1 -1
@@ 9,7 9,7 @@ from harness.interface.defs import status

@pytest.mark.service_desktop_test
@pytest.mark.rt1051
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.backup
def test_backup(harness):
    body = { "request": True }

M test/pytest/service-desktop/test_battery_file.py => test/pytest/service-desktop/test_battery_file.py +1 -1
@@ 6,7 6,7 @@ from harness.interface.defs import status

@pytest.mark.rt1051
@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_battery_file(harness):
    body = {"command" : "checkFile" , "fileName" : "/sys/user/batteryFuelGaugeConfig.cfg"}
    ret = harness.endpoint_request("filesystemUpload", "post", body)

M test/pytest/service-desktop/test_calendar.py => test/pytest/service-desktop/test_calendar.py +1 -1
@@ 7,7 7,7 @@ import copy

@pytest.mark.rt1051
@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_calendar(harness):
    # add events
    add_body = {

M test/pytest/service-desktop/test_calendar_events.py => test/pytest/service-desktop/test_calendar_events.py +1 -1
@@ 6,7 6,7 @@ import copy
import time

@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_calendar(harness):
    # add events
    add_body = {

M test/pytest/service-desktop/test_calllog.py => test/pytest/service-desktop/test_calllog.py +2 -2
@@ 1,11 1,11 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import pytest
from harness.interface.defs import status


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_calllog(harness):
    # checking call log count
    body = {"count": True}

M test/pytest/service-desktop/test_contacts.py => test/pytest/service-desktop/test_contacts.py +2 -2
@@ 1,11 1,11 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import pytest
from harness.interface.defs import status


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_contacts(harness):
    # getting the contacts count
    body = {"count": True}

M test/pytest/service-desktop/test_device_info.py => test/pytest/service-desktop/test_device_info.py +1 -1
@@ 5,7 5,7 @@ from harness.interface.defs import status


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_device_info(harness):
    body = {}
    ret = harness.endpoint_request("deviceInfo", "get", body)

M test/pytest/service-desktop/test_factory_reset.py => test/pytest/service-desktop/test_factory_reset.py +1 -1
@@ 6,7 6,7 @@ from harness.interface.defs import status

@pytest.mark.service_desktop_test
@pytest.mark.rt1051
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_factory_reset(harness):
    body = {"factoryRequest": True}
    ret = harness.endpoint_request("factory", "post", body)

M test/pytest/service-desktop/test_messages.py => test/pytest/service-desktop/test_messages.py +8 -8
@@ 8,7 8,7 @@ MESSAGES_PAGE_SIZE = 4


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_messages_without_pagination(harness):
    limit = MESSAGES_PAGE_SIZE - 1
    get_body = {"category": "message", "limit": limit, "offset": 0}


@@ 30,7 30,7 @@ def test_get_messages_without_pagination(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_messages_with_pagination(harness):
    limit = MESSAGES_PAGE_SIZE + 1
    body = {"category": "message", "limit": limit, "offset": 0}


@@ 43,7 43,7 @@ def test_get_messages_with_pagination(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_all_messages(harness):
    # get messages count
    body = {"category": "message", "count": True}


@@ 85,7 85,7 @@ def test_get_all_messages(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_messages_by_thread_id_without_pagination(harness):
    thread_id = 1
    limit = MESSAGES_PAGE_SIZE - 1


@@ 101,7 101,7 @@ def test_get_messages_by_thread_id_without_pagination(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_messages_by_thread_id_with_pagination(harness):
    thread_id = 1
    limit = MESSAGES_PAGE_SIZE + 1


@@ 117,7 117,7 @@ def test_get_messages_by_thread_id_with_pagination(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_all_messages_by_thread_id(harness):
    thread_id = 1
    # get messages count


@@ 160,7 160,7 @@ def test_get_all_messages_by_thread_id(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_remove_message(harness):
    # get messages count
    body = {"category": "message", "count": True}


@@ 194,7 194,7 @@ def test_remove_message(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_message_by_id(harness):
    message_id = 1
    get_body = {"category": "message", "messageID": message_id}

M test/pytest/service-desktop/test_restore.py => test/pytest/service-desktop/test_restore.py +1 -1
@@ 8,7 8,7 @@ from harness import log

@pytest.mark.service_desktop_test
@pytest.mark.rt1051
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.restore
def test_restore(harness):
    # this requests the list of available files

M test/pytest/service-desktop/test_security.py => test/pytest/service-desktop/test_security.py +48 -7
@@ 6,8 6,8 @@ from harness.interface.defs import status


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
def test_security_usb_unlocked(harness):
@pytest.mark.usefixtures("phone_unlocked")
def test_security_phone_unlocked(harness):
    body = {}

    ret = harness.endpoint_request("deviceInfo", "get", body)


@@ 15,8 15,8 @@ def test_security_usb_unlocked(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_locked")
def test_security_usb_locked(harness):
@pytest.mark.usefixtures("phone_locked")
def test_security_phone_locked_with_code(harness):
    body = {}

    ret = harness.endpoint_request("usbSecurity", "get", body)


@@ 24,8 24,8 @@ def test_security_usb_locked(harness):


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_locked")
def test_all_other_endpoints_usb_locked(harness):
@pytest.mark.usefixtures("phone_locked")
def test_all_other_endpoints_phone_locked_with_code(harness):
    body = {}
    endpoints_list = ["deviceInfo",
                      "update",


@@ 55,4 55,45 @@ def test_all_other_endpoints_usb_locked(harness):
    ret = harness.endpoint_request("developerMode", "get", body)
    assert ret["status"] == status["OK"]

    harness.unlock_usb()

@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_security_phone_locked_without_code(harness):
    body = {"phoneLockCodeEnabled": False}
    ret = harness.endpoint_request("developerMode", "put", body)
    assert ret["status"] == status["OK"]

    harness.lock_phone()
    body = {}
    ret = harness.endpoint_request("usbSecurity", "get", body)
    assert ret["status"] == status["OK"]

    body = {"phoneLockCodeEnabled": True}
    ret = harness.endpoint_request("developerMode", "put", body)
    assert ret["status"] == status["OK"]

    harness.lock_phone()
    body = {}
    ret = harness.endpoint_request("usbSecurity", "get", body)
    assert ret["status"] == status["Forbidden"]


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_security_unlock_phone(harness):

    body = {"phoneLockCode": "1111"}
    ret = harness.endpoint_request("usbSecurity", "put", body)
    assert ret["status"] == status["Forbidden"]

    body = {"phoneLockCode": "1"}
    ret = harness.endpoint_request("usbSecurity", "put", body)
    assert ret["status"] == status["BadRequest"]

    body = {"phoneLockCode": "3333"}
    ret = harness.endpoint_request("usbSecurity", "put", body)
    assert ret["status"] == status["OK"]

    body = {}
    ret = harness.endpoint_request("deviceInfo", "get", body)
    assert ret["status"] == status["OK"]

M test/pytest/service-desktop/test_templates.py => test/pytest/service-desktop/test_templates.py +4 -4
@@ 145,28 145,28 @@ class TemplatesTester:


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_template_by_id(harness):
    templates_tester = TemplatesTester(harness)
    templates_tester.test_getting_template_by_id()


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_templates_without_pagination(harness):
    templates_tester = TemplatesTester(harness)
    templates_tester.test_getting_templates_without_pagination()

@pytest.mark.rt1051
@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_change_template(harness):
    templates_tester = TemplatesTester(harness)
    templates_tester.test_changing_template_body()

@pytest.mark.rt1051
@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_get_templates_with_pagination(harness):
    templates_tester = TemplatesTester(harness)
    templates_tester.test_getting_templates_with_pagination()

M test/pytest/service-desktop/test_threads.py => test/pytest/service-desktop/test_threads.py +1 -1
@@ 5,7 5,7 @@ from harness.interface.defs import status


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_threads(harness):
    # getting all threads
    body = {"category": "thread"}

M test/pytest/service-desktop/test_update.py => test/pytest/service-desktop/test_update.py +1 -1
@@ 5,7 5,7 @@ from harness.interface.defs import status


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.rt1051
def test_update(harness):
    body = {}

M test/pytest/test_call.py => test/pytest/test_call.py +0 -1
@@ 8,7 8,6 @@ from module_apps.call_utils import get_calllog_count, select_call_button
@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_ends_test_in_desktop")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")
def test_call(harness, phone_number, call_duration):
    count_before = get_calllog_count(harness)
    # enter number

M test/pytest/test_call_back.py => test/pytest/test_call_back.py +0 -1
@@ 10,7 10,6 @@ from module_apps.call_utils import get_calllog_count, select_call_button
@pytest.mark.usefixtures("phone_ends_test_in_desktop")
@pytest.mark.usefixtures("phone_in_desktop")
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")
def test_call(harness, call_duration):
    count_before = get_calllog_count(harness)


M test/pytest/test_cellular_sleep.py => test/pytest/test_cellular_sleep.py +2 -3
@@ 26,8 26,7 @@ def wait_for_cellular_sleep(harness, max_attempts):


@pytest.mark.rt1051
@pytest.mark.usefixtures("usb_unlocked")

@pytest.mark.usefixtures("phone_unlocked")
def test_call_during_cellular_sleep_mode(harness, phone_number, call_duration, max_attempts = 10):
    cellular_sleep_mode = wait_for_cellular_sleep(harness, max_attempts)
    if (cellular_sleep_mode == False):


@@ 43,7 42,7 @@ def test_call_during_cellular_sleep_mode(harness, phone_number, call_duration, m
    assert ret["body"]["cellularSleepMode"] == False

@pytest.mark.rt1051
@pytest.mark.usefixtures("usb_unlocked")
@pytest.mark.usefixtures("phone_unlocked")
def test_sms_during_cellular_sleep_mode(harness, phone_number, sms_text, max_attempts = 10):
    cellular_sleep_mode = wait_for_cellular_sleep(harness, max_attempts)
    if (cellular_sleep_mode == False):

M test/pytest/test_cellular_start.py => test/pytest/test_cellular_start.py +0 -4
@@ 42,8 42,6 @@ def wait_for_cellular_state(harness, state, max_attempts = 10):

@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")

def test_cellular_cold_start(harness, phone_number, sms_text):
    ret = request_cellular_state_info(harness)
    assert ret["status"] == status["OK"]


@@ 72,8 70,6 @@ def test_cellular_cold_start(harness, phone_number, sms_text):

@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")

def test_cellular_hot_start(harness, phone_number, sms_text):
    time.sleep(2)
    request_cellular_power_state_change(harness, cellular_states["HotStart"])

M test/pytest/test_send_message.py => test/pytest/test_send_message.py +0 -1
@@ 174,7 174,6 @@ def remove_added_messages(harness, diff_messages):
@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("phone_in_desktop")
@pytest.mark.usefixtures("usb_unlocked")
def test_send_message(harness, phone_number, sms_text):
    old_messages = get_message_by_text(harness, sms_text, str(phone_number))


M test/search_sms.py => test/search_sms.py +1 -1
@@ 37,7 37,7 @@ def main():
        port_name = sys.argv[1]

    harness = Harness(port_name)
    harness. unlock_usb()
    harness.unlock_phone()
    message = str(sys.argv[2])
    phone_number = str(sys.argv[3])


M test/set_tethering.py => test/set_tethering.py +0 -1
@@ 26,7 26,6 @@ def main():
        port_name = sys.argv[1]

    harness = Harness(port_name)
    harness. unlock_usb()
    state = int(sys.argv[2])

    harness.unlock_phone()

M test/version_check.py => test/version_check.py +1 -1
@@ 50,7 50,7 @@ def main():
        exit()

    harness = Harness(port_name)
    harness.unlock_usb()
    harness.unlock_phone()
    [rev, branch, tag] = get_version(harness)

    if args.git_tag != tag or args.git_branch != branch or args.git_revision != rev: