Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secure Upgrade Test Update #8355

Closed
wants to merge 28 commits into from
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bbc14f9
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
77de6c2
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
8ff103e
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
460a5ca
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
a0b570c
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
33212e6
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
446fe7e
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
36d40dc
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
025449d
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
28b2744
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
f4277a9
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
360db65
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
fff9a52
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
5ed43f2
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
4e52d11
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
ed3b3a2
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
98f05fd
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
d858143
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
b255a46
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
af387af
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
4021888
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
2130983
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
dbb8c66
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
1f11b2a
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
cb2435a
Adding new test case for non secure upgarde failure check:
azmyali98 Nov 9, 2022
5e9520d
Introducing new test case for default password change after initial
azmyali98 Nov 21, 2022
74a473b
Revert "Introducing new test case for default password change after i…
azmyali98 Nov 22, 2022
7bdf0f1
Revert "Introducing new test case for default password change after i…
azmyali98 Nov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions tests/platform_tests/test_secure_upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""
This test checks secure upgrade feature. If we have a secure system with secured image installed
on it, the system is expected to install only secured images on it. So trying to install non-secure image
will cause fail and a print of failure message to console indicating it is not a secured image.
This test case validates the error flow mentioned above.

In order to run this test, you need to specify the following argument:

--target_image_list (to contain one non-secure image path e.g. /tmp/images/my_non_secure_img.bin)

Example run from tests directory:
"pytest platform_tests/test_secure_upgrade.py <regular arguments> --target_image_list non_secure_image.bin"
"""
import logging
import pytest
import re
from tests.common.errors import RunAnsibleModuleFail
from tests.common.helpers.assertions import pytest_assert
from tests.upgrade_path.upgrade_helpers import install_sonic

pytestmark = [
pytest.mark.topology('any'),
pytest.mark.disable_loganalyzer,
]

logger = logging.getLogger(__name__)


@pytest.fixture(scope='function', autouse=True)
def keep_same_version_installed(duthost):
'''
@summary: extract the current version installed as shown in the "show boot" output
and restore original image installed after the test run
:param duthost: device under test
'''
output = duthost.shell("show boot")['stdout']
results = re.findall(r"Current\s*\:\s*(.*)\n", output)
pytest_assert(len(results) > 0, "Current image is empty!")
current_version = results[0]
yield
duthost.shell("sudo sonic-installer set-default {}", format(current_version))


@pytest.fixture(scope='session')
def non_secure_image_path(request):
'''
@summary: will extract the non secure image path from --target_image_list parameter
:return: given non secure image path
'''
non_secure_img_path = request.config.getoption('target_image_list')
return str(non_secure_img_path)


def test_non_secure_boot_upgrade_failure(duthost, non_secure_image_path, tbinfo):
"""
@summary: This test case validates non successful upgrade of a given non secure image
"""
# install non secure image
logger.info("install non secure image - expect fail, image path = {}".format(non_secure_image_path))
result = "image install failure" # because we expect fail
try:
# in case of success result will take the target image name
result = install_sonic(duthost, non_secure_image_path, tbinfo)
except RunAnsibleModuleFail as err:
output_msg = str(err.results._check_key("module_stdout"))
err_msg = str(err.results._check_key("msg"))
logger.info("Expected fail, err msg is : {}\n\noutput_msg is {}".format(err_msg, output_msg))
pytest_assert(
"Failure: CMS signature verification failed" in str(output_msg),
"failure was not due to security limitations")
finally:
pytest_assert(result == "image install failure", "non-secure image was successfully installed")