diff --git a/tests/api2/test_550_vmware.py b/tests/api2/test_550_vmware.py index b579ecc971e80..f691d16a5fe71 100644 --- a/tests/api2/test_550_vmware.py +++ b/tests/api2/test_550_vmware.py @@ -1,16 +1,7 @@ -#!/usr/bin/env python3 - -# Author: Eric Turgeon -# License: BSD - -import pytest import sys import os -from pytest_dependency import depends -apifolder = os.getcwd() -sys.path.append(apifolder) -from functions import GET, POST, SSH_TEST -from auto_config import user, password + +import pytest try: Reason = 'VMWARE credentials credential is missing' @@ -26,19 +17,20 @@ def test_01_get_vmware_query(): assert isinstance(results.json(), list) is True -if vmw_credentials: - def test_02_create_vmware(): - payload = { - 'hostname': VMWARE_HOST, - 'username': VMWARE_USERNAME, - 'password': VMWARE_PASSWORD - } - results = POST('/vmware/get_datastores/', payload) - assert results.status_code == 200, results.text - assert isinstance(results.json(), list) is True, results.text - - def test_03_verify_vmware_get_datastore_do_not_leak_password(request): - cmd = f"grep -R \"{os.environ['VMWARE_PASSWORD']}\" " \ - "/var/log/middlewared.log" - results = SSH_TEST(cmd, user, password) - assert results['result'] is False, str(results['output']) +@pytest.mark.skipif(not vmw_credentials, reason='Test only valid with VM credentials') +def test_02_create_vmware(): + payload = { + 'hostname': VMWARE_HOST, + 'username': VMWARE_USERNAME, + 'password': VMWARE_PASSWORD + } + results = POST('/vmware/get_datastores/', payload) + assert results.status_code == 200, results.text + assert isinstance(results.json(), list) is True, results.text + +@pytest.mark.skipif(not vmw_credentials, reason='Test only valid with VM credentials') +def test_03_verify_vmware_get_datastore_do_not_leak_password(request): + cmd = f"grep -R \"{os.environ['VMWARE_PASSWORD']}\" " \ + "/var/log/middlewared.log" + results = SSH_TEST(cmd, user, password) + assert results['result'] is False, str(results['output'])